pax_global_header 0000666 0000000 0000000 00000000064 14561607147 0014525 g ustar 00root root 0000000 0000000 52 comment=cc4f18322ac0d881c4adb8a2bd3298799e8064db
ukui-app-widget-4.0.0.2/ 0000775 0000000 0000000 00000000000 14561607147 0014702 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/LICENSE 0000664 0000000 0000000 00000105755 14561607147 0015724 0 ustar 00root root 0000000 0000000 GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.
ukui-app-widget-4.0.0.2/README.md 0000664 0000000 0000000 00000011146 14561607147 0016164 0 ustar 00root root 0000000 0000000 ## ukui-app-widget
ukui-app-widget是UKUI桌面环境的小插件框架,
插件用户可以使用小插件框架实现桌面环境小插件UI;
### 依赖
------
### 编译依赖
- debhelper-compat
- qt5-qmake
- qtbase5-dev
- qtbase5-dev-tools
- qtdeclarative5-dev
- qtquickcontrols2-5-dev
- libglib2.0-dev
- libgsettings-qt-dev
- libukui-log4qt-dev
### 编译
------
```shell
$ cd ukui-app-widget
$ mkdir build
$ cd build
$ qmake ..
$ make
```
### 安装
------
```shell
$ sudo make install
```
### 框架组成
- **InProgress**
- 小插件管理服务
- 小插件使用端
- 小插件提供端
- **TROUBLE**
- 无
### SDK组成
- **InProgress**
- libukui-appwidget-manager
- libukui-appwidget-plugin
- libukui-appwidget-provider
- AppWidget.qml
- **TROUBLE**
- 无
### 模块介绍
#### 框架
- **管理服务模块**
小插件框架中的后台管理服务,主要提供提供端与使用端
的通信能力。
- **使用端**
用于显示小插件的应用组件,使用端可以不唯一,小插件使
用端可以通过小插件框架提供的sdk获取到对应的小插件信息
以及ui文件。
- **提供端**
应用组件作为提供端为小插件服务提供小插件ui界面,小插件
的配置信息,小插件的更新数据服务。
- **ukui-appwidget-test**
小插件框架应用的demo
##### SDK
- **libukui-appwidget-manager**
小插件管理服务接口SDK,用户可以通过该接口获取到小插件
的信息,提供端可以通过管理服务接口推送更新数据。
- **libukui-appwidget-plugin**
封装为qml可以使用的内部插件库,由Appwidget.qml控件导入
使用,是qml与小插件使用端的通信类,封装为点击事件消息、
自定义事件消息、使用端注册dbus的接口以及数据更新的函数。
- **libukui-appwidget-provider**
小插件提供端SDK,提供端可以通过继承该类实现提供端的服务。
接收由管理服务传来的消息。
- **AppWidget.qml**
qml控件的封装,用于小插件实例使用,负责连接qml与内部插件
库函数,作为中间控件实现小插件实例与使用端的通信。
### 接口使用
#### 使用端接口
- **获取小插件列表**
QStringList getAppWidgetList();
功能说明:获取可加载的小插件列表(列表形式如:("clock", "search"),列表内容为小插件名字)。
- **获取小插件ui文件路径**
QString getAppWidgetUiFile(const QString &appwidgetname);
功能说明:通过小插件名字获取小插件qml ui布局文件(ui路径如:"/usr/share/appwidget/qml/search.qml")
- **获取小插件的config属性**
QString getAppWidgetConfig(const QString &appwidgetname,const AppWidgetConfig& config)
功能说明:通过小插件名称,以及小插件的属性config获取小插件的配置信息
- **获取小插件的所有属性**
QMap getAppWidgetConfigs(const QString &appwidgetname);
功能说明:用于一次性获取小插件的所有配置信息
- **更新使用端状态**
void updateUserStatus(const QString &username, const UserStatus& userstatus);
功能说明:用于使用端通知小插件使用端状态
- **使用端注册小插件**
register(QString appname, QString usrname);
功能说明:用户使用端qml界面注册小插件,在使用端加载小插件时调用
#### 提供端接口
创建提供端类,该类需要继承KAppWidgetProvider类
- **小插件自定义事件**
void appWidgetRecevie(const QString &eventname, const QString &widgetname, const QDBusVariant &value);
功能说明:用于响应小插件qml中发送的自定义事件
- **小插件更新函数**
void appWidgetUpdate();
功能说明:用于响应由管理服务发送来的更新通知
- **小插件禁用函数**
void appWidgetDisable();
功能说明:用于响应由管理服务发送来的小插件禁用通知(当该提供端的所有小插件都被移除后发送)
- **小插件删除函数**
void appWidgetDeleted();
功能说明:用于响应由管理服务发送来的使用端小插件删除通知
- **小插件启用函数**
void appWidgetEnable();
功能说明:用于响应由管理服务发送来的小插件通知(当该提供端的小插件第一次被添加时发送)
- **小插件点击函数**
void appWidgetClicked(const QString &widgetname, const QDBusVariant &value);
功能说明:用于响应由管理服务发送来的小插件点击事件通知
ukui-app-widget-4.0.0.2/libukui-app-widget/ 0000775 0000000 0000000 00000000000 14561607147 0020405 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-app-widget.pro 0000664 0000000 0000000 00000000657 14561607147 0024642 0 ustar 00root root 0000000 0000000 TEMPLATE = subdirs
SUBDIRS += \
libukui-appwidget-plugin \
libukui-appwidget-manager \
libukui-appwidget-provider
#编译依赖顺序
libukui-appwidget-plugin.depends += libukui-appwidget-manager
unix {
installPath = $$[QT_INSTALL_LIBS]/qt5/qml/org/ukui/appwidget/
# installPath = /usr/share/appwidget/qml/
template.files = org.ukui.appwidget/*
template.path = $$installPath
INSTALLS += template
}
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-manager/ 0000775 0000000 0000000 00000000000 14561607147 0025443 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-manager/kappwidgetmanager.cpp 0000664 0000000 0000000 00000020424 14561607147 0031643 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "kappwidgetmanager.h"
#include
#include
#include
#include
#include
namespace AppWidget
{
KAppWidgetManager::KAppWidgetManager(QObject *parent)
:QDBusInterface(KAppWidgetCommon::getManagerDbusObject(),
KAppWidgetCommon::getManagerDbusPath(),
KAppWidgetCommon::getManagerDbusInterface(),QDBusConnection::sessionBus(),parent)
{
qDBusRegisterMetaType>();
}
QStringList KAppWidgetManager::getAppWidgetList()
{
qDebug() << "KAppWidgetManager::getAppWidgetList";
QStringList appWidgetList;
QDBusMessage response = call("getAppWidgetList");
if (response.type() == QDBusMessage::ErrorMessage ) {
qCritical() << "ERROR" << response.errorMessage();
return QStringList();
}
if (response.type() == QDBusMessage::ReplyMessage) {
appWidgetList = response.arguments().takeFirst().toStringList();
}
return appWidgetList;
}
QString KAppWidgetManager::getAppWidgetUiFile(const QString &appwidgetname)
{
qDebug() << "KAppWidgetManager::getAppWidgetUiFile";
if(appwidgetname.isEmpty()) {
qWarning() << "parameter is empty";
return QString();
}
QString uiFile;
QDBusMessage response = call("getAppWidgetUiFile", appwidgetname);
if (response.type() == QDBusMessage::ErrorMessage ) {
qCritical() << "ERROR" << response.errorMessage();
return QString();
}
if (response.type() == QDBusMessage::ReplyMessage) {
uiFile = response.arguments().takeFirst().toString();
}
return uiFile;
}
QString KAppWidgetManager::getAppWidgetConfig(const QString &appwidgetname,
const AppWidgetConfig& config)
{
qDebug() << "KAppWidgetManager::getAppWidgetConfig";
if(appwidgetname.isEmpty()) {
qWarning() << "parameter is empty";
return QString();
}
QString uiFile;
QDBusMessage response = call("getAppWidgetConfig", appwidgetname, enumToSTring(config));
if (response.type() == QDBusMessage::ErrorMessage ) {
qCritical() << "ERROR" << response.errorMessage();
return QString();
}
if (response.type() == QDBusMessage::ReplyMessage) {
uiFile = response.arguments().takeFirst().toString();
}
return uiFile;
}
QMap KAppWidgetManager::getAppWidgetConfigs(const QString &appwidgetname)
{
qDebug() << "KAppWidgetManager::getAppWidgetConfigs";
if(appwidgetname.isEmpty()) {
qWarning() << "parameter is empty";
return QMap();
}
QMap confs;
QDBusPendingReply> reply = call("getAppWidgetConfigs", appwidgetname);
confs =reply.value();
return confs;
}
int KAppWidgetManager::registerAppWidget(const QString &appwidgetname,
const QString &username)
{
qDebug() << "KAppWidgetManager::registerAppWidget";
if(appwidgetname.isEmpty() || username.isEmpty()) {
qWarning() << "parameter is empty";
return -1;
}
int id = -1;
QDBusMessage response = call("registerAppWidget", appwidgetname, username);
if (response.type() == QDBusMessage::ErrorMessage ) {
qCritical() << "ERROR" << response.errorMessage();
return -1;
}
if (response.type() == QDBusMessage::ReplyMessage) {
id = response.arguments().takeFirst().toInt();
}
return id;
}
bool KAppWidgetManager::unregisterAppWidget(const int &appwidgetid)
{
qDebug() << "KAppWidgetManager::unregisterAppWidget";
if(appwidgetid < 0) {
qWarning() << "parameter is error";
return false;
}
bool unregister = false;
QDBusMessage response = call("unregisterAppWidget", appwidgetid);
if (response.type() == QDBusMessage::ErrorMessage ) {
qCritical() << __FUNCTION__ << __LINE__ << response.errorMessage();
return false;
}
if (response.type() == QDBusMessage::ReplyMessage) {
unregister = response.arguments().takeFirst().toBool();
}
return unregister;
}
QMap KAppWidgetManager::getAppWidgetData(const int &appwidgetid)
{
qDebug() << "KAppWidgetManager::getAppWidgetData";
if(appwidgetid < 0) {
qWarning() << __FUNCTION__ << __LINE__ << "get invalid id :" << appwidgetid;
return QMap();
}
QDBusPendingReply> reply = asyncCall("getAppWidgetData", appwidgetid);
reply.waitForFinished();
if (reply.isError()) {
qDebug() << __FUNCTION__ << __LINE__ << reply.error().message();
return QMap();
}
QMap map = reply.value();
return map;
}
void KAppWidgetManager::updateAppWidget(const QString &providername,
const QMap &data)
{
qDebug() << "KAppWidgetManager::updateAppWidget" << providername << data;
if(providername.isEmpty()) {
qWarning() << "parameter is empty";
return ;
}
asyncCall("updateAppWidget", providername, data);
}
QString KAppWidgetManager::enumToSTring(const AppWidgetConfig& config)
{
QString conf;
switch (config) {
case AppWidgetConfig::NAME:
conf = "name";
break;
case AppWidgetConfig::PROVIDER_NAME:
conf = "providerName";
break;
case AppWidgetConfig::PREVIEW_PATH:
conf = "previewPath";
break;
case AppWidgetConfig::ZOOM:
conf = "zoom";
break;
case AppWidgetConfig::RIGHT_BUTTON:
conf = "rightButton";
break;
case AppWidgetConfig::REPEAT_PLACEMENT:
conf = "repeatPlacement";
break;
case AppWidgetConfig::MIN_WIDTH:
conf = "minWidget";
break;
case AppWidgetConfig::MIN_HEIGHT:
conf = "minHeight";
break;
case AppWidgetConfig::TARGET_CELL_WIDTH:
conf = "targetCellWidth";
break;
case AppWidgetConfig::TARGET_CELL_HEIGHT:
conf = "targetCellHeight";
break;
case AppWidgetConfig::UPDATE_PERIODMILLIS:
conf = "updatePeriodMillis";
break;
case AppWidgetConfig::DESCRIBE:
conf = "describe";
break;
default:
break;
}
return conf;
}
QString KAppWidgetManager::enumUserStatusToSTring(const UserStatus& userstatus)
{
QString status = "Normal";
switch (userstatus) {
case UserStatus::NORMAL:
status = "Normal";
break;
case UserStatus::EDITABLE:
status = "Editable";
break;
default:
break;
}
return status;
}
void KAppWidgetManager::updateUserStatus(const QString &username, const UserStatus& userstatus)
{
if(username.isEmpty()) {
qWarning() << __FUNCTION__ << __LINE__ << "参数不能为空";
return;
}
QString status = enumUserStatusToSTring(userstatus);
asyncCall("updateUserStatus", username, status);
}
void KAppWidgetManager::notifyProviderUpdate(int id) {
asyncCall("notifyProviderUpdate", id);
}
QMap KAppWidgetManager::getAppWidgetLanguageFiles(const QString &appwidgetname)
{
if(appwidgetname.isEmpty()) {
qWarning() << __FILE__ << __FUNCTION__ << "appwidgetname is empty";
return QMap();
}
QDBusReply> reply = call("getAppWidgetLanguageFiles", appwidgetname);
if (!reply.isValid()) {
qWarning() << __FUNCTION__ << __LINE__ << reply.error();
return QMap();
}
return reply.value();
}
}// namespace AppWidget
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-manager/kappwidgetmanager.h 0000664 0000000 0000000 00000011030 14561607147 0031301 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef KAPPWIDGETMANAGER_H
#define KAPPWIDGETMANAGER_H
#include "libukui-appwidget-manager_global.h"
#include
namespace AppWidget
{
/**
* @defgroup 小插件管理服务接口模块
*/
/**
* @brief 小插件属性枚举
*/
enum AppWidgetConfig {
NAME = 1, //小插件名字
PROVIDER_NAME, //提供端名
PREVIEW_PATH, //预览图
ZOOM, //是否支持缩放
RIGHT_BUTTON, //是否支持右键
REPEAT_PLACEMENT, //是否可以重复放置
MIN_WIDTH, //最小宽度
MIN_HEIGHT, //最小高度
TARGET_CELL_WIDTH, //小插件默认宽度所占屏幕的单位格数
TARGET_CELL_HEIGHT, //小插件默认高度所占屏幕的单位格数
UPDATE_PERIODMILLIS, //是否定时更新
DESCRIBE, //小插件描述
};
/**
* @brief 使用端状态属性枚举
*/
enum UserStatus {
NORMAL = 1, //正常状态
EDITABLE = 2, //编辑状态
};
class LIBUKUIAPPWIDGETMANAGER_EXPORT KAppWidgetManager : public QDBusInterface
{
Q_OBJECT
public:
KAppWidgetManager(QObject *parent = nullptr);
static KAppWidgetManager* getInstance() {
static KAppWidgetManager s_instance;
return &s_instance;
}
/**
* @brief 获取小插件列表
* @return app widget list
*/
QStringList getAppWidgetList();
/**
* @brief 获取小插件ui文件路径
* @param appwidgetname
* @return path of ui file
*/
QString getAppWidgetUiFile(const QString &appwidgetname);
/**
* @brief 获取小插件的config属性
* @param appwidgetname config
* @return config value of appwidgetname
*/
QString getAppWidgetConfig(const QString &appwidgetname, const AppWidgetConfig& config);
/**
* @brief 获取小插件的所有属性
* @param appwidgetname
* @return config list of widget
*/
QMap getAppWidgetConfigs(const QString &appwidgetname);
/**
* @brief 注册小插件
* @param appwidgetname username
* @return appwidget id
*/
int registerAppWidget(const QString &appwidgetname, const QString &username);
/**
* @brief 注销小插件
* @param appwidgetid
* @return unregister success return true, else false
*/
bool unregisterAppWidget(const int &appwidgetid);
/**
* @brief 获取小插件共享数据
* @param appwidgetid
* @return data from provider
*/
QMap getAppWidgetData(const int &appwidgetid);
/**
* @brief 更新小插件共享数据
* @param providername data
*/
void updateAppWidget(const QString &providername, const QMap &data);
/**
*@brief 更新使用端状态
*@param username userstatus
*
*/
void updateUserStatus(const QString &username, const UserStatus& userstatus);
void notifyProviderUpdate(int id);
QMap getAppWidgetLanguageFiles(const QString &appwidgetname);
signals:
/**
* @brief 小插件资源文件增加信号
* @param appwidget name
*/
void appWidgetAdded(QString appwidgetname);
/**
* @brief 小插件资源文件删除信号
* @param appwidget name
*/
void appWidgetDeleted (QString appwidgetname);
private:
/**
* @brief 转换AppWidgetConfig枚举为字符串
* @param AppWidgetConfig config
* @return config of string
*/
static QString enumToSTring(const AppWidgetConfig& config);
/**
* @brief 转换UserStatus枚举为字符串
* @param UserStatus config
* @return config of string
*/
static QString enumUserStatusToSTring(const UserStatus& userstatus);
};
}// namespace AppWidget
#endif // KAPPWIDGETMANAGER_H
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-manager/libukui-appwidget-manager.pro 0000664 0000000 0000000 00000002160 14561607147 0033222 0 ustar 00root root 0000000 0000000 QT -= gui
QT += dbus
TEMPLATE = lib
DEFINES += LIBUKUIAPPWIDGETMANAGER_LIBRARY
TARGET = ukui-appwidget-manager
VERSION = 0.0.0
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
include(../../libukui-appwidget-common/libukui-appwidget-common.pri)
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
kappwidgetmanager.cpp
HEADERS += \
libukui-appwidget-manager_global.h \
kappwidgetmanager.h
# Default rules for deployment.
unix {
target.path = /usr/lib
apifile.files = *.h
apifile.path = /usr/include/ukui/
}
!isEmpty(target.path): INSTALLS += target apifile
libukui-appwidget-manager_global.h 0000664 0000000 0000000 00000002060 14561607147 0034111 0 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-manager /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef LIBUKUIAPPWIDGETMANAGER_GLOBAL_H
#define LIBUKUIAPPWIDGETMANAGER_GLOBAL_H
#include
#if defined(LIBUKUIAPPWIDGETMANAGER_LIBRARY)
# define LIBUKUIAPPWIDGETMANAGER_EXPORT Q_DECL_EXPORT
#else
# define LIBUKUIAPPWIDGETMANAGER_EXPORT Q_DECL_IMPORT
#endif
#endif // LIBUKUIAPPWIDGETMANAGER_GLOBAL_H
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/ 0000775 0000000 0000000 00000000000 14561607147 0025327 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/kappwidgetconnect.cpp 0000664 0000000 0000000 00000013405 14561607147 0031547 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "kappwidgetconnect.h"
#include
#include
#include
#include
#include
using namespace AppWidget;
KAppWidgetConnect::KAppWidgetConnect(QObject *parent) : QObject(parent)
{
}
KAppWidgetConnect::~KAppWidgetConnect()
{
KAppWidgetManager::getInstance()->unregisterAppWidget(m_id);
if(m_gsettingmap.count() > 0) {
qDeleteAll(m_gsettingmap);
m_gsettingmap.clear();
}
}
void KAppWidgetConnect::onClickedEvent(const QString &widgetname, const QVariant &value)
{
qDebug() << __FILE__ << __FUNCTION__ << widgetname << " send clicked signal";
QDBusVariant variant;
variant.setVariant(value);
Q_EMIT clickedSignal(widgetname, variant);
}
void KAppWidgetConnect::onDefineEvent(const QString &eventname, const QString &widgetname, const QVariant &value)
{
qDebug() << __FILE__ << __FUNCTION__ << widgetname << "Send DefineEvent Signal" << value;
QDBusVariant variant;
variant.setVariant(value);
Q_EMIT defineEventSignal(eventname, widgetname, variant);
}
void KAppWidgetConnect::registerAppWidget(const QString &appname, const QString &username)
{
initConnToManager(appname, username);
registerAppWidgetDbus(username);
KAppWidgetManager::getInstance()->notifyProviderUpdate(m_id);
}
void KAppWidgetConnect::initConnToManager(const QString &appname, const QString &username)
{
qDebug() << __FILE__ << __FUNCTION__ << "Register Appwidget Service: " << username << "," << appname;
m_appname = appname;
m_username = username;
m_id = KAppWidgetManager::getInstance()->registerAppWidget(m_appname, m_username);
updateAppWidget();
}
void KAppWidgetConnect::registerAppWidgetDbus(const QString &username)
{
if (m_id == -1) {
qCritical() << __FILE__ << __FUNCTION__ << "Init AppWidget Id Error: id = " << m_id;
}
QString object = KAppWidgetCommon::getAppWidgetDbusObject(username, m_id);
QString objectpath = KAppWidgetCommon::getAppWidgetDbusPath(username, m_id);
QDBusConnection sessionBus = QDBusConnection::sessionBus();
if (sessionBus.registerService(object)) {
qDebug() << "Regist Dbus Service success";
sessionBus.registerObject(objectpath, this, QDBusConnection :: ExportAllSlots
| QDBusConnection :: ExportAllSignals
| QDBusConnection::ExportAllInvokables);
} else {
qCritical() << "Register DBus Service Error:" << sessionBus.lastError().message();
}
}
QMap KAppWidgetConnect::getData()
{
QMap reply = KAppWidgetManager::getInstance()->getAppWidgetData(m_id);
qDebug() << __FILE__ << __FUNCTION__ << ": " << reply;
return reply;
}
void KAppWidgetConnect::updateAppWidget()
{
Q_EMIT updatesignal();
}
void KAppWidgetConnect::updateUserStatus(const QString &status)
{
Q_EMIT userStatusChanged(status);
}
bool KAppWidgetConnect::creatGsetting(const QString &gsetting)
{
if(gsetting.isEmpty()) {
qWarning() << __FILE__ << __FUNCTION__ << "parameter is null";
return false;
}
if(m_gsettingmap.contains(gsetting)) {
qWarning() << __FILE__ << __FUNCTION__ << gsetting << " gsetting isalready exists";
return false;
}
QByteArray id(gsetting.toLatin1());
if(QGSettings::isSchemaInstalled(id)) {
QGSettings *gsettings = new QGSettings(id);
m_gsettingmap.insert(gsetting, gsettings);
connect(gsettings, &QGSettings::changed, [ = ](const QString & key) {
qDebug() << "gsettings changed" << key;
emit gsettingChanged(key, gsettings->get(key));
});
return true;
} else {
qDebug() << __FILE__ << __FUNCTION__ << gsetting << " gsetting is not install";
return false;
}
return true;
}
bool KAppWidgetConnect::deleteGsetting(const QString &gsetting)
{
if(gsetting.isEmpty()) {
qWarning() << __FILE__ << __FUNCTION__ << "parameter is null";
return false;
}
if(!m_gsettingmap.contains(gsetting)) {
qWarning() << __FILE__ << __FUNCTION__ << gsetting << " gsetting is not exists";
return false;
}
QGSettings *gsettings = m_gsettingmap.value(gsetting);
gsettings->disconnect();
gsettings->deleteLater();
m_gsettingmap.remove(gsetting);
return true;
}
QVariant KAppWidgetConnect::getGsettingValue(const QString &gsetting , const QString &key)
{
if(gsetting.isEmpty()) {
qWarning() << __FILE__ << __FUNCTION__ << "first parameter is null";
return QVariant();
}
if(key.isEmpty()) {
qWarning() << __FILE__ << __FUNCTION__ << "second parameter is null";
return QVariant();
}
QVariant value;
QByteArray id(gsetting.toLatin1());
if(QGSettings::isSchemaInstalled(id)) {
QGSettings *gsettings = new QGSettings(id);
value = gsettings->get(key);
gsettings->deleteLater();
}else {
qWarning() << __FILE__ << __FUNCTION__ << gsetting << " gsetting is uninstall";
}
return value;
}
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/kappwidgetconnect.h 0000664 0000000 0000000 00000004767 14561607147 0031227 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef KAPPWIDGETCOMMUNICATION_H
#define KAPPWIDGETCOMMUNICATION_H
#include
#include
class QGSettings;
namespace AppWidget {
class KAppWidgetManager;
class KAppWidgetConnect : public QObject
{
Q_OBJECT
public:
Q_CLASSINFO("D-Bus Interface", "org.ukui.appwidget")
explicit KAppWidgetConnect(QObject *parent = nullptr);
~KAppWidgetConnect();
Q_INVOKABLE QMap getData();
Q_INVOKABLE bool creatGsetting(const QString &gsetting);
Q_INVOKABLE bool deleteGsetting(const QString &gsetting);
Q_INVOKABLE QVariant getGsettingValue(const QString &gsetting , const QString &key);
Q_INVOKABLE void registerAppWidget(const QString &appname, const QString &username);
signals:
void clickedSignal(const QString &widgetname, const QDBusVariant &value);
void defineEventSignal(const QString &eventname, const QString &widgetname, const QDBusVariant &value);
void updatesignal();
void gsettingChanged(const QString &key, const QVariant &value);
void userStatusChanged(const QString &status);
public slots:
void onClickedEvent(const QString &widgetname, const QVariant &value);
void onDefineEvent(const QString &eventname, const QString &widgetname, const QVariant &value);
void updateAppWidget();
void updateUserStatus(const QString &status);
private:
void initConnToManager(const QString &appname, const QString &username);
void registerAppWidgetDbus(const QString &username);
QString m_appname;
QString m_username;
int m_id = -1;
/**
* @brief gsettings容器,QMap键值对说明<生成的QGSettings的schema_id, 生成的QGSettings *对象>
*/
QMap m_gsettingmap;
};
} // namespace AppWidget
#endif // KAPPWIDGETCOMMUNICATION_H
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/kappwidgetplugin.cpp 0000664 0000000 0000000 00000002244 14561607147 0031413 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "kappwidgetplugin.h"
#include
#include "kappwidgetconnect.h"
#include "translatorhelper.h"
void KAppWidgetPlugin::registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.ukui.appwidget.private"));
// @uri org.ukui.appwidget.private
qmlRegisterType(uri, 1, 0, "Connection");
qmlRegisterType(uri, 1, 0, "Translator");
}
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/kappwidgetplugin.h 0000664 0000000 0000000 00000002055 14561607147 0031060 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef LIBUKUIAPPWIDGET_PLUGIN_H
#define LIBUKUIAPPWIDGET_PLUGIN_H
#include
class KAppWidgetPlugin : public QQmlExtensionPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid)
public:
void registerTypes(const char *uri) override;
};
#endif // LIBUKUIAPPWIDGET_PLUGIN_H
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/libukui-appwidget-plugin.pro 0000664 0000000 0000000 00000002321 14561607147 0032771 0 ustar 00root root 0000000 0000000 TEMPLATE = lib
TARGET = ukui-appwidget-plugin
VERSION = 0.0.0
QT += qml quick dbus
CONFIG += plugin c++11 link_pkgconfig
PKGCONFIG += gsettings-qt
LIBS +=-L../libukui-appwidget-manager/ -lukui-appwidget-manager
INCLUDEPATH += ../libukui-appwidget-manager/
DEPENDPATH += ../libukui-appwidget-manager/
TARGET = $$qtLibraryTarget($$TARGET)
uri = org.ukui.appwidget.private
include(../../libukui-appwidget-common/libukui-appwidget-common.pri)
# Input
SOURCES += \
kappwidgetconnect.cpp \
kappwidgetplugin.cpp \
translatorhelper.cpp
HEADERS += \
kappwidgetconnect.h \
kappwidgetplugin.h \
translatorhelper.h
DISTFILES = qmldir
!equals(_PRO_FILE_PWD_, $$OUT_PWD) {
copy_qmldir.target = $$OUT_PWD/qmldir
copy_qmldir.depends = $$_PRO_FILE_PWD_/qmldir
copy_qmldir.commands = $(COPY_FILE) "$$replace(copy_qmldir.depends, /, $$QMAKE_DIR_SEP)" "$$replace(copy_qmldir.target, /, $$QMAKE_DIR_SEP)"
QMAKE_EXTRA_TARGETS += copy_qmldir
PRE_TARGETDEPS += $$copy_qmldir.target
}
qmldir.files = qmldir
unix {
installPath = $$[QT_INSTALL_LIBS]/qt5/qml/org/ukui/appwidget/private
qmldir.path = $$installPath
target.path = $$installPath
INSTALLS += target qmldir
}
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/qmldir 0000664 0000000 0000000 00000000077 14561607147 0026546 0 ustar 00root root 0000000 0000000 module org.ukui.appwidget.private
plugin ukui-appwidget-plugin
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/translatorhelper.cpp 0000664 0000000 0000000 00000002547 14561607147 0031434 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "translatorhelper.h"
#include
#include
#include
#include
using namespace AppWidget;
TranslatorHelper::TranslatorHelper(QObject *parent)
: QObject(parent)
{
}
void TranslatorHelper::installTranslators(const QString &appname)
{
QTranslator* translator = new QTranslator(this);
QString key = QLocale::system().name();
QMap languageFiles = KAppWidgetManager::getInstance()->getAppWidgetLanguageFiles(appname);
QString qmFile = languageFiles.value(key);
translator->load(qmFile);
qApp->installTranslator(translator);
}
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-plugin/translatorhelper.h 0000664 0000000 0000000 00000002175 14561607147 0031076 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef TRANSLATORHELPER_H
#define TRANSLATORHELPER_H
#include
namespace AppWidget {
class KAppWidgetManager;
class TranslatorHelper : public QObject
{
Q_OBJECT
public:
explicit TranslatorHelper(QObject *parent = nullptr);
~TranslatorHelper() = default;
Q_INVOKABLE void installTranslators(const QString &appname);
};
} //namespace AppWidget
#endif // TRANSLATORHELPER_H
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-provider/ 0000775 0000000 0000000 00000000000 14561607147 0025663 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-provider/kappwidgetprovider.cpp 0000664 0000000 0000000 00000005076 14561607147 0032311 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "kappwidgetprovider.h"
#include
#include
#include
#include
namespace AppWidget
{
KAppWidgetProvider::KAppWidgetProvider(QString providername, QObject *parent): QObject(parent)
{
if(providername.isEmpty()) {
qWarning() << "providername isEmpty!";
return;
}
QString servicename = KAppWidgetCommon::getProviderDbusObject(providername);
QString objectpath = KAppWidgetCommon::getProviderDbusPath(providername);
QString objectinterface = KAppWidgetCommon::getProviderDbusInterface(providername);
QDBusConnection connection = QDBusConnection::sessionBus();
if (connection.registerService(servicename)) {
connection.registerObject(objectpath, objectinterface, this, QDBusConnection::ExportAllSlots);
qDebug() << "Regist Dbus Service success";
}else {
qCritical() << "Register DBus Service Error:" << connection.lastError().message();
}
}
void KAppWidgetProvider::appWidgetRecevie(const QString &eventname, const QString &widgetname, const QDBusVariant &value)
{
Q_UNUSED(eventname);
Q_UNUSED(widgetname);
Q_UNUSED(value);
qDebug() << "KAppWidgetProvider::appWidgetRecevie";
}
void KAppWidgetProvider::appWidgetUpdate()
{
qDebug() << "KAppWidgetProvider::appWidgetUpdate";
}
void KAppWidgetProvider::appWidgetDisable()
{
qDebug() << "KAppWidgetProvider::appWidgetDisable";
}
void KAppWidgetProvider::appWidgetDeleted()
{
qDebug() << "KAppWidgetProvider::appWidgetDeleted";
}
void KAppWidgetProvider::appWidgetEnable()
{
qDebug() << "KAppWidgetProvider::appWidgetEnable";
}
void KAppWidgetProvider::appWidgetClicked(const QString &widgetname, const QDBusVariant &value)
{
Q_UNUSED(widgetname);
Q_UNUSED(value);
qDebug() << "KAppWidgetProvider::appWidgetClicked";
}
}// namespace AppWidget
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-provider/kappwidgetprovider.h 0000664 0000000 0000000 00000003527 14561607147 0031755 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef KAPPWIDGETPROVIDER_H
#define KAPPWIDGETPROVIDER_H
#include "libukui-appwidget-provider_global.h"
#include
class QDBusVariant;
namespace AppWidget
{
/** @defgroup 小插件提供端模块
* @{
*/
class LIBUKUIAPPWIDGETPROVIDER_EXPORT KAppWidgetProvider : public QObject
{
Q_OBJECT
public:
KAppWidgetProvider(QString providername, QObject *parent = nullptr) ;
public slots:
/**
* @brief 小插件自定义事件
*/
virtual void appWidgetRecevie(const QString &eventname, const QString &widgetname, const QDBusVariant &value);
/**
* @brief 小插件更新函数
*/
virtual void appWidgetUpdate();
/**
* @brief 小插件禁用函数
*/
virtual void appWidgetDisable();
/**
* @brief 小插件删除函数
*/
virtual void appWidgetDeleted();
/**
* @brief 小插件启用函数
*/
virtual void appWidgetEnable();
/**
* @brief 小插件点击函数
*/
virtual void appWidgetClicked(const QString &widgetname, const QDBusVariant &value);
};
}// namespace AppWidget
#endif // KAPPWIDGETPROVIDER_H
ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-provider/libukui-appwidget-provider.pro0000664 0000000 0000000 00000002170 14561607147 0033663 0 ustar 00root root 0000000 0000000 QT -= gui
QT += dbus
TEMPLATE = lib
DEFINES += LIBUKUIAPPWIDGETPROVIDER_LIBRARY
TARGET = ukui-appwidget-provider
VERSION = 0.0.0
CONFIG += c++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
include(../../libukui-appwidget-common/libukui-appwidget-common.pri)
SOURCES += \
kappwidgetprovider.cpp
HEADERS += \
libukui-appwidget-provider_global.h \
kappwidgetprovider.h
# Default rules for deployment.
unix {
target.path = /usr/lib
apifile.files = *.h
apifile.path = /usr/include/ukui/
}
!isEmpty(target.path): INSTALLS += target apifile
libukui-appwidget-provider_global.h 0000664 0000000 0000000 00000002066 14561607147 0034557 0 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/libukui-app-widget/libukui-appwidget-provider /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef LIBUKUIAPPWIDGETPROVIDER_GLOBAL_H
#define LIBUKUIAPPWIDGETPROVIDER_GLOBAL_H
#include
#if defined(LIBUKUIAPPWIDGETPROVIDER_LIBRARY)
# define LIBUKUIAPPWIDGETPROVIDER_EXPORT Q_DECL_EXPORT
#else
# define LIBUKUIAPPWIDGETPROVIDER_EXPORT Q_DECL_IMPORT
#endif
#endif // LIBUKUIAPPWIDGETPROVIDER_GLOBAL_H
ukui-app-widget-4.0.0.2/libukui-app-widget/org.ukui.appwidget/ 0000775 0000000 0000000 00000000000 14561607147 0024133 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/libukui-app-widget/org.ukui.appwidget/AppWidget.qml 0000664 0000000 0000000 00000006553 14561607147 0026543 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
import QtQuick 2.0
import org.ukui.appwidget.private 1.0 as UKUIAppWidget
Item {
id:controlroot
UKUIAppWidget.Connection {
id:appwidget
}
UKUIAppWidget.Translator {
id:translator
}
signal qmldefineeventchangedsignal(string eventname, string widgetname, var value);
signal qmlclickedsignal(string widgetname, var value);
signal update();
signal gsettingUpdate(string key, var value);
/* @deprecated 此信号接口会在应用同步后弃用 */
signal userStatusChangedSignal(string status);
property string appname
property string username
property var datavalue
property string userstatus: "Normal"
onAppnameChanged: {
translator.installTranslators(appname)
}
onUserstatusChanged: {
userStatusChangedSignal(userstatus)
}
Component.onCompleted: {
appwidget.updatesignal.connect(controlroot.qmlUpdate)
qmlclickedsignal.connect(appwidget.onClickedEvent)
qmldefineeventchangedsignal.connect(appwidget.onDefineEvent)
appwidget.gsettingChanged.connect(controlroot.gsettingChanged)
appwidget.userStatusChanged.connect(controlroot.setUserStatus)
}
function qmlUpdate() {
datavalue = appwidget.getData();
update();
}
function register(appname, username)
{
appwidget.registerAppWidget(appname, username);
console.log(" QML AppWidget register dbus");
}
function creatGsetting(gsettingname)
{
console.log(" QML AppWidget creatGsetting", gsettingname);
if(appwidget.creatGsetting(gsettingname)) {
console.log(" QML AppWidget register gsetting successful");
}else {
console.log(" QML AppWidget register gsetting fail");
}
}
function deleteGsetting(gsettingname)
{
console.log(" QML AppWidget deleteGsetting", gsettingname);
if(appwidget.deleteGsetting(gsettingname)) {
console.log(" QML AppWidget delete gsetting successful");
}else {
console.log(" QML AppWidget delete gsetting fail");
}
}
function getGsettingValue(gsettingname, key)
{
console.log(" QML AppWidget getGsettingValue", gsettingname, key, appwidget.getGsettingValue(gsettingname, key));
return appwidget.getGsettingValue(gsettingname, key);
}
function gsettingChanged(key, value) {
console.log(" QML AppWidget gsettingChanged", key,value)
gsettingUpdate(key, value);
}
function setUserStatus(status) {
console.log(" QML AppWidget setUserStatus", status, " appname: ", appwidget.appname)
userstatus = status
}
}
ukui-app-widget-4.0.0.2/libukui-app-widget/org.ukui.appwidget/qmldir 0000664 0000000 0000000 00000000066 14561607147 0025350 0 ustar 00root root 0000000 0000000 module org.ukui.appwidget
AppWidget 1.0 AppWidget.qml
ukui-app-widget-4.0.0.2/libukui-appwidget-common/ 0000775 0000000 0000000 00000000000 14561607147 0021616 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/libukui-appwidget-common/kappwidgetcommon.cpp 0000664 0000000 0000000 00000005342 14561607147 0025676 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "kappwidgetcommon.h"
#include
namespace AppWidget
{
KAppWidgetCommon::KAppWidgetCommon(QObject *parent) : QObject(parent)
{
}
QString KAppWidgetCommon::getProviderDbusObject(const QString &providername)
{
if(providername.isEmpty()) {
qWarning() << "providername isEmpty!";
return QString();
}
QString object = QString("org.ukui.appwidget.provider.%1").arg(providername);
return object;
}
QString KAppWidgetCommon::getProviderDbusPath(const QString &providername)
{
if(providername.isEmpty()) {
qWarning() << "providername isEmpty!";
return QString();
}
QString objectpath = QString("/org/ukui/appwidget/provider");
return objectpath;
}
QString KAppWidgetCommon::getProviderDbusInterface(const QString &providername)
{
if(providername.isEmpty()) {
qWarning() << "providername isEmpty!";
return QString();
}
QString interface = QString("org.ukui.appwidget.provider.%1").arg(providername);
return interface;
}
QString KAppWidgetCommon::getManagerDbusObject()
{
QString object = QString("org.ukui.appwidget.manager");
return object;
}
QString KAppWidgetCommon::getManagerDbusPath()
{
QString objectpath = QString("/");
return objectpath;
}
QString KAppWidgetCommon::getManagerDbusInterface()
{
QString interface = QString("org.ukui.appwidget.manager");
return interface;
}
QString KAppWidgetCommon::getAppWidgetDbusObject(const QString &username, const int &id)
{
Q_UNUSED(id);
QString object = QString("org.ukui.appwidget.%1").arg(username);
return object;
}
QString KAppWidgetCommon::getAppWidgetDbusPath(const QString &username, const int &id)
{
Q_UNUSED(username);
QString objectpath = QString("/%1").arg(id);
return objectpath;
}
QString KAppWidgetCommon::getAppWidgetDbusInterface(const QString &username, const int &id)
{
Q_UNUSED(username);
Q_UNUSED(id);
QString interface = QString("org.ukui.appwidget");
return interface;
}
}// namespace AppWidget
ukui-app-widget-4.0.0.2/libukui-appwidget-common/kappwidgetcommon.h 0000664 0000000 0000000 00000005573 14561607147 0025351 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef KAPPWIDGETCOMMON_H
#define KAPPWIDGETCOMMON_H
#include "libukui-appwidget-common_global.h"
#include
namespace AppWidget
{
/**
* @defgroup 公共接口模块
*/
class LIBUKUIAPPWIDGETCOMMON_EXPORT KAppWidgetCommon : public QObject
{
Q_OBJECT
public:
explicit KAppWidgetCommon(QObject *parent = nullptr);
/**
* @brief 获取Providername的提供端Dbus Object name
* @param providername
* @return Provider dbus object name
*/
static QString getProviderDbusObject(const QString &providername);
/**
* @brief 获取Providername的提供端Dbus Path
* @param providername
* @return Provider dbus path name
*/
static QString getProviderDbusPath(const QString &providername);
/**
* @brief 获取Providername的提供端Dbus Interface
* @param providername
* @return Provider dbus interface name
*/
static QString getProviderDbusInterface(const QString &providername);
/**
* @brief 获取Manager的提供端Dbus Object name
* @return Manager dbus object name
*/
static QString getManagerDbusObject();
/**
* @brief 获取Manager的提供端Dbus Path
* @return Manager dbus path name
*/
static QString getManagerDbusPath();
/**
* @brief 获取Manager的提供端Dbus Interface
* @return Manager dbus interface name
*/
static QString getManagerDbusInterface();
/**
* @brief 获取AppWidget的提供端Dbus Object name
* @param username appwidget`id
* @return Widget dbus object name
*/
static QString getAppWidgetDbusObject(const QString &username, const int &id);
/**
* @brief 获取AppWidget的提供端Dbus Object name
* @param username appwidget`id
* @return Widget dbus path name
*/
static QString getAppWidgetDbusPath(const QString &username, const int &id);
/**
* @brief 获取AppWidget的提供端Dbus Object name
* @param username appwidget`id
* @return Widget dbus interface name
*/
static QString getAppWidgetDbusInterface(const QString &username, const int &id);
};
}// namespace AppWidget
#endif // KAPPWIDGETCOMMON_H
ukui-app-widget-4.0.0.2/libukui-appwidget-common/libukui-appwidget-common.pri 0000664 0000000 0000000 00000000246 14561607147 0027250 0 ustar 00root root 0000000 0000000 INCLUDEPATH += $$PWD
SOURCES += \
$$PWD/kappwidgetcommon.cpp
HEADERS += \
$$PWD/libukui-appwidget-common_global.h \
$$PWD/kappwidgetcommon.h
ukui-app-widget-4.0.0.2/libukui-appwidget-common/libukui-appwidget-common_global.h 0000664 0000000 0000000 00000002052 14561607147 0030222 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef LIBUKUIAPPWIDGETCOMMON_GLOBAL_H
#define LIBUKUIAPPWIDGETCOMMON_GLOBAL_H
#include
#if defined(LIBUKUIAPPWIDGETCOMMON_LIBRARY)
# define LIBUKUIAPPWIDGETCOMMON_EXPORT Q_DECL_EXPORT
#else
# define LIBUKUIAPPWIDGETCOMMON_EXPORT Q_DECL_IMPORT
#endif
#endif // LIBUKUIAPPWIDGETCOMMON_GLOBAL_H
ukui-app-widget-4.0.0.2/man/ 0000775 0000000 0000000 00000000000 14561607147 0015455 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/man/appwidgetprovider-clock-demo.1 0000664 0000000 0000000 00000003733 14561607147 0023317 0 ustar 00root root 0000000 0000000 .\" ukui-app-widget manual page
.\"
.\" This is free software; you may 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,
.\" or (at your option) any later version.
.\"
.\" This is distributed in the hope that 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.
.\"
.TH UKUI-APP-WIDGET 1 "05 Apr 2023" "UKUI Desktop Environment"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH "NAME"
ukui-app-widget \- The UKUI Desktop for qml
.SH "SYNOPSIS"
.B ukui-app-widget [OPTIONS]
.SH "DESCRIPTION"
ukui-app-widget is a qml appwidget framework. It can display a view for quick browsing, which is mainly to display the most important data and functions of the application.
.SH "OPTIONS"
.TP
\fB\-\-display=DISPLAY\fR
X display to use.
.TP
\fB\-\-no\-daemon\fR
Don't start as a daemon
.TP
\fB\-\-debug\fR
Enable debugging messages for \fBukui-screensaver\fP
.TP
\fB\-\-version\fR
Output version information and exit.
.TP
\fB\-h, \-\-help\fR
Print standard command line options.
.TP
\fB\-\-help\-all\fR
Print all command line options.
.P
This program also accepts the standard GTK options.
.SH "BUGS"
.SS Should you encounter any bugs, they may be reported at:
https://gitee.com/openkylin/ukui-app-widget/issues
.SH "AUTHORS"
.SS ukui-app-widget is maintained by:
.nf
Yan Wang
.fi
.SS This Man Page has been updated for the UKUI Desktop Environment by:
Yan Wang (2023)
.SH "SEE ALSO"
.SS Further information may also be available at: http://wiki.ukui-desktop.org/docs
.P
.BR gtk-options (7)
ukui-app-widget-4.0.0.2/man/appwidgetprovider-clock-service.1 0000664 0000000 0000000 00000003733 14561607147 0024033 0 ustar 00root root 0000000 0000000 .\" ukui-app-widget manual page
.\"
.\" This is free software; you may 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,
.\" or (at your option) any later version.
.\"
.\" This is distributed in the hope that 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.
.\"
.TH UKUI-APP-WIDGET 1 "05 Apr 2023" "UKUI Desktop Environment"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH "NAME"
ukui-app-widget \- The UKUI Desktop for qml
.SH "SYNOPSIS"
.B ukui-app-widget [OPTIONS]
.SH "DESCRIPTION"
ukui-app-widget is a qml appwidget framework. It can display a view for quick browsing, which is mainly to display the most important data and functions of the application.
.SH "OPTIONS"
.TP
\fB\-\-display=DISPLAY\fR
X display to use.
.TP
\fB\-\-no\-daemon\fR
Don't start as a daemon
.TP
\fB\-\-debug\fR
Enable debugging messages for \fBukui-screensaver\fP
.TP
\fB\-\-version\fR
Output version information and exit.
.TP
\fB\-h, \-\-help\fR
Print standard command line options.
.TP
\fB\-\-help\-all\fR
Print all command line options.
.P
This program also accepts the standard GTK options.
.SH "BUGS"
.SS Should you encounter any bugs, they may be reported at:
https://gitee.com/openkylin/ukui-app-widget/issues
.SH "AUTHORS"
.SS ukui-app-widget is maintained by:
.nf
Yan Wang
.fi
.SS This Man Page has been updated for the UKUI Desktop Environment by:
Yan Wang (2023)
.SH "SEE ALSO"
.SS Further information may also be available at: http://wiki.ukui-desktop.org/docs
.P
.BR gtk-options (7)
ukui-app-widget-4.0.0.2/man/appwidgetprovider-search-demo.1 0000664 0000000 0000000 00000003733 14561607147 0023471 0 ustar 00root root 0000000 0000000 .\" ukui-app-widget manual page
.\"
.\" This is free software; you may 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,
.\" or (at your option) any later version.
.\"
.\" This is distributed in the hope that 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.
.\"
.TH UKUI-APP-WIDGET 1 "05 Apr 2023" "UKUI Desktop Environment"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH "NAME"
ukui-app-widget \- The UKUI Desktop for qml
.SH "SYNOPSIS"
.B ukui-app-widget [OPTIONS]
.SH "DESCRIPTION"
ukui-app-widget is a qml appwidget framework. It can display a view for quick browsing, which is mainly to display the most important data and functions of the application.
.SH "OPTIONS"
.TP
\fB\-\-display=DISPLAY\fR
X display to use.
.TP
\fB\-\-no\-daemon\fR
Don't start as a daemon
.TP
\fB\-\-debug\fR
Enable debugging messages for \fBukui-screensaver\fP
.TP
\fB\-\-version\fR
Output version information and exit.
.TP
\fB\-h, \-\-help\fR
Print standard command line options.
.TP
\fB\-\-help\-all\fR
Print all command line options.
.P
This program also accepts the standard GTK options.
.SH "BUGS"
.SS Should you encounter any bugs, they may be reported at:
https://gitee.com/openkylin/ukui-app-widget/issues
.SH "AUTHORS"
.SS ukui-app-widget is maintained by:
.nf
Yan Wang
.fi
.SS This Man Page has been updated for the UKUI Desktop Environment by:
Yan Wang (2023)
.SH "SEE ALSO"
.SS Further information may also be available at: http://wiki.ukui-desktop.org/docs
.P
.BR gtk-options (7)
ukui-app-widget-4.0.0.2/man/appwidgetuser-demo.1 0000664 0000000 0000000 00000003733 14561607147 0021352 0 ustar 00root root 0000000 0000000 .\" ukui-app-widget manual page
.\"
.\" This is free software; you may 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,
.\" or (at your option) any later version.
.\"
.\" This is distributed in the hope that 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.
.\"
.TH UKUI-APP-WIDGET 1 "05 Apr 2023" "UKUI Desktop Environment"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH "NAME"
ukui-app-widget \- The UKUI Desktop for qml
.SH "SYNOPSIS"
.B ukui-app-widget [OPTIONS]
.SH "DESCRIPTION"
ukui-app-widget is a qml appwidget framework. It can display a view for quick browsing, which is mainly to display the most important data and functions of the application.
.SH "OPTIONS"
.TP
\fB\-\-display=DISPLAY\fR
X display to use.
.TP
\fB\-\-no\-daemon\fR
Don't start as a daemon
.TP
\fB\-\-debug\fR
Enable debugging messages for \fBukui-screensaver\fP
.TP
\fB\-\-version\fR
Output version information and exit.
.TP
\fB\-h, \-\-help\fR
Print standard command line options.
.TP
\fB\-\-help\-all\fR
Print all command line options.
.P
This program also accepts the standard GTK options.
.SH "BUGS"
.SS Should you encounter any bugs, they may be reported at:
https://gitee.com/openkylin/ukui-app-widget/issues
.SH "AUTHORS"
.SS ukui-app-widget is maintained by:
.nf
Yan Wang
.fi
.SS This Man Page has been updated for the UKUI Desktop Environment by:
Yan Wang (2023)
.SH "SEE ALSO"
.SS Further information may also be available at: http://wiki.ukui-desktop.org/docs
.P
.BR gtk-options (7)
ukui-app-widget-4.0.0.2/man/ukui-appwidget-manager.1 0000664 0000000 0000000 00000003733 14561607147 0022114 0 ustar 00root root 0000000 0000000 .\" ukui-app-widget manual page
.\"
.\" This is free software; you may 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,
.\" or (at your option) any later version.
.\"
.\" This is distributed in the hope that 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.
.\"
.TH UKUI-APP-WIDGET 1 "05 Apr 2023" "UKUI Desktop Environment"
.\" Please adjust this date whenever revising the manpage.
.\"
.SH "NAME"
ukui-app-widget \- The UKUI Desktop for qml
.SH "SYNOPSIS"
.B ukui-app-widget [OPTIONS]
.SH "DESCRIPTION"
ukui-app-widget is a qml appwidget framework. It can display a view for quick browsing, which is mainly to display the most important data and functions of the application.
.SH "OPTIONS"
.TP
\fB\-\-display=DISPLAY\fR
X display to use.
.TP
\fB\-\-no\-daemon\fR
Don't start as a daemon
.TP
\fB\-\-debug\fR
Enable debugging messages for \fBukui-screensaver\fP
.TP
\fB\-\-version\fR
Output version information and exit.
.TP
\fB\-h, \-\-help\fR
Print standard command line options.
.TP
\fB\-\-help\-all\fR
Print all command line options.
.P
This program also accepts the standard GTK options.
.SH "BUGS"
.SS Should you encounter any bugs, they may be reported at:
https://gitee.com/openkylin/ukui-app-widget/issues
.SH "AUTHORS"
.SS ukui-app-widget is maintained by:
.nf
Yan Wang
.fi
.SS This Man Page has been updated for the UKUI Desktop Environment by:
Yan Wang (2023)
.SH "SEE ALSO"
.SS Further information may also be available at: http://wiki.ukui-desktop.org/docs
.P
.BR gtk-options (7)
ukui-app-widget-4.0.0.2/ukui-app-widget.pro 0000664 0000000 0000000 00000000327 14561607147 0020442 0 ustar 00root root 0000000 0000000 TEMPLATE = subdirs
SUBDIRS += \
libukui-app-widget \
ukui-appwidget-test \
ukui-appwidget-manager
ukui-appwidget-test.depends += libukui-app-widget
ukui-appwidget-manager.depends += libukui-app-widget
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/ 0000775 0000000 0000000 00000000000 14561607147 0021251 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/ 0000775 0000000 0000000 00000000000 14561607147 0025163 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/QtLockedFile 0000664 0000000 0000000 00000000032 14561607147 0027407 0 ustar 00root root 0000000 0000000 #include "qtlockedfile.h"
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/QtSingleApplication 0000664 0000000 0000000 00000000041 14561607147 0031013 0 ustar 00root root 0000000 0000000 #include "qtsingleapplication.h"
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtlocalpeer.cpp 0000664 0000000 0000000 00000015436 14561607147 0030213 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtlocalpeer.h"
#include
#include
#include
#if defined(Q_OS_WIN)
#include
#include
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
static PProcessIdToSessionId pProcessIdToSessionId = 0;
#endif
#if defined(Q_OS_UNIX)
#include
#include
#include
#endif
namespace QtLP_Private {
#include "qtlockedfile.cpp"
#if defined(Q_OS_WIN)
#include "qtlockedfile_win.cpp"
#else
#include "qtlockedfile_unix.cpp"
#endif
}
const char* QtLocalPeer::ack = "ack";
QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
: QObject(parent), id(appId)
{
QString prefix = id;
if (id.isEmpty()) {
id = QCoreApplication::applicationFilePath();
#if defined(Q_OS_WIN)
id = id.toLower();
#endif
prefix = id.section(QLatin1Char('/'), -1);
}
prefix.remove(QRegExp("[^a-zA-Z]"));
prefix.truncate(6);
QByteArray idc = id.toUtf8();
quint16 idNum = qChecksum(idc.constData(), idc.size());
socketName = QLatin1String("qtsingleapp-") + prefix
+ QLatin1Char('-') + QString::number(idNum, 16);
#if defined(Q_OS_WIN)
if (!pProcessIdToSessionId) {
QLibrary lib("kernel32");
pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId");
}
if (pProcessIdToSessionId) {
DWORD sessionId = 0;
pProcessIdToSessionId(GetCurrentProcessId(), &sessionId);
socketName += QLatin1Char('-') + QString::number(sessionId, 16);
}
#else
socketName += QLatin1Char('-') + QString::number(::getuid(), 16);
#endif
server = new QLocalServer(this);
QString lockName = QDir(QDir::tempPath()).absolutePath()
+ QLatin1Char('/') + socketName
+ QLatin1String("-lockfile");
lockFile.setFileName(lockName);
lockFile.open(QIODevice::ReadWrite);
}
bool QtLocalPeer::isClient()
{
if (lockFile.isLocked())
return false;
if (!lockFile.lock(QtLP_Private::QtLockedFile::WriteLock, false))
return true;
bool res = server->listen(socketName);
#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
// ### Workaround
if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
res = server->listen(socketName);
}
#endif
if (!res)
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
return false;
}
bool QtLocalPeer::sendMessage(const QString &message, int timeout)
{
if (!isClient())
return false;
QLocalSocket socket;
bool connOk = false;
for(int i = 0; i < 2; i++) {
// Try twice, in case the other instance is just starting up
socket.connectToServer(socketName);
connOk = socket.waitForConnected(timeout/2);
if (connOk || i)
break;
int ms = 250;
#if defined(Q_OS_WIN)
Sleep(DWORD(ms));
#else
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
nanosleep(&ts, NULL);
#endif
}
if (!connOk)
return false;
QByteArray uMsg(message.toUtf8());
QDataStream ds(&socket);
ds.writeBytes(uMsg.constData(), uMsg.size());
bool res = socket.waitForBytesWritten(timeout);
if (res) {
res &= socket.waitForReadyRead(timeout); // wait for ack
if (res)
res &= (socket.read(qstrlen(ack)) == ack);
}
return res;
}
void QtLocalPeer::receiveConnection()
{
QLocalSocket* socket = server->nextPendingConnection();
if (!socket)
return;
while (true) {
if (socket->state() == QLocalSocket::UnconnectedState) {
qWarning("QtLocalPeer: Peer disconnected");
delete socket;
return;
}
if (socket->bytesAvailable() >= qint64(sizeof(quint32)))
break;
socket->waitForReadyRead();
}
QDataStream ds(socket);
QByteArray uMsg;
quint32 remaining;
ds >> remaining;
uMsg.resize(remaining);
int got = 0;
char* uMsgBuf = uMsg.data();
do {
got = ds.readRawData(uMsgBuf, remaining);
remaining -= got;
uMsgBuf += got;
} while (remaining && got >= 0 && socket->waitForReadyRead(2000));
if (got < 0) {
qWarning("QtLocalPeer: Message reception failed %s", socket->errorString().toLatin1().constData());
delete socket;
return;
}
QString message(QString::fromUtf8(uMsg));
socket->write(ack, qstrlen(ack));
socket->waitForBytesWritten(1000);
socket->waitForDisconnected(1000); // make sure client reads ack
delete socket;
Q_EMIT messageReceived(message); //### (might take a long time to return)
}
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtlocalpeer.h 0000664 0000000 0000000 00000005205 14561607147 0027651 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTLOCALPEER_H
#define QTLOCALPEER_H
#include
#include
#include
#include "qtlockedfile.h"
class QtLocalPeer : public QObject
{
Q_OBJECT
public:
QtLocalPeer(QObject *parent = 0, const QString &appId = QString());
bool isClient();
bool sendMessage(const QString &message, int timeout);
QString applicationId() const
{ return id; }
Q_SIGNALS:
void messageReceived(const QString &message);
protected Q_SLOTS:
void receiveConnection();
protected:
QString id;
QString socketName;
QLocalServer* server;
QtLP_Private::QtLockedFile lockFile;
private:
static const char* ack;
};
#endif // QTLOCALPEER_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtlockedfile.cpp 0000664 0000000 0000000 00000013742 14561607147 0030344 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtlockedfile.h"
/*!
\class QtLockedFile
\brief The QtLockedFile class extends QFile with advisory locking
functions.
A file may be locked in read or write mode. Multiple instances of
\e QtLockedFile, created in multiple processes running on the same
machine, may have a file locked in read mode. Exactly one instance
may have it locked in write mode. A read and a write lock cannot
exist simultaneously on the same file.
The file locks are advisory. This means that nothing prevents
another process from manipulating a locked file using QFile or
file system functions offered by the OS. Serialization is only
guaranteed if all processes that access the file use
QLockedFile. Also, while holding a lock on a file, a process
must not open the same file again (through any API), or locks
can be unexpectedly lost.
The lock provided by an instance of \e QtLockedFile is released
whenever the program terminates. This is true even when the
program crashes and no destructors are called.
*/
/*! \enum QtLockedFile::LockMode
This enum describes the available lock modes.
\value ReadLock A read lock.
\value WriteLock A write lock.
\value NoLock Neither a read lock nor a write lock.
*/
/*!
Constructs an unlocked \e QtLockedFile object. This constructor
behaves in the same way as \e QFile::QFile().
\sa QFile::QFile()
*/
QtLockedFile::QtLockedFile()
: QFile()
{
#ifdef Q_OS_WIN
wmutex = 0;
rmutex = 0;
#endif
m_lock_mode = NoLock;
}
/*!
Constructs an unlocked QtLockedFile object with file \a name. This
constructor behaves in the same way as \e QFile::QFile(const
QString&).
\sa QFile::QFile()
*/
QtLockedFile::QtLockedFile(const QString &name)
: QFile(name)
{
#ifdef Q_OS_WIN
wmutex = 0;
rmutex = 0;
#endif
m_lock_mode = NoLock;
}
/*!
Opens the file in OpenMode \a mode.
This is identical to QFile::open(), with the one exception that the
Truncate mode flag is disallowed. Truncation would conflict with the
advisory file locking, since the file would be modified before the
write lock is obtained. If truncation is required, use resize(0)
after obtaining the write lock.
Returns true if successful; otherwise false.
\sa QFile::open(), QFile::resize()
*/
bool QtLockedFile::open(OpenMode mode)
{
if (mode & QIODevice::Truncate) {
qWarning("QtLockedFile::open(): Truncate mode not allowed.");
return false;
}
return QFile::open(mode);
}
/*!
Returns \e true if this object has a in read or write lock;
otherwise returns \e false.
\sa lockMode()
*/
bool QtLockedFile::isLocked() const
{
return m_lock_mode != NoLock;
}
/*!
Returns the type of lock currently held by this object, or \e
QtLockedFile::NoLock.
\sa isLocked()
*/
QtLockedFile::LockMode QtLockedFile::lockMode() const
{
return m_lock_mode;
}
/*!
\fn bool QtLockedFile::lock(LockMode mode, bool block = true)
Obtains a lock of type \a mode. The file must be opened before it
can be locked.
If \a block is true, this function will block until the lock is
aquired. If \a block is false, this function returns \e false
immediately if the lock cannot be aquired.
If this object already has a lock of type \a mode, this function
returns \e true immediately. If this object has a lock of a
different type than \a mode, the lock is first released and then a
new lock is obtained.
This function returns \e true if, after it executes, the file is
locked by this object, and \e false otherwise.
\sa unlock(), isLocked(), lockMode()
*/
/*!
\fn bool QtLockedFile::unlock()
Releases a lock.
If the object has no lock, this function returns immediately.
This function returns \e true if, after it executes, the file is
not locked by this object, and \e false otherwise.
\sa lock(), isLocked(), lockMode()
*/
/*!
\fn QtLockedFile::~QtLockedFile()
Destroys the \e QtLockedFile object. If any locks were held, they
are released.
*/
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtlockedfile.h 0000664 0000000 0000000 00000006307 14561607147 0030010 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTLOCKEDFILE_H
#define QTLOCKEDFILE_H
#include
#ifdef Q_OS_WIN
#include
#endif
#if defined(Q_OS_WIN)
# if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT)
# define QT_QTLOCKEDFILE_EXPORT
# elif defined(QT_QTLOCKEDFILE_IMPORT)
# if defined(QT_QTLOCKEDFILE_EXPORT)
# undef QT_QTLOCKEDFILE_EXPORT
# endif
# define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport)
# elif defined(QT_QTLOCKEDFILE_EXPORT)
# undef QT_QTLOCKEDFILE_EXPORT
# define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport)
# endif
#else
# define QT_QTLOCKEDFILE_EXPORT
#endif
namespace QtLP_Private {
class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile
{
public:
enum LockMode { NoLock = 0, ReadLock, WriteLock };
QtLockedFile();
QtLockedFile(const QString &name);
~QtLockedFile();
bool open(OpenMode mode);
bool lock(LockMode mode, bool block = true);
bool unlock();
bool isLocked() const;
LockMode lockMode() const;
private:
#ifdef Q_OS_WIN
Qt::HANDLE wmutex;
Qt::HANDLE rmutex;
QVector rmutexes;
QString mutexname;
Qt::HANDLE getMutexHandle(int idx, bool doCreate);
bool waitMutex(Qt::HANDLE mutex, bool doBlock);
#endif
LockMode m_lock_mode;
};
}
#endif
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtlockedfile_unix.cpp 0000664 0000000 0000000 00000006614 14561607147 0031407 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include
#include
#include
#include
#include "qtlockedfile.h"
bool QtLockedFile::lock(LockMode mode, bool block)
{
if (!isOpen()) {
qWarning("QtLockedFile::lock(): file is not opened");
return false;
}
if (mode == NoLock)
return unlock();
if (mode == m_lock_mode)
return true;
if (m_lock_mode != NoLock)
unlock();
struct flock fl;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK;
int cmd = block ? F_SETLKW : F_SETLK;
int ret = fcntl(handle(), cmd, &fl);
if (ret == -1) {
if (errno != EINTR && errno != EAGAIN)
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
return false;
}
m_lock_mode = mode;
return true;
}
bool QtLockedFile::unlock()
{
if (!isOpen()) {
qWarning("QtLockedFile::unlock(): file is not opened");
return false;
}
if (!isLocked())
return true;
struct flock fl;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_type = F_UNLCK;
int ret = fcntl(handle(), F_SETLKW, &fl);
if (ret == -1) {
qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno));
return false;
}
m_lock_mode = NoLock;
return true;
}
QtLockedFile::~QtLockedFile()
{
if (isOpen())
unlock();
}
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtlockedfile_win.cpp 0000664 0000000 0000000 00000014663 14561607147 0031224 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtlockedfile.h"
#include
#include
#define MUTEX_PREFIX "QtLockedFile mutex "
// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS
#define MAX_READERS MAXIMUM_WAIT_OBJECTS
#if QT_VERSION >= 0x050000
#define QT_WA(unicode, ansi) unicode
#endif
Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
{
if (mutexname.isEmpty()) {
QFileInfo fi(*this);
mutexname = QString::fromLatin1(MUTEX_PREFIX)
+ fi.absoluteFilePath().toLower();
}
QString mname(mutexname);
if (idx >= 0)
mname += QString::number(idx);
Qt::HANDLE mutex;
if (doCreate) {
QT_WA( { mutex = CreateMutexW(NULL, FALSE, (TCHAR*)mname.utf16()); },
{ mutex = CreateMutexA(NULL, FALSE, mname.toLocal8Bit().constData()); } );
if (!mutex) {
qErrnoWarning("QtLockedFile::lock(): CreateMutex failed");
return 0;
}
}
else {
QT_WA( { mutex = OpenMutexW(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, (TCHAR*)mname.utf16()); },
{ mutex = OpenMutexA(SYNCHRONIZE | MUTEX_MODIFY_STATE, FALSE, mname.toLocal8Bit().constData()); } );
if (!mutex) {
if (GetLastError() != ERROR_FILE_NOT_FOUND)
qErrnoWarning("QtLockedFile::lock(): OpenMutex failed");
return 0;
}
}
return mutex;
}
bool QtLockedFile::waitMutex(Qt::HANDLE mutex, bool doBlock)
{
Q_ASSERT(mutex);
DWORD res = WaitForSingleObject(mutex, doBlock ? INFINITE : 0);
switch (res) {
case WAIT_OBJECT_0:
case WAIT_ABANDONED:
return true;
break;
case WAIT_TIMEOUT:
break;
default:
qErrnoWarning("QtLockedFile::lock(): WaitForSingleObject failed");
}
return false;
}
bool QtLockedFile::lock(LockMode mode, bool block)
{
if (!isOpen()) {
qWarning("QtLockedFile::lock(): file is not opened");
return false;
}
if (mode == NoLock)
return unlock();
if (mode == m_lock_mode)
return true;
if (m_lock_mode != NoLock)
unlock();
if (!wmutex && !(wmutex = getMutexHandle(-1, true)))
return false;
if (!waitMutex(wmutex, block))
return false;
if (mode == ReadLock) {
int idx = 0;
for (; idx < MAX_READERS; idx++) {
rmutex = getMutexHandle(idx, false);
if (!rmutex || waitMutex(rmutex, false))
break;
CloseHandle(rmutex);
}
bool ok = true;
if (idx >= MAX_READERS) {
qWarning("QtLockedFile::lock(): too many readers");
rmutex = 0;
ok = false;
}
else if (!rmutex) {
rmutex = getMutexHandle(idx, true);
if (!rmutex || !waitMutex(rmutex, false))
ok = false;
}
if (!ok && rmutex) {
CloseHandle(rmutex);
rmutex = 0;
}
ReleaseMutex(wmutex);
if (!ok)
return false;
}
else {
Q_ASSERT(rmutexes.isEmpty());
for (int i = 0; i < MAX_READERS; i++) {
Qt::HANDLE mutex = getMutexHandle(i, false);
if (mutex)
rmutexes.append(mutex);
}
if (rmutexes.size()) {
DWORD res = WaitForMultipleObjects(rmutexes.size(), rmutexes.constData(),
TRUE, block ? INFINITE : 0);
if (res != WAIT_OBJECT_0 && res != WAIT_ABANDONED) {
if (res != WAIT_TIMEOUT)
qErrnoWarning("QtLockedFile::lock(): WaitForMultipleObjects failed");
m_lock_mode = WriteLock; // trick unlock() to clean up - semiyucky
unlock();
return false;
}
}
}
m_lock_mode = mode;
return true;
}
bool QtLockedFile::unlock()
{
if (!isOpen()) {
qWarning("QtLockedFile::unlock(): file is not opened");
return false;
}
if (!isLocked())
return true;
if (m_lock_mode == ReadLock) {
ReleaseMutex(rmutex);
CloseHandle(rmutex);
rmutex = 0;
}
else {
Q_FOREACH(Qt::HANDLE mutex, rmutexes) {
ReleaseMutex(mutex);
CloseHandle(mutex);
}
rmutexes.clear();
ReleaseMutex(wmutex);
}
m_lock_mode = QtLockedFile::NoLock;
return true;
}
QtLockedFile::~QtLockedFile()
{
if (isOpen())
unlock();
if (wmutex)
CloseHandle(wmutex);
}
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtsingleapplication.cpp 0000664 0000000 0000000 00000026742 14561607147 0031754 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtsingleapplication.h"
#include "qtlocalpeer.h"
//#include
#include
#include
#include
#include
#include
/*!
\class QtSingleApplication qtsingleapplication.h
\brief The QtSingleApplication class provides an API to detect and
communicate with running instances of an application.
This class allows you to create applications where only one
instance should be running at a time. I.e., if the user tries to
launch another instance, the already running instance will be
activated instead. Another usecase is a client-server system,
where the first started instance will assume the role of server,
and the later instances will act as clients of that server.
By default, the full path of the executable file is used to
determine whether two processes are instances of the same
application. You can also provide an explicit identifier string
that will be compared instead.
The application should create the QtSingleApplication object early
in the startup phase, and call isRunning() to find out if another
instance of this application is already running. If isRunning()
returns false, it means that no other instance is running, and
this instance has assumed the role as the running instance. In
this case, the application should continue with the initialization
of the application user interface before entering the event loop
with exec(), as normal.
The messageReceived() signal will be emitted when the running
application receives messages from another instance of the same
application. When a message is received it might be helpful to the
user to raise the application so that it becomes visible. To
facilitate this, QtSingleApplication provides the
setActivationWindow() function and the activateWindow() slot.
If isRunning() returns true, another instance is already
running. It may be alerted to the fact that another instance has
started by using the sendMessage() function. Also data such as
startup parameters (e.g. the name of the file the user wanted this
new instance to open) can be passed to the running instance with
this function. Then, the application should terminate (or enter
client mode).
If isRunning() returns true, but sendMessage() fails, that is an
indication that the running instance is frozen.
Here's an example that shows how to convert an existing
application to use QtSingleApplication. It is very simple and does
not make use of all QtSingleApplication's functionality (see the
examples for that).
\code
// Original
int main(int argc, char **argv)
{
QApplication app(argc, argv);
MyMainWidget mmw;
mmw.show();
return app.exec();
}
// Single instance
int main(int argc, char **argv)
{
QtSingleApplication app(argc, argv);
if (app.isRunning())
return !app.sendMessage(someDataString);
MyMainWidget mmw;
app.setActivationWindow(&mmw);
mmw.show();
return app.exec();
}
\endcode
Once this QtSingleApplication instance is destroyed (normally when
the process exits or crashes), when the user next attempts to run the
application this instance will not, of course, be encountered. The
next instance to call isRunning() or sendMessage() will assume the
role as the new running instance.
For console (non-GUI) applications, QtSingleCoreApplication may be
used instead of this class, to avoid the dependency on the QtGui
library.
\sa QtSingleCoreApplication
*/
void QtSingleApplication::sysInit(const QString &appId)
{
actObj = 0;
peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
/*!
Creates a QtSingleApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc, \a
argv, and \a GUIenabled are passed on to the QAppliation constructor.
If you are creating a console application (i.e. setting \a
GUIenabled to false), you may consider using
QtSingleCoreApplication instead.
*/
QtSingleApplication::QtSingleApplication(int &argc, char **argv, bool GUIenabled)
: QApplication(argc, argv, GUIenabled)
{
sysInit();
}
/*!
Creates a QtSingleApplication object with the application
identifier \a appId. \a argc and \a argv are passed on to the
QAppliation constructor.
*/
QtSingleApplication::QtSingleApplication(const QString &appId, int &argc, char **argv)
: QApplication(argc, argv)
{
sysInit(appId);
}
#if QT_VERSION < 0x050000
/*!
Creates a QtSingleApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc, \a
argv, and \a type are passed on to the QAppliation constructor.
*/
QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
: QApplication(argc, argv, type)
{
sysInit();
}
# if defined(Q_WS_X11)
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be QCoreApplication::applicationFilePath(). \a dpy, \a visual,
and \a cmap are passed on to the QApplication constructor.
*/
QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, visual, cmap)
{
sysInit();
}
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a
argv, \a visual, and \a cmap are passed on to the QApplication
constructor.
*/
QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, argc, argv, visual, cmap)
{
sysInit();
}
/*!
Special constructor for X11, ref. the documentation of
QApplication's corresponding constructor. The application identifier
will be \a appId. \a dpy, \a argc, \a
argv, \a visual, and \a cmap are passed on to the QApplication
constructor.
*/
QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
: QApplication(dpy, argc, argv, visual, cmap)
{
sysInit(appId);
}
# endif // Q_WS_X11
#endif // QT_VERSION < 0x050000
/*!
Returns true if another instance of this application is running;
otherwise false.
This function does not find instances of this application that are
being run by a different user (on Windows: that are running in
another session).
\sa sendMessage()
*/
bool QtSingleApplication::isRunning()
{
return peer->isClient();
}
/*!
Tries to send the text \a message to the currently running
instance. The QtSingleApplication object in the running instance
will emit the messageReceived() signal when it receives the
message.
This function returns true if the message has been sent to, and
processed by, the current instance. If there is no instance
currently running, or if the running instance fails to process the
message within \a timeout milliseconds, this function return false.
\sa isRunning(), messageReceived()
*/
bool QtSingleApplication::sendMessage(const QString &message, int timeout)
{
return peer->sendMessage(message, timeout);
}
/*!
Returns the application identifier. Two processes with the same
identifier will be regarded as instances of the same application.
*/
QString QtSingleApplication::id() const
{
return peer->applicationId();
}
/*!
Sets the activation window of this application to \a aw. The
activation window is the widget that will be activated by
activateWindow(). This is typically the application's main window.
If \a activateOnMessage is true (the default), the window will be
activated automatically every time a message is received, just prior
to the messageReceived() signal being emitted.
\sa activateWindow(), messageReceived()
*/
void QtSingleApplication::setActivationWindow(QObject* aw, bool activateOnMessage)
{
actObj = aw;
if (activateOnMessage)
connect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
else
disconnect(peer, SIGNAL(messageReceived(const QString&)), this, SLOT(activateWindow()));
}
/*!
Returns the applications activation window if one has been set by
calling setActivationWindow(), otherwise returns 0.
\sa setActivationWindow()
*/
QObject* QtSingleApplication::activationWindow() const
{
return actObj;
}
/*!
De-minimizes, raises, and activates this application's activation window.
This function does nothing if no activation window has been set.
This is a convenience function to show the user that this
application instance has been activated when he has tried to start
another instance.
This function should typically be called in response to the
messageReceived() signal. By default, that will happen
automatically, if an activation window has been set.
\sa setActivationWindow(), messageReceived(), initialize()
*/
void QtSingleApplication::activateWindow()
{
}
/*!
\fn void QtSingleApplication::messageReceived(const QString& message)
This signal is emitted when the current instance receives a \a
message from another instance of this application.
\sa sendMessage(), setActivationWindow(), activateWindow()
*/
/*!
\fn void QtSingleApplication::initialize(bool dummy = true)
\obsolete
*/
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtsingleapplication.h 0000664 0000000 0000000 00000007632 14561607147 0031416 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTSINGLEAPPLICATION_H
#define QTSINGLEAPPLICATION_H
#include
class QtLocalPeer;
#if defined(Q_OS_WIN)
# if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT)
# define QT_QTSINGLEAPPLICATION_EXPORT
# elif defined(QT_QTSINGLEAPPLICATION_IMPORT)
# if defined(QT_QTSINGLEAPPLICATION_EXPORT)
# undef QT_QTSINGLEAPPLICATION_EXPORT
# endif
# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport)
# elif defined(QT_QTSINGLEAPPLICATION_EXPORT)
# undef QT_QTSINGLEAPPLICATION_EXPORT
# define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport)
# endif
#else
# define QT_QTSINGLEAPPLICATION_EXPORT
#endif
class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication
{
Q_OBJECT
public:
QtSingleApplication(int &argc, char **argv, bool GUIenabled = true);
QtSingleApplication(const QString &id, int &argc, char **argv);
#if QT_VERSION < 0x050000
QtSingleApplication(int &argc, char **argv, Type type);
# if defined(Q_WS_X11)
QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
# endif // Q_WS_X11
#endif // QT_VERSION < 0x050000
bool isRunning();
QString id() const;
void setActivationWindow(QObject* aw, bool activateOnMessage = true);
QObject* activationWindow() const;
// Obsolete:
void initialize(bool dummy = true)
{ isRunning(); Q_UNUSED(dummy) }
public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
void activateWindow();
Q_SIGNALS:
void messageReceived(const QString &message);
private:
void sysInit(const QString &appId = QString());
QtLocalPeer *peer;
QObject *actObj = nullptr;
};
#endif // QTSINGLEAPPLICATION_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtsingleapplication.pri 0000664 0000000 0000000 00000001061 14561607147 0031747 0 ustar 00root root 0000000 0000000 INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
QT *= network
greaterThan(QT_MAJOR_VERSION, 4): QT *= widgets
qtsingleapplication-uselib:!qtsingleapplication-buildlib {
LIBS += -L$$QTSINGLEAPPLICATION_LIBDIR -l$$QTSINGLEAPPLICATION_LIBNAME
} else {
SOURCES += $$PWD/qtsingleapplication.cpp $$PWD/qtlocalpeer.cpp
HEADERS += $$PWD/qtsingleapplication.h $$PWD/qtlocalpeer.h
}
win32 {
contains(TEMPLATE, lib):contains(CONFIG, shared):DEFINES += QT_QTSINGLEAPPLICATION_EXPORT
else:qtsingleapplication-uselib:DEFINES += QT_QTSINGLEAPPLICATION_IMPORT
}
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtsinglecoreapplication.cpp 0000664 0000000 0000000 00000012355 14561607147 0032620 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qtsinglecoreapplication.h"
#include "qtlocalpeer.h"
/*!
\class QtSingleCoreApplication qtsinglecoreapplication.h
\brief A variant of the QtSingleApplication class for non-GUI applications.
This class is a variant of QtSingleApplication suited for use in
console (non-GUI) applications. It is an extension of
QCoreApplication (instead of QApplication). It does not require
the QtGui library.
The API and usage is identical to QtSingleApplication, except that
functions relating to the "activation window" are not present, for
obvious reasons. Please refer to the QtSingleApplication
documentation for explanation of the usage.
A QtSingleCoreApplication instance can communicate to a
QtSingleApplication instance if they share the same application
id. Hence, this class can be used to create a light-weight
command-line tool that sends commands to a GUI application.
\sa QtSingleApplication
*/
/*!
Creates a QtSingleCoreApplication object. The application identifier
will be QCoreApplication::applicationFilePath(). \a argc and \a
argv are passed on to the QCoreAppliation constructor.
*/
QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv)
: QCoreApplication(argc, argv)
{
peer = new QtLocalPeer(this);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
/*!
Creates a QtSingleCoreApplication object with the application
identifier \a appId. \a argc and \a argv are passed on to the
QCoreAppliation constructor.
*/
QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv)
: QCoreApplication(argc, argv)
{
peer = new QtLocalPeer(this, appId);
connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&)));
}
/*!
Returns true if another instance of this application is running;
otherwise false.
This function does not find instances of this application that are
being run by a different user (on Windows: that are running in
another session).
\sa sendMessage()
*/
bool QtSingleCoreApplication::isRunning()
{
return peer->isClient();
}
/*!
Tries to send the text \a message to the currently running
instance. The QtSingleCoreApplication object in the running instance
will emit the messageReceived() signal when it receives the
message.
This function returns true if the message has been sent to, and
processed by, the current instance. If there is no instance
currently running, or if the running instance fails to process the
message within \a timeout milliseconds, this function return false.
\sa isRunning(), messageReceived()
*/
bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout)
{
return peer->sendMessage(message, timeout);
}
/*!
Returns the application identifier. Two processes with the same
identifier will be regarded as instances of the same application.
*/
QString QtSingleCoreApplication::id() const
{
return peer->applicationId();
}
/*!
\fn void QtSingleCoreApplication::messageReceived(const QString& message)
This signal is emitted when the current instance receives a \a
message from another instance of this application.
\sa sendMessage()
*/
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtsinglecoreapplication.h 0000664 0000000 0000000 00000005025 14561607147 0032261 0 ustar 00root root 0000000 0000000 /****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Solutions component.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QTSINGLECOREAPPLICATION_H
#define QTSINGLECOREAPPLICATION_H
#include
class QtLocalPeer;
class QtSingleCoreApplication : public QCoreApplication
{
Q_OBJECT
public:
QtSingleCoreApplication(int &argc, char **argv);
QtSingleCoreApplication(const QString &id, int &argc, char **argv);
bool isRunning();
QString id() const;
public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
Q_SIGNALS:
void messageReceived(const QString &message);
private:
QtLocalPeer* peer;
};
#endif // QTSINGLECOREAPPLICATION_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/QtSingleApplication/qtsinglecoreapplication.pri 0000664 0000000 0000000 00000000504 14561607147 0032621 0 ustar 00root root 0000000 0000000 INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += $$PWD/qtsinglecoreapplication.h $$PWD/qtlocalpeer.h
SOURCES += $$PWD/qtsinglecoreapplication.cpp $$PWD/qtlocalpeer.cpp
QT *= network
win32:contains(TEMPLATE, lib):contains(CONFIG, shared) {
DEFINES += QT_QTSINGLECOREAPPLICATION_EXPORT=__declspec(dllexport)
}
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetcommon.h 0000664 0000000 0000000 00000002702 14561607147 0024620 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef APPWIDGETCOMMON_H
#define APPWIDGETCOMMON_H
namespace AppWidget {
class AppWidgetCommon
{
public:
static int getProviderIndexFromdecodeAppWidgetId(const int id) {
int sum = id;
int index = (sum >> 16) & (int)0xffff;
return index;
}
static int getWidgetIndexFromdecodeAppWidgetId(const int id) {
int sum = id;
int index = sum & (int)0xffff;
return index;
}
static int createAppWidgetId(const int providerindex, const int appwidgetindex) {
int index1 = providerindex;
int index2 = appwidgetindex;
int id;
id = (index1 << 16) | index2;
return id;
}
};
} // namespace AppWidget
#endif // APPWIDGETCOMMON_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetconfiguration.cpp 0000664 0000000 0000000 00000015501 14561607147 0026533 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "appwidgetconfiguration.h"
#include
#include
#include
#include
#include
static const char* CONFIG_FILE_PATH = "/usr/share/appwidget/config/";
namespace AppWidget {
AppWidgetConfiguration::AppWidgetConfiguration(QObject *parent)
: QObject(parent)
{
m_configInfo = getCurrentConfigInfo();
initFileWatcher();
}
QString AppWidgetConfiguration::getProviderNameByAppWidgetName(const QString &appwidgetname)
{
if(appwidgetname.isEmpty()) {
qWarning() << __FILE__ << __FUNCTION__ << "parameter is empty";
return QString();
}
QString path = QString(CONFIG_FILE_PATH) + QString("%1.conf").arg(appwidgetname);
QSettings setting(path, QSettings::IniFormat);
setting.beginGroup("AppWidget");
QString providerName = setting.value("providerName").toString();
qDebug() << __FILE__ << __FUNCTION__ << appwidgetname << " `s appwidgetname is :" < AppWidgetConfiguration::getAppWidgetConfigs(const QString &appwidgetname, QString begianName)
{
if(appwidgetname.isEmpty()) {
qWarning() << __FILE__ << __FUNCTION__ << "parameter is empty";
return QMap();
}
QMap configs;
QString path = QString(CONFIG_FILE_PATH) + QString("%1.conf").arg(appwidgetname);
QSettings setting(path, QSettings::IniFormat);
setting.beginGroup(begianName);
QStringList keylist = setting.allKeys();
for (int i = 0; i < keylist.count(); i++) {
configs.insert(keylist.at(i),setting.value(keylist.at(i)));
}
setting.endGroup();
setting.sync();
return configs;
}
QString AppWidgetConfiguration::getConfigurationByKey(const QString &path, const QString &key)
{
if(path.isEmpty() || key.isEmpty()) {
qWarning() << __FILE__ << __FUNCTION__ << "parameter is empty";
return QString();
}
QSettings setting(path, QSettings::IniFormat);
setting.setIniCodec(QTextCodec::codecForName("utf-8"));
setting.beginGroup("AppWidget");
QString value = setting.value(key).toString();
setting.endGroup();
setting.sync();
return value;
}
void AppWidgetConfiguration::initFileWatcher()
{
QFileSystemWatcher* fileWatcher = new QFileSystemWatcher(this);
fileWatcher->addPath(QString(CONFIG_FILE_PATH));
connect(fileWatcher, &QFileSystemWatcher::directoryChanged, this, &AppWidgetConfiguration::onDirectoryChanged);
}
QMap AppWidgetConfiguration::getCurrentConfigInfo() const
{
QMap files;
QStringList configFiles = getCurrentConfigFiles();
for (const QString& file : configFiles) {
QString appWidgetName = getAppWidgetNameByFile(file);
files.insert(file, appWidgetName);
}
return files;
}
QStringList AppWidgetConfiguration::getCurrentConfigFiles() const
{
QDir dirinfo = QDir(QString(CONFIG_FILE_PATH));
if (!dirinfo.exists()) {
return QStringList();
}
QStringList filename = {"*.conf"};
QStringList configFiles = dirinfo.entryList(filename, QDir::Files, QDir::Name);
return configFiles;
}
QString AppWidgetConfiguration::getAppWidgetNameByFile(const QString& configFile) const
{
QString path = QString(CONFIG_FILE_PATH) + QString("%1").arg(configFile);
QSettings setting(path, QSettings::IniFormat);
setting.beginGroup("AppWidget");
QString appWidgetName = setting.value("name").toString();
setting.endGroup();
setting.sync();
return appWidgetName;
}
/* 分别获得目录下的当前文件与目录变化之前的文件,移除相同部分;
* 若当前文件非空,则判断为文件新增;
* 若目录变化之前的文件非空,则判断为文件删除;
* 若文件重命名,则表现为旧名文件的删除和新名文件的新增;
*/
void AppWidgetConfiguration::onDirectoryChanged()
{
QStringList currentFiles = getCurrentConfigFiles();
QStringList oldCofigFiles = m_configInfo.keys();
for (const auto& file : currentFiles) {
if (!oldCofigFiles.contains(file)) {
continue;
}
oldCofigFiles.removeOne(file);
currentFiles.removeOne(file);
}
if (currentFiles.count() != 0) {
onAppwidgetAdded(currentFiles);
}
if (oldCofigFiles.count() != 0) {
onAppwidgetRemoved(oldCofigFiles);
}
m_configInfo = getCurrentConfigInfo();
}
void AppWidgetConfiguration::onAppwidgetAdded(const QStringList& changedFiles)
{
for (const QString& file : changedFiles) {
QString appWidgetName = getAppWidgetNameByFile(file);
qDebug() << __FILE__ << __FUNCTION__ << "Appwidgt added: " << appWidgetName;
emit appwidgetAdded(appWidgetName);
}
}
void AppWidgetConfiguration::onAppwidgetRemoved(const QStringList& changedFiles)
{
for (const QString& file : changedFiles) {
QString appWidgetName = m_configInfo.value(file);
qDebug() << __FILE__ << __FUNCTION__ << "Appwidgt removed: " << appWidgetName;
emit appwidgetRemoved(appWidgetName);
}
}
} // namespace AppWidget
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetconfiguration.h 0000664 0000000 0000000 00000004227 14561607147 0026203 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef APPWIDGETCONFIGURATION_H
#define APPWIDGETCONFIGURATION_H
#include
#include
class QFileSystemWatcher;
namespace AppWidget{
class AppWidgetConfiguration : public QObject
{
Q_OBJECT
public:
explicit AppWidgetConfiguration(QObject *parent = nullptr);
~AppWidgetConfiguration() = default;
QString getProviderNameByAppWidgetName(const QString &appwidgetname);
//获取ui文件
QString getAppWidgetUiFile(const QString &appwidgetname);
//获取属性
QString getAppWidgetConfig(const QString &appwidgetname, const QString &config);
//获取所有属性
QMap getAppWidgetConfigs(const QString &appwidgetname, QString begianName);
//各个属性的获取函数
QString getConfigurationByKey(const QString &path, const QString &key);
signals:
void appwidgetAdded(QString name);
void appwidgetRemoved(QString name);
private slots:
void onDirectoryChanged();
private:
void initFileWatcher();
QMap getCurrentConfigInfo() const;
QStringList getCurrentConfigFiles() const;
QString getAppWidgetNameByFile(const QString& configFile) const;
void onAppwidgetAdded(const QStringList& changedFiles);
void onAppwidgetRemoved(const QStringList& changedFiles);
//! @keyword config filename, @value AppWidget name
QMap m_configInfo;
};
} // namespace AppWidget
#endif // APPWIDGETCONFIGURATION_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetmanager.cpp 0000664 0000000 0000000 00000020775 14561607147 0025307 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "appwidgetmanager.h"
#include "appwidgetproviderproxy.h"
#include "appwidgetproxy.h"
#include "mappingmanager.h"
#include "appwidgetconfiguration.h"
#include
#include
#include
#include
namespace AppWidget {
AppWidgetManager::AppWidgetManager(QObject *parent)
: QObject(parent),
m_mappingmanager(new MappingManager(this)),
m_configmanager(new AppWidgetConfiguration(this))
{
qDBusRegisterMetaType>();
registerCommunicationService();
connect(m_configmanager, &AppWidgetConfiguration::appwidgetAdded, this, [this](QString appwidgetName) {
Q_EMIT appWidgetAdded(appwidgetName);
});
connect(m_configmanager, &AppWidgetConfiguration::appwidgetRemoved, this, [this](QString appwidgetName) {
Q_EMIT appWidgetDeleted(appwidgetName);
});
}
AppWidgetManager::~AppWidgetManager()
{
}
//public slots
QStringList AppWidgetManager::getAppWidgetList()
{
QStringList appwidgetlist;
QDir dirinfo = QDir(APP_WIDGET_LIST);
if (!dirinfo.exists()) {
return QStringList();
}
QStringList filename ;
filename << "*.qml";
QStringList results;
results = dirinfo.entryList(filename, QDir::Files, QDir::Name);
for(int i=0; igetAppWidgetUiFile(appwidgetname);
}
QString AppWidgetManager::getAppWidgetConfig(QString appwidgetname, QString config)
{
if (appwidgetname.isEmpty() || config.isEmpty()) {
return QString();
}
return m_configmanager->getAppWidgetConfig(appwidgetname, config);
}
QMap AppWidgetManager::getAppWidgetConfigs(QString appwidgetname)
{
if (appwidgetname.isEmpty()) {
return QMap();
}
return m_configmanager->getAppWidgetConfigs(appwidgetname, "AppWidget");
}
QMap AppWidgetManager::getAppWidgetLanguageFiles(QString appwidgetname)
{
if (appwidgetname.isEmpty()) {
return QMap();
}
QMap languageFiles = m_configmanager->getAppWidgetConfigs(appwidgetname, "LanguageFiles");
QMap appWidgetLanguageFiles;
for (auto it = languageFiles.begin(); it != languageFiles.end(); ++it) {
appWidgetLanguageFiles.insert(it.key(), it.value().toString());
}
return appWidgetLanguageFiles;
}
int AppWidgetManager::registerAppWidget(QString appwidgetname,QString username)
{
if (appwidgetname.isEmpty() | username.isEmpty()) {
return -1;
}
QString providername = m_configmanager->getProviderNameByAppWidgetName(appwidgetname);
if (providername==NULL) {
return -1;
}
AppWidgetProviderProxy* providerproxy = m_mappingmanager->findProviderProxyByProviderName(providername);
if (!providerproxy) {
providerproxy = createProviderProxy(providername);
}
AppWidgetProxy* appwidget = createAppWidgetProxy(providerproxy, appwidgetname, username);
if (!appwidget) {
return -1;
}
return appwidget->getAppWidgetProxyId();
}
bool AppWidgetManager::unregisterAppWidget(int appwidgetid)
{
AppWidgetProviderProxy* providerproxy = m_mappingmanager->findProviderProxyByAppWidgetId(appwidgetid);
if (!providerproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "Providerproxy is null";
return true;
}
if (deleteAppWidgetProxy(providerproxy, appwidgetid)) {
if (providerproxy->appWidgetProxyIsEmpty()) {
deleteProviderProxy(providerproxy);
}
}else {
return false;
}
return true;
}
QMap AppWidgetManager::getAppWidgetData(int appwidgetid)
{
AppWidgetProviderProxy* providerproxy = m_mappingmanager->findProviderProxyByAppWidgetId(appwidgetid);
if (!providerproxy) {
return QMap();
}
return providerproxy->getAppWidgetProviderProxyData();
}
void AppWidgetManager::updateAppWidget(QString providername, QMap data)
{
qDebug() << __FILE__ << __FUNCTION__ << ": Providername = " << providername;
AppWidgetProviderProxy * providerproxy = m_mappingmanager->findProviderProxyByProviderName(providername);
if (!providerproxy) {
return ;
}
providerproxy->updateAppWidgetProviderProxyData(data);
}
void AppWidgetManager::updateUserStatus(QString username, QString status)
{
QVector appvec = m_mappingmanager->findAppWidgetProxyByUserName(username);
for (int var = 0; var < appvec.size(); ++var) {
appvec.at(var)->updateUserStatus(status);
}
}
void AppWidgetManager::notifyProviderUpdate(int id) {
AppWidgetProviderProxy* providerproxy = m_mappingmanager->findProviderProxyByAppWidgetId(id);
providerproxy->appWidgetUpdate();
}
void AppWidgetManager::registerCommunicationService()
{
QDBusConnection systembus = QDBusConnection::sessionBus();
QString object = KAppWidgetCommon::getManagerDbusObject();
QString objectPath = KAppWidgetCommon::getManagerDbusPath();
QString interface = KAppWidgetCommon::getManagerDbusInterface();
if (systembus.registerService(object)) {
qDebug() << "Regist Dbus Service success";
systembus.registerObject(objectPath, interface, this, QDBusConnection :: ExportAllSlots | QDBusConnection :: ExportAllSignals);
}
else
qCritical() << "Register DBus Service Error:" << systembus.lastError().message();
}
bool AppWidgetManager::registerScheduledUpdate(AppWidgetProviderProxy* providerproxy , int timingperiod)
{
Q_UNUSED(providerproxy);
Q_UNUSED(timingperiod);
return false;
}
bool AppWidgetManager::unregisterScheduledUpdate(AppWidgetProviderProxy* providerproxy)
{
Q_UNUSED(providerproxy);
return false;
}
AppWidgetProviderProxy* AppWidgetManager::createProviderProxy(QString providername)
{
AppWidgetProviderProxy* providerproxy = m_mappingmanager->asyncCreateProviderProxy(providername);
if (!providerproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "providerproxy is null";
return nullptr;
}
providerproxy->appWidgetEnable();
return providerproxy;
}
void AppWidgetManager::deleteProviderProxy(AppWidgetProviderProxy* providerproxy)
{
if (!providerproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "providerproxy is null";
return;
}
providerproxy->appWidgetDisable();
// if(通过配置管理查看配置是否注册定时任务){
// unregisterScheduledUpdate(providerproxy);
// }
m_mappingmanager->destroyProviderProxy(providerproxy);
}
AppWidgetProxy* AppWidgetManager::createAppWidgetProxy(AppWidgetProviderProxy* providerproxy, QString appwidgetname, QString username)
{
if (!providerproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "providerproxy is null";
return nullptr ;
}
AppWidgetProxy* appwidgetproxy = providerproxy->createAppWidgetProxy(appwidgetname, username);
if (!appwidgetproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "appwidgetproxy is null";
return nullptr;
}
appwidgetproxy->setProviderProxy(providerproxy);
return appwidgetproxy;
}
bool AppWidgetManager::deleteAppWidgetProxy(AppWidgetProviderProxy* providerproxy, int id)
{
qDebug() << __FILE__ << __FUNCTION__ << "delete appwidget`s id:" << id;
if (!providerproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "providerproxy is null";
return false;
}
if (providerproxy->destroyAppWidgetProxy(id)) {
providerproxy->appWidgetDeleted();
} else {
return false;
}
return true;
}
} // namespace AppWidget
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetmanager.h 0000664 0000000 0000000 00000005473 14561607147 0024752 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef APPWIDGETMANAGER_H
#define APPWIDGETMANAGER_H
#include
#include
namespace AppWidget {
class AppWidgetProviderProxy;
class AppWidgetProxy;
class MappingManager;
class AppWidgetConfiguration;
class AppWidgetManager : public QObject
{
Q_OBJECT
public:
Q_CLASSINFO("D-Bus Interface", "org.ukui.appwidget.manager")
explicit AppWidgetManager(QObject *parent = nullptr);
~AppWidgetManager();
public slots:
QStringList getAppWidgetList();
QString getAppWidgetUiFile(QString appwidgetname);
QString getAppWidgetConfig(QString appwidgetname, QString config);
QMap getAppWidgetConfigs(QString appwidgetname);
QMap getAppWidgetLanguageFiles(QString appwidgetname);
int registerAppWidget(QString appwidgetname, QString username);
bool unregisterAppWidget(int appwidgetid);
QMap getAppWidgetData(int appwidgetid);
void updateAppWidget(QString providername, QMap data);
void updateUserStatus(QString username, QString status);
void notifyProviderUpdate(int id);
signals:
void appWidgetAdded(QString appwidgetname);
void appWidgetDeleted (QString appwidgetname);
private:
void registerCommunicationService();//注册dbus服务
bool registerScheduledUpdate(AppWidgetProviderProxy* providerproxy, int timingperiod);//注册定时更新
bool unregisterScheduledUpdate(AppWidgetProviderProxy* providerproxy);//注销定时更新
AppWidgetProviderProxy* createProviderProxy(QString providername);
void deleteProviderProxy(AppWidgetProviderProxy* providerproxy);
AppWidgetProxy* createAppWidgetProxy(AppWidgetProviderProxy* providerproxy, QString appwidgetname, QString username);
bool deleteAppWidgetProxy(AppWidgetProviderProxy* providerproxy, int id);
//定时更新
//映射管理
MappingManager* m_mappingmanager = nullptr;
//小插件列表管理
//小插件配置管理
AppWidgetConfiguration * m_configmanager = nullptr;
};
} // namespace AppWidget
Q_DECLARE_METATYPE(QString)
#endif // APPWIDGETMANAGER_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetproviderproxy.cpp 0000664 0000000 0000000 00000013447 14561607147 0026627 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "appwidgetproviderproxy.h"
#include "appwidgetcommon.h"
#include "appwidgetproxy.h"
#include
#include
#include
#include
namespace AppWidget {
AppWidgetProviderProxy::AppWidgetProviderProxy(int id, QString providername)
:QDBusInterface(KAppWidgetCommon::getProviderDbusObject(providername),
KAppWidgetCommon::getProviderDbusPath(providername),
KAppWidgetCommon::getProviderDbusInterface(providername)),
m_index(id),
m_providername(providername)
{
}
AppWidgetProviderProxy::~AppWidgetProviderProxy()
{
for (int i = 0; i < m_appwidgetproxy.count(); i++) {
if(m_appwidgetproxy.at(i) != nullptr) {
delete m_appwidgetproxy.at(i);
}
}
}
int AppWidgetProviderProxy::getAppWidgetProviderProxyIndex()
{
return m_index;
}
QString AppWidgetProviderProxy::getAppWidgetProviderProxyProviderName()
{
return m_providername;
}
QVector AppWidgetProviderProxy::getAppwidgetProxyByUser(QString username)
{
QVector appwidgetvec;
for (int i = 0; i < m_appwidgetproxy.size(); ++i) {
if (m_appwidgetproxy.at(i) == nullptr || !m_appwidgetproxy.at(i)->isValid()) {
continue;
}
if(m_appwidgetproxy.at(i)->getAppWidgetProxyUserName() == username) {
appwidgetvec.append(m_appwidgetproxy.at(i));
}
}
return appwidgetvec;
}
QMap AppWidgetProviderProxy::getAppWidgetProviderProxyData()
{
return m_data;
}
AppWidgetProxy* AppWidgetProviderProxy::getAppWidgetProxy(int id)
{
int index = AppWidgetCommon::getWidgetIndexFromdecodeAppWidgetId(id);
if(m_appwidgetproxy.at(index)) {
return m_appwidgetproxy.at(index);
}else {
return nullptr;
}
}
void AppWidgetProviderProxy::updateAppWidgetProviderProxyData(QMap data)
{
m_data = data;
int size = m_appwidgetproxy.size();
for(int i = 0; i < size; i++) {
if(m_appwidgetproxy.at(i)) {
m_appwidgetproxy.at(i)->updateAppWidget();
}
}
}
void AppWidgetProviderProxy::appWidgetRecevie(QString eventname, QString controlname, QDBusVariant value)
{
QVariant date;
date.setValue(value);
asyncCall("appWidgetRecevie", eventname, controlname, date);
}
void AppWidgetProviderProxy::appWidgetUpdate()
{
asyncCall("appWidgetUpdate");
}
void AppWidgetProviderProxy::appWidgetDisable()
{
asyncCall("appWidgetDisable");
}
void AppWidgetProviderProxy::appWidgetEnable()
{
asyncCall("appWidgetEnable");
}
void AppWidgetProviderProxy::appWidgetDeleted()
{
asyncCall("appWidgetDeleted");
}
void AppWidgetProviderProxy::appWidgetClicked(QString cotrolname, QDBusVariant value)
{
qDebug() << __FILE__ << __FUNCTION__ << ": Appwidgetname: " << cotrolname;
QVariant date;
date.setValue(value);
asyncCall("appWidgetClicked", cotrolname, date);
// system("ukui-control-center");
}
bool AppWidgetProviderProxy::appWidgetProxyIsEmpty()
{
int size = m_appwidgetproxy.size();
for(int i = 0; i < size; i++) {
if(m_appwidgetproxy.at(i) != nullptr) {
return false;
}
}
return true;
}
AppWidgetProxy* AppWidgetProviderProxy::createAppWidgetProxy(QString appwidgetname, QString username)
{
int index1 = m_index;
int index2 = getUsableIndex();
int id = AppWidgetCommon::createAppWidgetId(index1, index2);
AppWidgetProxy* appwidgetproxy = new AppWidgetProxy(id, appwidgetname, username);
addAppWidgetProxy(index2, appwidgetproxy);
return appwidgetproxy;
}
bool AppWidgetProviderProxy::destroyAppWidgetProxy(int id)
{
int index = AppWidgetCommon::getWidgetIndexFromdecodeAppWidgetId(id);
return deleteAppWidgetProxy(index);
}
int* AppWidgetProviderProxy::getAllAppWidgetIds()
{
return nullptr;
}
bool AppWidgetProviderProxy::addAppWidgetProxy(int index, AppWidgetProxy* appwidgetproxy)
{
if(appwidgetproxy) {
int size = m_appwidgetproxy.size();
if(index < size) {
m_appwidgetproxy.replace(index, appwidgetproxy);
}else {
m_appwidgetproxy.append(appwidgetproxy);
}
return true;
}
qWarning() << __FILE__ << __FUNCTION__ << "Appwidgetproxy is nullptr";
return false;
}
bool AppWidgetProviderProxy::deleteAppWidgetProxy(int index)
{
int size = m_appwidgetproxy.size();
if(index < size) {
if(m_appwidgetproxy.at(index)) {
AppWidgetProxy* appwidgetproxy = m_appwidgetproxy.at(index);
m_appwidgetproxy.replace(index, nullptr);
if(appwidgetproxy != nullptr) {
delete appwidgetproxy;
appwidgetproxy = nullptr;
}
return true;
}
}
qWarning() << __FILE__ << __FUNCTION__ << "Appwidgetproxy deleted failed";
return false;
}
int AppWidgetProviderProxy::getUsableIndex()
{
int size = m_appwidgetproxy.size();
for(int i = 0; i < size; i++) {
if(m_appwidgetproxy.at(i) == nullptr) {
return i;
}
}
return size;
}
} // namespace AppWidget
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetproviderproxy.h 0000664 0000000 0000000 00000004263 14561607147 0026270 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef APPWIDGETPROVIDERPROXY_H
#define APPWIDGETPROVIDERPROXY_H
#include
#include
namespace AppWidget {
class AppWidgetProxy;
class AppWidgetProviderProxy : public QDBusInterface
{
Q_OBJECT
public:
AppWidgetProviderProxy(int id, QString providerName);
~AppWidgetProviderProxy();
void updateAppWidgetProviderProxyData(QMap data);
QMap getAppWidgetProviderProxyData();
AppWidgetProxy* createAppWidgetProxy(QString appwidgetname, QString username);
bool destroyAppWidgetProxy(int id);
int* getAllAppWidgetIds();
void appWidgetRecevie(QString eventname, QString widgetname, QDBusVariant value);
void appWidgetUpdate();
void appWidgetDisable();
void appWidgetDeleted();
void appWidgetEnable();
void appWidgetClicked(QString widgetname, QDBusVariant value);
bool appWidgetProxyIsEmpty();
AppWidgetProxy* getAppWidgetProxy(int id);
int getAppWidgetProviderProxyIndex();
QString getAppWidgetProviderProxyProviderName();
QVector getAppwidgetProxyByUser(QString username);
private:
bool addAppWidgetProxy(int index, AppWidgetProxy* appwidgetproxy);
bool deleteAppWidgetProxy(int index);
int getUsableIndex();
private:
QMap m_data;
QVector m_appwidgetproxy;
int m_index;
QString m_providername;
};
} // namespace AppWidget
#endif // APPWIDGETPROVIDERPROXY_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetproxy.cpp 0000664 0000000 0000000 00000005025 14561607147 0025045 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "appwidgetproxy.h"
#include "appwidgetproviderproxy.h"
#include "appwidgetcommon.h"
#include
#include
#include
namespace AppWidget {
AppWidgetProxy::AppWidgetProxy(int id, QString appwidgetname, QString appwidgetuser)
:QDBusInterface(KAppWidgetCommon::getAppWidgetDbusObject(appwidgetuser,id),
KAppWidgetCommon::getAppWidgetDbusPath(appwidgetuser,id),
KAppWidgetCommon::getAppWidgetDbusInterface(appwidgetuser,id)),
m_id(id),
m_appwidgetname(appwidgetname),
m_username(appwidgetuser),
m_provider(nullptr)
{
connect(this, &AppWidgetProxy::clickedSignal, this, &AppWidgetProxy::onClicked);
connect(this, &AppWidgetProxy::defineEventSignal, this, &AppWidgetProxy::onDefineSignalType);
}
AppWidgetProxy::~AppWidgetProxy()
{
}
void AppWidgetProxy::setProviderProxy(AppWidgetProviderProxy * providerproxy)
{
m_provider = providerproxy;
}
int AppWidgetProxy::getAppWidgetProxyId()
{
return m_id;
}
QString AppWidgetProxy::getAppWidgetProxyAppWidgetName()
{
return m_appwidgetname;
}
QString AppWidgetProxy::getAppWidgetProxyUserName()
{
return m_username;
}
void AppWidgetProxy::updateAppWidget()
{
qDebug() << "dbus 调用提供端小插件代理" << m_id;
this->asyncCall("updateAppWidget");
}
void AppWidgetProxy::updateUserStatus(QString status)
{
qDebug() << "dbus updateUserStatus" << status;
this->asyncCall("updateUserStatus", status);
}
void AppWidgetProxy::onClicked(QString widgetname, QDBusVariant value)
{
m_provider->appWidgetClicked(widgetname, value);
}
void AppWidgetProxy::onDefineSignalType(QString eventname, QString widgetname, QDBusVariant value)
{
m_provider->appWidgetRecevie(eventname, widgetname, value);
}
} // namespace AppWidget
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/appwidgetproxy.h 0000664 0000000 0000000 00000003555 14561607147 0024520 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef APPWIDGETPROXY_H
#define APPWIDGETPROXY_H
#include
namespace AppWidget {
class AppWidgetProviderProxy;
class AppWidgetProxy : public QDBusInterface
{
Q_OBJECT
public:
AppWidgetProxy(int id, QString appwidgetname, QString appwidgetuser);
~AppWidgetProxy();
void updateAppWidget();
void updateUserStatus(QString status);
void updateAppWidgetOptions(QVariant key, QVariant value);
bool updateAppWidgetSize(QSize);
int getAppWidgetProxyId();
QString getAppWidgetProxyAppWidgetName();
QString getAppWidgetProxyUserName();
void setProviderProxy(AppWidgetProviderProxy * providerproxy);
public slots:
void onClicked(QString widgetname, QDBusVariant value);
void onDefineSignalType(QString eventname, QString widgetname, QDBusVariant value);
private:
int m_id ;
QString m_appwidgetname;
QString m_username;
AppWidgetProviderProxy* m_provider;
signals:
void clickedSignal(QString widgetname, QDBusVariant value);
void defineEventSignal(QString eventname, QString widgetname, QDBusVariant value);
};
} // namespace AppWidget
#endif // APPWIDGETPROXY_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/asyncproviderproxycreator.cpp 0000664 0000000 0000000 00000003060 14561607147 0027326 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "asyncproviderproxycreator.h"
#include "appwidgetproviderproxy.h"
#include
namespace AppWidget {
AsyncProviderProxyCreator::AsyncProviderProxyCreator(QObject* parent)
: QThread(parent)
{
}
void AsyncProviderProxyCreator::startCreatorByIndexAndName(int index, QString providername)
{
m_providerName = providername;
m_index = index;
start();
}
void AsyncProviderProxyCreator::run()
{
qDebug() << __FILE__ << __FUNCTION__ << "providername =" << m_providerName;
AppWidgetProviderProxy* providerproxy = new AppWidgetProviderProxy(m_index, m_providerName);
m_appWidgetProviderProxy = providerproxy;
}
AppWidgetProviderProxy* AsyncProviderProxyCreator::getProviderProxy()
{
if (isFinished()) {
return m_appWidgetProviderProxy;
}
return nullptr;
}
} // namespace AppWidget
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/asyncproviderproxycreator.h 0000664 0000000 0000000 00000002567 14561607147 0027006 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef ASYNCPROVIDERPROXYCREATOR_H
#define ASYNCPROVIDERPROXYCREATOR_H
#include
namespace AppWidget {
class AppWidgetProviderProxy;
class AsyncProviderProxyCreator : public QThread
{
Q_OBJECT
public:
AsyncProviderProxyCreator(QObject *parent = nullptr);
~AsyncProviderProxyCreator() = default;
void run() override;
void startCreatorByIndexAndName(int index, QString providername);
AppWidgetProviderProxy* getProviderProxy();
private:
int m_index;
QString m_providerName;
AppWidgetProviderProxy* m_appWidgetProviderProxy = nullptr;
};
} // namespace AppWidget
#endif // ASYNCPROVIDERPROXYCREATOR_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/data/ 0000775 0000000 0000000 00000000000 14561607147 0022162 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-manager/data/org.ukui.appwidget.manager.service 0000664 0000000 0000000 00000000125 14561607147 0030701 0 ustar 00root root 0000000 0000000 [D-BUS Service]
Name=org.ukui.appwidget.manager
Exec=/usr/bin/ukui-appwidget-manager
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/data/ukui-appwidget-manager.desktop 0000664 0000000 0000000 00000000450 14561607147 0030123 0 ustar 00root root 0000000 0000000 [Desktop Entry]
Name=ukui-appwidget-manager
Name[zh_CN]=小插框架件
Comment=ukui-appwidget-manager
Comment[zh_CN]=小插框架件
Exec=/usr/bin/ukui-appwidget-manager
Terminal=false
Type=Application
NoDisplay=true
OnlyShowIn=UKUI
X-UKUI-Autostart-Phase=Initialization
X-UKUI-AutoRestart=true
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/main.cpp 0000664 0000000 0000000 00000002277 14561607147 0022711 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "appwidgetmanager.h"
#include
#include "ukui-log4qt.h"
int main(int argc, char *argv[])
{
QtSingleApplication a("ukui-appwidget-manager", argc, argv);
if(a.isRunning())
{
a.sendMessage("Process already exists");
return EXIT_SUCCESS;
}
#ifndef QT_DEBUG
initUkuiLog4qt("ukui-appwidget-manager");
#endif
AppWidget::AppWidgetManager w;
a.setActivationWindow(&w);//单例
return a.exec();
}
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/mappingmanager.cpp 0000664 0000000 0000000 00000012312 14561607147 0024742 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#include "mappingmanager.h"
#include "appwidgetproviderproxy.h"
#include "appwidgetcommon.h"
#include "asyncproviderproxycreator.h"
#include
#include
#include
namespace AppWidget {
MappingManager::MappingManager(QObject *parent)
:QObject(parent)
{
}
MappingManager::~MappingManager()
{
for (int i = 0; i < m_providerproxy.count(); i++) {
if (m_providerproxy.at(i) != nullptr) {
delete m_providerproxy.at(i);
}
}
}
AppWidgetProviderProxy* MappingManager::findProviderProxyByProviderName(const QString providername)
{
//通过名字从提供端容器查找到提供端代理
for (int i = 0 ; i < m_providerproxy.size(); i++) {
if (m_providerproxy.at(i)) {
if (m_providerproxy.at(i)->getAppWidgetProviderProxyProviderName() == providername) {
return m_providerproxy.at(i);
}
}
}
return nullptr;
}
AppWidgetProviderProxy* MappingManager::findProviderProxyByAppWidgetId(int id)
{
int index = AppWidgetCommon::getProviderIndexFromdecodeAppWidgetId(id);
if (index < m_providerproxy.size()) {
return m_providerproxy.at(index);
}
return nullptr;
}
AppWidgetProxy* MappingManager::findAppWidgetProxyByAppWidgetId(int id)
{
qDebug() << __FILE__ << __FUNCTION__ << "appwidget`s id :" << id;
int index1 = AppWidgetCommon::getProviderIndexFromdecodeAppWidgetId(id);
AppWidgetProviderProxy* providerproxy;
if (index1 < m_providerproxy.size()) {
providerproxy = m_providerproxy.at(index1);
if (!providerproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "providerproxy is null";
return nullptr;
}
}
AppWidgetProxy* appwidgetproxy = providerproxy->getAppWidgetProxy(id);
if (appwidgetproxy) {
return appwidgetproxy;
}else {
qWarning() << __FILE__ << __FUNCTION__ << "appwidgetproxy is null";
return nullptr;
}
}
QVector MappingManager::findAppWidgetProxyByUserName(QString username)
{
qDebug() << __FILE__ << __FUNCTION__ << "UserName`s :" << username;
QVector appwidgetlist;
AppWidgetProviderProxy* providerproxy;
for (int i = 0; i < m_providerproxy.size(); ++i) {
providerproxy = m_providerproxy.at(i);
if (!providerproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "providerproxy is null";
continue;
}
QVector appvec(providerproxy->getAppwidgetProxyByUser(username));
for (int var = 0; var < appvec.size(); ++var) {
appwidgetlist.append(appvec.at(var));
}
}
return appwidgetlist;
}
AppWidgetProviderProxy* MappingManager::asyncCreateProviderProxy(QString providername)
{
qDebug() << __FILE__ << __FUNCTION__ << "providername :" << providername;
int index = getUsableIndex();
AsyncProviderProxyCreator providerProxyCreator;
providerProxyCreator.startCreatorByIndexAndName(index, providername);
while (!providerProxyCreator.isFinished()) {
QCoreApplication::processEvents(QEventLoop::AllEvents);
QThread::msleep(1);
}
if (providerProxyCreator.getProviderProxy()) {
addProviderProxy(index, providerProxyCreator.getProviderProxy());
}
return providerProxyCreator.getProviderProxy();
}
void MappingManager::destroyProviderProxy(AppWidgetProviderProxy* providerproxy)
{
if (!providerproxy) {
qWarning() << __FILE__ << __FUNCTION__ << "providerproxy is null";
return ;
}
int index = providerproxy->getAppWidgetProviderProxyIndex();
deleteProviderProxy(index);
}
int MappingManager::getUsableIndex()
{
int size = m_providerproxy.size();
for (int i = 0; i < size; i++) {
if (m_providerproxy.at(i) == nullptr) {
return i;
}
}
return size;
}
void MappingManager::addProviderProxy(int index, AppWidgetProviderProxy* providerproxy)
{
int size = m_providerproxy.size();
if (index < size){
m_providerproxy.replace(index, providerproxy);
} else {
m_providerproxy.append(providerproxy);
}
}
void MappingManager::deleteProviderProxy(int index)
{
qDebug() << __FILE__ << __FUNCTION__;
int size = m_providerproxy.size();
if (index < size) {
AppWidgetProviderProxy * providerproxy = m_providerproxy.at(index);
m_providerproxy.replace(index, nullptr);
if (providerproxy) {
delete providerproxy;
}
}
}
} // namespace AppWidget
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/mappingmanager.h 0000664 0000000 0000000 00000003422 14561607147 0024411 0 ustar 00root root 0000000 0000000 /*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: wangyan
*
*/
#ifndef MAPPINGMANAGER_H
#define MAPPINGMANAGER_H
#include
#include
#include
class AsyncProviderProxyCreator;
namespace AppWidget {
class AppWidgetProviderProxy;
class AppWidgetProxy;
class MappingManager:public QObject
{
Q_OBJECT
public:
MappingManager(QObject *parent = nullptr);
~MappingManager();
AppWidgetProviderProxy* findProviderProxyByProviderName(const QString providername);
AppWidgetProviderProxy* findProviderProxyByAppWidgetId(int id);
AppWidgetProxy* findAppWidgetProxyByAppWidgetId(int id);
QVector findAppWidgetProxyByUserName(QString username);
AppWidgetProviderProxy* asyncCreateProviderProxy(QString providername);
void destroyProviderProxy(AppWidgetProviderProxy* providerproxy);
private:
int getUsableIndex();
void addProviderProxy(int index, AppWidgetProviderProxy* providerproxy);
void deleteProviderProxy(int index);
private:
QVector m_providerproxy;
};
} // namespace AppWidget
#endif // MAPPINGMANAGER_H
ukui-app-widget-4.0.0.2/ukui-appwidget-manager/ukui-appwidget-manager.pro 0000664 0000000 0000000 00000003321 14561607147 0026341 0 ustar 00root root 0000000 0000000 QT += core gui dbus
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++11 link_pkgconfig
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
DEFINES += APP_WIDGET_LIST=\\\"/usr/share/appwidget/qml\\\"
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
include(QtSingleApplication/qtsingleapplication.pri)
include(../libukui-appwidget-common/libukui-appwidget-common.pri)
SOURCES += \
appwidgetconfiguration.cpp \
appwidgetproviderproxy.cpp \
appwidgetproxy.cpp \
asyncproviderproxycreator.cpp \
main.cpp \
appwidgetmanager.cpp \
mappingmanager.cpp
HEADERS += \
appwidgetcommon.h \
appwidgetconfiguration.h \
appwidgetmanager.h \
appwidgetproviderproxy.h \
appwidgetproxy.h \
asyncproviderproxycreator.h \
mappingmanager.h
# Default rules for deployment.
target.path = /usr/bin/
managerservice.files += data/org.ukui.appwidget.manager.service
managerservice.path += /usr/share/dbus-1/services/
desktop.files += data/ukui-appwidget-manager.desktop
desktop.path += /etc/xdg/autostart/
INSTALLS += target managerservice desktop
DISTFILES += \
data/org.ukui.appwidget.manager.service \
data/ukui-appwidget-manager.desktop
LIBS += -lukui-log4qt
ukui-app-widget-4.0.0.2/ukui-appwidget-test/ 0000775 0000000 0000000 00000000000 14561607147 0020616 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-test/appwidgetprovider-clock-demo/ 0000775 0000000 0000000 00000000000 14561607147 0026370 5 ustar 00root root 0000000 0000000 appwidgetprovider-clock-demo.pro 0000664 0000000 0000000 00000000150 14561607147 0034601 0 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-test/appwidgetprovider-clock-demo TEMPLATE = subdirs
SUBDIRS += \
appwidgetprovider-clock-demo \
appwidgetprovider-clock-service
appwidgetprovider-clock-demo/ 0000775 0000000 0000000 00000000000 14561607147 0034063 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-test/appwidgetprovider-clock-demo appwidgetprovider-clock-demo.pro 0000664 0000000 0000000 00000003205 14561607147 0042357 0 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-test/appwidgetprovider-clock-demo/appwidgetprovider-clock-demo QT += core gui widgets dbus qml quick
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
include(../../../ukui-appwidget-manager/QtSingleApplication/qtsingleapplication.pri)
CONFIG += C++11
# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
TRANSLATIONS += \
translations/democlock_zh_CN.ts \
translations/democlock_bo_CN.ts
# Default rules for deployment.
qnx: target.path = /usr/bin/
else: unix:!android: target.path = /usr/bin/
qml.files += data/democlock.qml
qml.path = /usr/share/appwidget/qml/
appwidgetcong.files += data/democlock.conf
appwidgetcong.path = /usr/share/appwidget/config/
preview.files += data/democlock.png
preview.path = /usr/share/appwidgetdemo/clock/
qm_files.files += translations/*
qm_files.path = /usr/share/appwidget/translations/
INSTALLS += target qml appwidgetcong preview qm_files
RESOURCES += \
src.qrc
DISTFILES += \ \
QtSingleApplication/qtsingleapplication.pri \
QtSingleApplication/qtsinglecoreapplication.pri
config.ini 0000664 0000000 0000000 00000000015 14561607147 0036025 0 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-test/appwidgetprovider-clock-demo/appwidgetprovider-clock-demo [AlarmClock]
data/ 0000775 0000000 0000000 00000000000 14561607147 0034774 5 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-test/appwidgetprovider-clock-demo/appwidgetprovider-clock-demo democlock.conf 0000664 0000000 0000000 00000000746 14561607147 0037612 0 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-test/appwidgetprovider-clock-demo/appwidgetprovider-clock-demo/data [AppWidget]
name = democlock
providerName = democlock
previewPath = /usr/share/appwidgetdemo/clock/democlock.png
qmlFile = /usr/share/appwidget/qml/democlock.qml
zoom = false
rightButton = false
repeatPlacement = false
minWidget = 400
minHeight = 400
targetCellWidth = 2
targetCellHeight = 2
updatePeriodMillis = 0
describe = this is a alarm clock
[LanguageFiles]
zh_CN = /usr/share/appwidget/translations/democlock_zh_CN.qm
bo_CN = /usr/share/appwidget/translations/democlock_bo_CN.qm
democlock.png 0000664 0000000 0000000 00000044736 14561607147 0037460 0 ustar 00root root 0000000 0000000 ukui-app-widget-4.0.0.2/ukui-appwidget-test/appwidgetprovider-clock-demo/appwidgetprovider-clock-demo/data PNG
IHDR L > pHYs + IDATxy\., 7,)&hbx`摚)}+-Kjٷ_g%QZ ʍ(%}-{]Waewχ{w絳s|>(@G !Ð#rrXCab99B,!G0!Ð#rrXCab99B,!G0!Ð#rrXCab99B,!G0!Ð#rrXCab9@Q__]RRXA]]] U`hhh^(he! p|6---%%%999%%eee*KKAYPWÐwEegg<23vXPHF@!jΝxbQQyN߾}'LonnraȵуN:Gi2eܹs5]jCE*++=Z:h.3gkAO`5O"9s&444""B,k.|Wutt4]NO!BCC>Ƶy.\Zz.Puu]~]ӵ_|1i$N(2XOO|}}} bX,DՏ?.//ɹ{nNNNnnn pvv^f͜9sx Z,`kk $IfeefddiW~뭷|
WZw!?bŊ