Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
X11:Liri:git
qt5-qtaccountsservice
_service:obs_scm:qt5-qtaccountsservice-1.3.0.26...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:qt5-qtaccountsservice-1.3.0.26+git.e8a9950.obscpio of Package qt5-qtaccountsservice
07070100000000000081A40000000000000000000000016208D08F000000D1000000000000000000000000000000000000003A00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.gitattributes.tag export-subst .gitignore export-ignore .gitattributes export-ignore .gitmodules export-ignore .github export-ignore .travis export-ignore .travis.yml export-ignore .tx export-ignore .mailmap export-ignore 07070100000001000041ED0000000000000000000000036208D08F00000000000000000000000000000000000000000000003300000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.github07070100000002000041ED0000000000000000000000026208D08F00000000000000000000000000000000000000000000003D00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.github/workflows07070100000003000081A40000000000000000000000016208D08F00000148000000000000000000000000000000000000004700000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.github/workflows/build.yml# SPDX-FileCopyrightText: 2022 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> # # SPDX-License-Identifier: CC0-1.0 name: CI on: push: branches: - master - develop pull_request: branches: - master - develop jobs: build: uses: lirios/.github/.github/workflows/build-linux.yml@master 07070100000004000081A40000000000000000000000016208D08F0000019F000000000000000000000000000000000000004800000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.github/workflows/checks.yml# SPDX-FileCopyrightText: 2022 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> # # SPDX-License-Identifier: CC0-1.0 name: Checks on: push: branches: - master - develop tags: - v* pull_request: types: - opened - synchronize - reopened - edited jobs: checks: uses: lirios/.github/.github/workflows/checks.yml@master with: enable_wip: true 07070100000005000081A40000000000000000000000016208D08F0000013B000000000000000000000000000000000000004600000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.github/workflows/copr.yml# SPDX-FileCopyrightText: 2022 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> # # SPDX-License-Identifier: CC0-1.0 name: COPR on: push: branches: - develop jobs: copr: uses: lirios/.github/.github/workflows/copr.yml@master secrets: COPR_WEBHOOK_URL: ${{ secrets.COPR_WEBHOOK_URL }} 07070100000006000081A40000000000000000000000016208D08F0000001B000000000000000000000000000000000000003600000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.gitignorebuild/ *.user *.qmlc *.jsc 07070100000007000081A40000000000000000000000016208D08F000000F1000000000000000000000000000000000000003400000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.mailmapPier Luigi Fiorini <pierluigi.fiorini@liri.io> <plfiorini@users.noreply.github.com> Pier Luigi Fiorini <pierluigi.fiorini@liri.io> <pierluigi.fiorini@hawaiios.org> Pier Luigi Fiorini <pierluigi.fiorini@liri.io> <pierluigi.fiorini@gmail.com> 07070100000008000081A40000000000000000000000016208D08F0000000C000000000000000000000000000000000000003000000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/.tag$Format:%H$ 07070100000009000081A40000000000000000000000016208D08F000000E2000000000000000000000000000000000000003600000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/AUTHORS.mdQt Accounts Service =================== # Core Developers * Pier Luigi Fiorini # Contributors You can see the list of contributors to this code base, and the number of their commits with: ```sh git shortlog -s -e -n ``` 0707010000000A000081A40000000000000000000000016208D08F000005C1000000000000000000000000000000000000003A00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/CMakeLists.txtcmake_minimum_required(VERSION 3.10.0) project("QtAccountsService" VERSION "1.3.0" DESCRIPTION "Qt-style API for Accounts Service" LANGUAGES CXX C ) ## Shared macros and functions: if(NOT LIRI_LOCAL_ECM) find_package(LiriCMakeShared "2.0.0" REQUIRED NO_MODULE) list(APPEND CMAKE_MODULE_PATH "${LCS_MODULE_PATH}") endif() ## Set minimum versions required: set(QT_MIN_VERSION "5.8.0") ## Liri specific setup common for all modules: include(LiriSetup) ## Only build on the appropriate platforms. if(NOT UNIX OR ANDROID) message(NOTICE "Skipping the build as the condition \"UNIX OR ANDROID\" is not met.") return() endif() ## Features: option(QTACCOUNTSSERVICE_WITH_EXAMPLES "Build examples" ON) add_feature_info("QtAccountsService Examples" QTACCOUNTSSERVICE_WITH_EXAMPLES "Build QtAccountsService examples") ## Find Qt 5: find_package(Qt5 "${QT_MIN_VERSION}" CONFIG REQUIRED COMPONENTS Core DBus Gui Qml Quick QuickTest ) ## Treat warnings as errors: add_compile_options(-Wall -Wextra -Werror) ## Add subdirectories: add_subdirectory(src/accountsservice) if(QTACCOUNTSSERVICE_WITH_EXAMPLES) add_subdirectory(examples/listusers) add_subdirectory(examples/loggedinuser) add_subdirectory(examples/useraccount) add_subdirectory(examples/userslistview) endif() add_subdirectory(src/imports/accountsservice) if(BUILD_TESTING) add_subdirectory(tests/auto/api) endif() 0707010000000B000081A40000000000000000000000016208D08F000059B2000000000000000000000000000000000000003700000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/LICENSE.FDL GNU Free Documentation License Version 1.3, 3 November 2008 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 0. PREAMBLE The purpose of this License is to make a manual, textbook, or other functional and useful document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others. This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software. We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. 1. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law. A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none. The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words. A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called "Opaque". Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only. The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. The "publisher" means any person or entity that distributes copies of the Document to the public. A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition. The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License. 2. VERBATIM COPYING You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. 3. COPYING IN QUANTITY If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 4. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version: A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission. B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement. C. State on the Title page the name of the publisher of the Modified Version, as the publisher. D. Preserve all the copyright notices of the Document. E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below. G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice. H. Include an unaltered copy of this License. I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence. J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission. K. For any section Entitled "Acknowledgements" or "Dedications", Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. M. Delete any section Entitled "Endorsements". Such a section may not be included in the Modified Version. N. Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any Invariant Section. O. Preserve any Warranty Disclaimers. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. 5. COMBINING DOCUMENTS You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements". 6. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. 7. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate. 8. TRANSLATION Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail. If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title. 9. TERMINATION You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License. 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, receipt of a copy of some or all of the same material does not give you any rights to use it. 10. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new, revised versions of the GNU Free Documentation 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. See http://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Document. 11. RELICENSING "Massive Multiauthor Collaboration Site" (or "MMC Site") means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A "Massive Multiauthor Collaboration" (or "MMC") contained in the site means any set of copyrightable works thus published on the MMC site. "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization. "Incorporate" means to publish or republish a Document, in whole or in part, as part of another Document. An MMC is "eligible for relicensing" if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008. The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing. ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright (c) YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the "with...Texts." line with this: with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software. 0707010000000C000081A40000000000000000000000016208D08F00001DE3000000000000000000000000000000000000003A00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/LICENSE.LGPLv3 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. 0707010000000D000081A40000000000000000000000016208D08F00000659000000000000000000000000000000000000003500000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/README.mdQt Accounts Service =================== [![License](https://img.shields.io/badge/license-LGPLv3.0-blue.svg)](http://www.gnu.org/licenses/lgpl.txt) [![GitHub release](https://img.shields.io/github/release/lirios/qtaccountsservice.svg)](https://github.com/lirios/qtaccountsservice) [![GitHub issues](https://img.shields.io/github/issues/lirios/qtaccountsservice.svg)](https://github.com/lirios/qtaccountsservice/issues) [![CI](https://github.com/lirios/qtaccountsservice/workflows/CI/badge.svg?branch=develop)](https://github.com/lirios/qtaccountsservice/actions?query=workflow%3ACI) Qt-style API to use freedesktop.org's AccountsService DBus service. For more information [read here](http://www.freedesktop.org/wiki/Software/AccountsService) ## Dependencies Qt >= 5.8.0 with at least the following modules is required: * [qtbase](http://code.qt.io/cgit/qt/qtbase.git) * [qtdeclarative](http://code.qt.io/cgit/qt/qtdeclarative.git) The following modules and their dependencies are required: * [cmake](https://gitlab.kitware.com/cmake/cmake) >= 3.10.0 * [cmake-shared](https://github.com/lirios/cmake-shared.git) >= 1.0.0 ## Installation ```sh mkdir build cd build cmake -DCMAKE_INSTALL_PREFIX=/path/to/prefix .. make make install # use sudo if necessary ``` Replace `/path/to/prefix` to your installation prefix. Default is `/usr/local`. You can also append the following options to the `cmake` command: * `-DQTACCOUNTSSERVICE_WITH_EXAMPLES:BOOL=OFF`: Do not build the examples. ## Licensing Licensed under the terms of the GNU Lesser General Public License version 3 or, at your option, any later version. 0707010000000E000041ED0000000000000000000000066208D08F00000000000000000000000000000000000000000000003400000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples0707010000000F000081A40000000000000000000000016208D08F000000E8000000000000000000000000000000000000004100000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/examples.qbsimport qbs 1.0 Project { name: "Examples" references: [ "listusers/listusers.qbs", "loggedinuser/loggedinuser.qbs", "useraccount/useraccount.qbs", "userslistview/userslistview.qbs", ] } 07070100000010000041ED0000000000000000000000026208D08F00000000000000000000000000000000000000000000003E00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/listusers07070100000011000081A40000000000000000000000016208D08F000000BE000000000000000000000000000000000000004D00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/listusers/CMakeLists.txtliri_add_executable(listusers SOURCES main.cpp LIBRARIES Qt5::Core Liri::Qt5AccountsService NO_TARGET_INSTALLATION ) liri_finalize_executable(listusers) 07070100000012000081A40000000000000000000000016208D08F0000007D000000000000000000000000000000000000004C00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/listusers/listusers.qbsimport qbs 1.0 QtApplication { name: "listusers" Depends { name: "Qt5AccountsService" } files: ["main.cpp"] } 07070100000013000081A40000000000000000000000016208D08F0000065A000000000000000000000000000000000000004700000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/listusers/main.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtCore/QCoreApplication> #include <QtCore/QDebug> #include <Qt5AccountsService/AccountsManager> #include <Qt5AccountsService/UserAccount> using namespace QtAccountsService; int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); AccountsManager *manager = new AccountsManager(); app.connect(manager, &AccountsManager::listCachedUsersFinished, &app, [](const UserAccountList &list) { for (UserAccount *account : list) qInfo() << account->realName() << account->userName(); QCoreApplication::quit(); }); manager->listCachedUsers(); return app.exec(); } 07070100000014000041ED0000000000000000000000026208D08F00000000000000000000000000000000000000000000004100000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/loggedinuser07070100000015000081A40000000000000000000000016208D08F00000102000000000000000000000000000000000000005000000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/loggedinuser/CMakeLists.txtliri_add_executable(loggedinuser SOURCES loggedinuser.qml main.cpp RESOURCES resources.qrc LIBRARIES Qt5::Core Qt5::Gui Qt5::Qml NO_TARGET_INSTALLATION ) liri_finalize_executable(loggedinuser) 07070100000016000081A40000000000000000000000016208D08F000000E0000000000000000000000000000000000000005200000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/loggedinuser/loggedinuser.qbsimport qbs 1.0 QtGuiApplication { name: "loggedinuser" Depends { name: "Qt"; submodules: ["gui", "qml"]; versionAtLeast: project.minimumQtVersion } files: [ "main.cpp", "resources.qrc" ] } 07070100000017000081A40000000000000000000000016208D08F00000684000000000000000000000000000000000000005200000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/loggedinuser/loggedinuser.qml/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * Copyright (C) 2015-2016 Leslie Zhai <xiang.zhai@i-soft.com.cn> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ import QtQuick 2.2 import QtQuick.Window 2.1 import QtAccountsService 1.0 Window { width: 300 height: 200 title: "QtAccountsService" visible: true UserAccount { id: userAccount } Image { id: faceIcon source: userAccount.iconFileName ? "file://" + userAccount.iconFileName : "" } Text { id: loginName anchors.left: faceIcon.right text: userAccount.userName } Text { id: displayName anchors.top: loginName.bottom anchors.left: loginName.left text: userAccount.displayName } } 07070100000018000081A40000000000000000000000016208D08F000004F5000000000000000000000000000000000000004A00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/loggedinuser/main.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine(QUrl(QLatin1String("qrc:/loggedinuser.qml"))); Q_UNUSED(engine); return app.exec(); } 07070100000019000081A40000000000000000000000016208D08F0000005F000000000000000000000000000000000000004F00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/loggedinuser/resources.qrc<RCC> <qresource prefix="/"> <file>loggedinuser.qml</file> </qresource> </RCC> 0707010000001A000041ED0000000000000000000000026208D08F00000000000000000000000000000000000000000000004000000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/useraccount0707010000001B000081A40000000000000000000000016208D08F000000FF000000000000000000000000000000000000004F00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/useraccount/CMakeLists.txtliri_add_executable(useraccount SOURCES main.cpp useraccount.qml RESOURCES resources.qrc LIBRARIES Qt5::Core Qt5::Gui Qt5::Qml NO_TARGET_INSTALLATION ) liri_finalize_executable(useraccount) 0707010000001C000081A40000000000000000000000016208D08F000004F4000000000000000000000000000000000000004900000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/useraccount/main.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine(QUrl(QLatin1String("qrc:/useraccount.qml"))); Q_UNUSED(engine); return app.exec(); } 0707010000001D000081A40000000000000000000000016208D08F0000005E000000000000000000000000000000000000004E00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/useraccount/resources.qrc<RCC> <qresource prefix="/"> <file>useraccount.qml</file> </qresource> </RCC> 0707010000001E000081A40000000000000000000000016208D08F000000DF000000000000000000000000000000000000005000000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/useraccount/useraccount.qbsimport qbs 1.0 QtGuiApplication { name: "useraccount" Depends { name: "Qt"; submodules: ["gui", "qml"]; versionAtLeast: project.minimumQtVersion } files: [ "main.cpp", "resources.qrc" ] } 0707010000001F000081A40000000000000000000000016208D08F00000918000000000000000000000000000000000000005000000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/useraccount/useraccount.qml/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * Copyright (C) 2015-2016 Leslie Zhai <xiang.zhai@i-soft.com.cn> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ import QtQuick 2.2 import QtQuick.Window 2.1 import QtAccountsService 1.0 Window { width: 300 height: 200 title: "QtAccountsService" visible: true UserAccount { id: userAccount } Column { anchors.fill: parent anchors.margins: 6 spacing: 6 Row { spacing: 6 Text { text: "Type a uid and press Enter:" } TextInput { id: textInput //inputMask: "[0-9]" focus: true onAccepted: userAccount.userId = text } } Rectangle { width: parent.width height: 1 color: "gainsboro" } Row { spacing: 9 Image { id: faceIcon source: userAccount.iconFileName ? "file://" + userAccount.iconFileName : "" } Column { spacing: 8 Text { id: loginName text: userAccount.userName } Text { id: displayName text: userAccount.displayName } } } } } 07070100000020000041ED0000000000000000000000026208D08F00000000000000000000000000000000000000000000004200000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/userslistview07070100000021000081A40000000000000000000000016208D08F00000105000000000000000000000000000000000000005100000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/userslistview/CMakeLists.txtliri_add_executable(userslistview SOURCES main.cpp userslistview.qml RESOURCES resources.qrc LIBRARIES Qt5::Core Qt5::Gui Qt5::Qml NO_TARGET_INSTALLATION ) liri_finalize_executable(userslistview) 07070100000022000081A40000000000000000000000016208D08F000004F6000000000000000000000000000000000000004B00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/userslistview/main.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtGui/QGuiApplication> #include <QtQml/QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine(QUrl(QLatin1String("qrc:/userslistview.qml"))); Q_UNUSED(engine); return app.exec(); } 07070100000023000081A40000000000000000000000016208D08F00000060000000000000000000000000000000000000005000000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/userslistview/resources.qrc<RCC> <qresource prefix="/"> <file>userslistview.qml</file> </qresource> </RCC> 07070100000024000081A40000000000000000000000016208D08F000000E0000000000000000000000000000000000000005400000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/userslistview/userslistview.qbsimport qbs 1.0 QtGuiApplication { name: "userslistview" Depends { name: "Qt"; submodules: ["gui", "qml"]; versionAtLest: project.minimumQtVersion } files: [ "main.cpp", "resources.qrc" ] } 07070100000025000081A40000000000000000000000016208D08F00000639000000000000000000000000000000000000005400000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/examples/userslistview/userslistview.qml/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ import QtQuick 2.0 import QtQuick.Window 2.0 import QtAccountsService 1.0 Window { width: 600 height: 400 title: "QtAccountsService" visible: true ListView { anchors.fill: parent model: UsersModel {} spacing: 8 delegate: Row { spacing: 8 Image { width: 96 height: width source: iconFileName ? "file://" + iconFileName : "" } Text { text: "User name: " + userName + "\n" + "Real name: " + realName } } } } 07070100000026000081A40000000000000000000000016208D08F00000333000000000000000000000000000000000000004100000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/qtaccountsservice.qbsimport qbs 1.0 Project { name: "QtAccountsService" readonly property string version: "1.2.0" readonly property var versionParts: version.split('.').map(function(part) { return parseInt(part); }) readonly property string minimumQtVersion: "5.8.0" property bool useStaticAnalyzer: false property bool withExamples: false property bool autotestEnabled: false property stringList autotestArguments: [] property stringList autotestWrapper: [] minimumQbsVersion: "1.9.0" references: [ "src/deployment.qbs", "src/accountsservice/accountsservice.qbs", "src/imports/imports.qbs", "tests/auto/auto.qbs", ] SubProject { filePath: "examples/examples.qbs" Properties { condition: withExamples } } } 07070100000027000041ED0000000000000000000000046208D08F00000000000000000000000000000000000000000000002F00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src07070100000028000041ED0000000000000000000000026208D08F00000000000000000000000000000000000000000000003F00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice07070100000029000081A40000000000000000000000016208D08F00000310000000000000000000000000000000000000004E00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/CMakeLists.txtliri_add_module(Qt5AccountsService DESCRIPTION "Qt style API for Accounts Service" MODULE_NAME Qt5AccountsService VERSIONED_MODULE_NAME Qt5AccountsService SOURCES accountsmanager.cpp accountsmanager.h accountsmanager_p.h useraccount.cpp useraccount.h useraccount_p.h usersmodel.cpp usersmodel.h usersmodel_p.h DBUS_INTERFACE_SOURCES org.freedesktop.Accounts.xml org.freedesktop.Accounts.User.xml DEFINES QT_NO_CAST_FROM_ASCII QT_NO_FOREACH PUBLIC_LIBRARIES Qt5::Core Qt5::DBus Qt5::Gui PKGCONFIG_DEPENDENCIES Qt5Core Qt5DBus Qt5Gui ) liri_finalize_module(Qt5AccountsService) 0707010000002A000081A40000000000000000000000016208D08F0000345C000000000000000000000000000000000000005300000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/accountsmanager.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtCore/QDebug> #include <QtDBus/QDBusPendingCallWatcher> #include "accountsmanager.h" #include "accountsmanager_p.h" namespace QtAccountsService { /* * AccountsManagerPrivate */ AccountsManagerPrivate::AccountsManagerPrivate(const QDBusConnection &bus) { interface = new OrgFreedesktopAccountsInterface(QStringLiteral("org.freedesktop.Accounts"), QStringLiteral("/org/freedesktop/Accounts"), bus); } AccountsManagerPrivate::~AccountsManagerPrivate() { qDeleteAll(usersCache); delete interface; } void AccountsManagerPrivate::_q_userAdded(const QDBusObjectPath &path) { Q_Q(AccountsManager); if (usersCache.contains(path.path())) { Q_EMIT q->userAdded(usersCache[path.path()]); return; } UserAccount *account = new UserAccount(path.path(), interface->connection()); usersCache[path.path()] = account; Q_EMIT q->userAdded(account); } void AccountsManagerPrivate::_q_userDeleted(const QDBusObjectPath &path) { Q_Q(AccountsManager); UserAccount *account = usersCache.value(path.path(), nullptr); if (!account) account = new UserAccount(path.path()); usersCache.remove(path.path()); Q_EMIT q->userDeleted(account->userId()); account->deleteLater(); } /*! \class AccountsManager \brief AccountsManager provides the backend for user management. The AccountsManager class allows for querying and manipiulating user account information. \author Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> */ /*! Constructs a AccountsManager object. */ AccountsManager::AccountsManager(const QDBusConnection &bus, QObject *parent) : QObject(parent) , d_ptr(new AccountsManagerPrivate(bus)) { qRegisterMetaType<UserAccount::AccountType>("UserAccount::AccountType"); qRegisterMetaType<UserAccount *>("UserAccount*"); d_ptr->q_ptr = this; connect(d_ptr->interface, SIGNAL(UserAdded(QDBusObjectPath)), // clazy:exclude=old-style-connect this, SLOT(_q_userAdded(QDBusObjectPath))); connect(d_ptr->interface, SIGNAL(UserDeleted(QDBusObjectPath)), // clazy:exclude=old-style-connect this, SLOT(_q_userDeleted(QDBusObjectPath))); } /*! Destroy a AccountsManager object. */ AccountsManager::~AccountsManager() { delete d_ptr; } /*! Caches a user account, so that it shows up in listCachedUsers() output. The user name may be a remote user, but the system must be able to lookup the user name and resolve the user information. A userCached() signal with a UserAccount pointer will be emitted as soon as the user account has been cached by AccountsService. \param userName The user name for the user. */ void AccountsManager::cacheUser(const QString &userName) { Q_D(AccountsManager); QDBusPendingCall call = d->interface->CacheUser(userName); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) { QDBusPendingReply<QDBusObjectPath> reply = *w; w->deleteLater(); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't cache user %s: %s", userName.toUtf8().constData(), error.errorString(error.type()).toUtf8().constData()); } else { QDBusObjectPath path = reply.argumentAt<0>(); if (path.path().isEmpty()) return; UserAccount *account = d->usersCache.value(path.path(), nullptr); if (!account) { account = new UserAccount(path.path(), d->interface->connection()); d->usersCache[path.path()] = account; } Q_EMIT userCached(userName); } }); } /*! Releases all metadata about a user account, including icon, language and session. If the user account is from a remote server and the user has never logged in before, then that account will no longer show up in listCachedUsers() output. Emits userUncached() when done. \param userName The user name for the user. */ void AccountsManager::uncacheUser(const QString &userName) { Q_D(AccountsManager); QDBusPendingCall call = d->interface->UncacheUser(userName); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) { QDBusPendingReply<QDBusObjectPath> reply = *w; w->deleteLater(); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't uncache user %s: %s", userName.toUtf8().constData(), error.errorString(error.type()).toUtf8().constData()); } else { QMap<QString, UserAccount *>::iterator it = d->usersCache.begin(); while (it != d->usersCache.end()) { auto account = it.value(); if (account->userName() == userName) { d->usersCache.erase(++it); account->deleteLater(); } else { ++it; } } Q_EMIT userUncached(userName); } }); } /*! List cache users asynchronously. When the list is ready, \c listCachedUsersFinished will be emitted. */ void AccountsManager::listCachedUsers() { Q_D(AccountsManager); QDBusPendingCall call = d->interface->ListCachedUsers(); QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this); connect(watcher, &QDBusPendingCallWatcher::finished, this, [=](QDBusPendingCallWatcher *w) { QDBusPendingReply<QList<QDBusObjectPath>> reply = *w; w->deleteLater(); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't list cached users: %s", error.errorString(error.type()).toUtf8().constData()); } else { UserAccountList userList; QList<QDBusObjectPath> value = reply.argumentAt<0>(); userList.reserve(value.size()); for (int i = 0; i < value.size(); i++) { const QString path = value.at(i).path(); UserAccount *account = d->usersCache.value(path, nullptr); if (!account) { account = new UserAccount(path, d->interface->connection()); d->usersCache[path] = account; } userList.append(account); } Q_EMIT listCachedUsersFinished(userList); } }); } /*! Returns a list of user accounts. This method is synchronous and may take some time. \param systemUsers If true, returns also system users. */ UserAccountList AccountsManager::listCachedUsersSync() { Q_D(AccountsManager); UserAccountList list; QDBusPendingReply<QList<QDBusObjectPath>> reply = d->interface->ListCachedUsers(); reply.waitForFinished(); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't list cached users: %s", error.errorString(error.type()).toUtf8().constData()); return list; } QList<QDBusObjectPath> value = reply.argumentAt<0>(); list.reserve(value.size()); for (int i = 0; i < value.size(); i++) { const QString path = value.at(i).path(); UserAccount *account = d->usersCache.value(path, nullptr); if (!account) { account = new UserAccount(path, d->interface->connection()); d->usersCache[path] = account; } list.append(account); } return list; } /*! Returns user with name \a userName from the list of cached users created by \l listCachedUsers(). \param userName The user name to look up. \return the corresponding UserAccount object. */ UserAccount *AccountsManager::cachedUser(const QString &userName) const { Q_D(const AccountsManager); QMap<QString, UserAccount *>::const_iterator it = d->usersCache.constBegin(); while (it != d->usersCache.constEnd()) { auto account = it.value(); if (account->userName() == userName) return account; } return nullptr; } /*! Finds a user by \a uid. This method is synchronous and may take some time. \param uid The uid to look up. \return the corresponding UserAccount object. */ UserAccount *AccountsManager::findUserById(qlonglong uid) { Q_D(AccountsManager); QDBusPendingReply<QDBusObjectPath> reply = d->interface->FindUserById(uid); reply.waitForFinished(); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't find user by uid %lld: %s", uid, error.errorString(error.type()).toUtf8().constData()); return nullptr; } QDBusObjectPath path = reply.argumentAt<0>(); if (path.path().isEmpty()) return nullptr; UserAccount *account = d->usersCache.value(path.path(), nullptr); if (!account) { account = new UserAccount(path.path(), d->interface->connection()); d->usersCache[path.path()] = account; } return account; } /*! Finds a user by user \a userName. This method is synchronous and may take some time. \param uid The user name to look up. \return the corresponding UserAccount object. */ UserAccount *AccountsManager::findUserByName(const QString &userName) { Q_D(AccountsManager); QDBusPendingReply<QDBusObjectPath> reply = d->interface->FindUserByName(userName); reply.waitForFinished(); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't find user by user name %s: %s", userName.toUtf8().constData(), error.errorString(error.type()).toUtf8().constData()); return nullptr; } QDBusObjectPath path = reply.argumentAt<0>(); if (path.path().isEmpty()) return nullptr; UserAccount *account = d->usersCache.value(path.path(), nullptr); if (!account) { account = new UserAccount(path.path(), d->interface->connection()); d->usersCache[path.path()] = account; } return account; } /*! Creates a new \a accountType type user account whose name is \a userName, real name is \a fullName. This method is synchronous and may take some time. \param userName The name of the new user to be created. \param fullName First name and last name. \param accountType The account type. \return whether the user was created successfully. */ bool AccountsManager::createUser(const QString &userName, const QString &fullName, UserAccount::AccountType accountType) { Q_D(AccountsManager); QDBusPendingReply<QDBusObjectPath> reply = d->interface->CreateUser(userName, fullName, accountType); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't create user %s: %s", userName.toUtf8().constData(), error.errorString(error.type()).toUtf8().constData()); return false; } return true; } /*! Deletes the user designated by \a uid. This method is synchronous and may take some time. \param uid The user identifier. \param removeFiles If true all files owned by the user will be removed. \return whether the user was deleted successfully. */ bool AccountsManager::deleteUser(qlonglong uid, bool removeFiles) { Q_D(AccountsManager); QDBusPendingReply<> reply = d->interface->DeleteUser(uid, removeFiles); if (reply.isError()) { QDBusError error = reply.error(); qWarning("Couldn't delete user %lld: %s", uid, error.errorString(error.type()).toUtf8().constData()); return false; } return true; } /*! Deletes the specified \a account. This method is synchronous and may take some time. \param account The account to remove. \param removeFiles If true all files owned by the user will be removed. \return whether the user was deleted successfully. */ bool AccountsManager::deleteUser(UserAccount *account, bool removeFiles) { return deleteUser(account->userId(), removeFiles); } } #include "moc_accountsmanager.cpp" 0707010000002B000081A40000000000000000000000016208D08F00000B46000000000000000000000000000000000000005100000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/accountsmanager.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #ifndef QTACCOUNTSSERVICE_ACCOUNTSMANAGER_H #define QTACCOUNTSSERVICE_ACCOUNTSMANAGER_H #include <QtCore/QObject> #include <QtDBus/QDBusConnection> #include <Qt5AccountsService/UserAccount> QT_FORWARD_DECLARE_CLASS(QDBusObjectPath) namespace QtAccountsService { class AccountsManagerPrivate; class QT5ACCOUNTSSERVICE_EXPORT AccountsManager : public QObject { Q_OBJECT public: explicit AccountsManager(const QDBusConnection &bus = QDBusConnection::systemBus(), QObject *parent = nullptr); ~AccountsManager(); Q_INVOKABLE void cacheUser(const QString &userName); Q_INVOKABLE void uncacheUser(const QString &userName); Q_INVOKABLE void listCachedUsers(); UserAccountList listCachedUsersSync(); Q_INVOKABLE QtAccountsService::UserAccount *cachedUser(const QString &userName) const; Q_INVOKABLE QtAccountsService::UserAccount *findUserById(qlonglong uid); Q_INVOKABLE QtAccountsService::UserAccount *findUserByName(const QString &userName); Q_INVOKABLE bool createUser(const QString &userName, const QString &fullName, UserAccount::AccountType accountType); Q_INVOKABLE bool deleteUser(qlonglong uid, bool removeFiles); bool deleteUser(UserAccount *account, bool removeFiles); Q_SIGNALS: void userAdded(QtAccountsService::UserAccount *account); void userDeleted(qlonglong uid); void userCached(const QString &userName); void userUncached(const QString &userName); void listCachedUsersFinished(const QtAccountsService::UserAccountList &userList); protected: AccountsManagerPrivate *d_ptr; private: Q_DECLARE_PRIVATE(AccountsManager) Q_PRIVATE_SLOT(d_func(), void _q_userAdded(const QDBusObjectPath &path)) Q_PRIVATE_SLOT(d_func(), void _q_userDeleted(const QDBusObjectPath &path)) }; } #endif // QTACCOUNTSSERVICE_ACCOUNTSMANAGER_H 0707010000002C000081A40000000000000000000000016208D08F00000785000000000000000000000000000000000000005300000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/accountsmanager_p.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #ifndef QTACCOUNTSSERVICE_ACCOUNTSMANAGER_P_H #define QTACCOUNTSSERVICE_ACCOUNTSMANAGER_P_H #include "accounts_interface.h" // // W A R N I N G // ------------- // // This file is not part of the Qt AccountsService API. It exists // purely as an implementation detail. This header file may change from // version to version without notice, or even be removed. // // We mean it. // class OrgFreedesktopAccountsInterface; namespace QtAccountsService { class AccountsManager; class AccountsManagerPrivate { Q_DECLARE_PUBLIC(AccountsManager) public: AccountsManagerPrivate(const QDBusConnection &bus); ~AccountsManagerPrivate(); AccountsManager *q_ptr; OrgFreedesktopAccountsInterface *interface; QMap<QString, UserAccount *> usersCache; void _q_userAdded(const QDBusObjectPath &path); void _q_userDeleted(const QDBusObjectPath &path); }; } #endif // QTACCOUNTSSERVICE_ACCOUNTSMANAGER_P_H 0707010000002D000081A40000000000000000000000016208D08F000006F3000000000000000000000000000000000000005300000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/accountsservice.qbsimport qbs 1.0 import LiriUtils LiriModuleProject { id: root name: "Qt5AccountsService" moduleName: "Qt5AccountsService" description: "Qt-style wrapper for Accounts Service" resolvedProperties: ({ Depends: [{ name: LiriUtils.quote("Qt.core") }, { name: LiriUtils.quote("Qt.dbus") }, { name: LiriUtils.quote("Qt.gui") }], }) pkgConfigDependencies: ["Qt5Core", "Qt5DBus", "Qt5Gui"] cmakeDependencies: ({ "Qt5Core": project.minimumQtVersion, "Qt5DBus": project.minimumQtVersion, "Qt5Gui": project.minimumQtVersion }) cmakeLinkLibraries: ["Qt5::Core", "Qt5::DBus", "Qt5::Gui"] LiriHeaders { name: root.headersName sync.module: root.moduleName Group { name: "Headers" files: "**/*.h" fileTags: ["hpp_syncable"] } } LiriModule { name: root.moduleName targetName: root.targetName version: "1.0.0" Depends { name: root.headersName } Depends { name: "Qt"; submodules: ["core", "dbus", "gui"]; versionAtLeast: project.minimumQtVersion } cpp.defines: base.concat([ "QTACCOUNTSSERVICE_VERSION=" + project.version, "QT_BUILD_QTACCOUNTSSERVICE_LIB" ]) files: ["*.cpp", "*.h"] Group { name: "D-Bus Interfaces" files: [ "org.freedesktop.Accounts.xml", "org.freedesktop.Accounts.User.xml" ] fileTags: ["qt.dbus.interface"] } Export { Depends { name: "cpp" } Depends { name: root.headersName } Depends { name: "Qt"; submodules: ["core", "dbus", "gui"]; versionAtLeast: project.minimumQtVersion } } } } 0707010000002E000081A40000000000000000000000016208D08F000069D3000000000000000000000000000000000000006100000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/org.freedesktop.Accounts.User.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" > <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> <interface name="org.freedesktop.Accounts.User"> <method name="SetUserName"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="name" direction="in" type="s"> <doc:doc> <doc:summary> The new username. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users username. Note that it is usually not allowed to have multiple users with the same username. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the username of any user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetRealName"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="name" direction="in" type="s"> <doc:doc> <doc:summary> The new name, typically in the form "Firstname Lastname". </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users real name. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term> <doc:definition>To change his own name</doc:definition> </doc:item> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the name of another user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetEmail"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="email" direction="in" type="s"> <doc:doc> <doc:summary> The new email address. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users email address. </doc:para> <doc:para> Note that setting an email address in the AccountsService is not the same as configuring a mail client. Mail clients might default to email address that is configured here, though. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term> <doc:definition>To change his own email address</doc:definition> </doc:item> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the email address of another user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetLanguage"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="language" direction="in" type="s"> <doc:doc> <doc:summary> The new language, as a locale specification like "de_DE.UTF-8". </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users language. </doc:para> <doc:para> The expectation is that display managers will start the users session with this locale. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term> <doc:definition>To change his own language</doc:definition> </doc:item> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the language of another user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetXSession"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="user_set_x_session"/> <arg name="x_session" direction="in" type="s"> <doc:doc> <doc:summary> The new xsession to start (e.g. "gnome") </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users x session. </doc:para> <doc:para> The expectation is that display managers will log the user in to this specified session, if available. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term> <doc:definition>To change his own language</doc:definition> </doc:item> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the language of another user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetLocation"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="location" direction="in" type="s"> <doc:doc> <doc:summary> The new location as a freeform string. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users location. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term> <doc:definition>To change his own location</doc:definition> </doc:item> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the location of another user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetHomeDirectory"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="homedir" direction="in" type="s"> <doc:doc> <doc:summary> The new homedir as an absolute path. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users home directory. </doc:para> <doc:para> Note that changing the users home directory moves all the content from the old location to the new one, and is potentially an expensive operation. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the home directory of a user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetShell"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="shell" direction="in" type="s"> <doc:doc> <doc:summary> The new user shell. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users shell. </doc:para> <doc:para> Note that setting the shell to a non-allowed program may prevent the user from logging in. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the shell of a user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetIconFile"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="filename" direction="in" type="s"> <doc:doc> <doc:summary> The absolute filename of a png file to use as the users icon. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users icon. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term> <doc:definition>To change his own icon</doc:definition> </doc:item> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the icon of another user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetLocked"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="locked" direction="in" type="b"> <doc:doc> <doc:summary> Whether to lock or unlock the users account. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Locks or unlocks a users account. </doc:para> <doc:para> Locking an account prevents the user from logging in. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To lock or unlock user accounts</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetAccountType"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="accountType" direction="in" type="i"> <doc:doc> <doc:summary> The new account type, encoded as an integer: <doc:list> <doc:item> <doc:term>0</doc:term> <doc:definition>Standard user</doc:definition> </doc:item> <doc:item> <doc:term>1</doc:term> <doc:definition>Administrator</doc:definition> </doc:item> </doc:list> </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Changes the users account type. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change an account type</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetPasswordMode"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="mode" direction="in" type="i"> <doc:doc> <doc:summary> The new password mode, encoded as an integer: <doc:list> <doc:item> <doc:term>0</doc:term> <doc:definition>Regular password</doc:definition> </doc:item> <doc:item> <doc:term>1</doc:term> <doc:definition>Password must be set at next login</doc:definition> </doc:item> <doc:item> <doc:term>2</doc:term> <doc:definition>No password</doc:definition> </doc:item> </doc:list> </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Changes the users password mode. </doc:para> <doc:para> Note that changing the password mode has the side-effect of unlocking the account. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change a users password mode</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetPassword"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="password" direction="in" type="s"> <doc:doc> <doc:summary> The crypted password. </doc:summary> </doc:doc> </arg> <arg name="hint" direction="in" type="s"> <doc:doc> <doc:summary> The password hint. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets a new password for this user. </doc:para> <doc:para> Note that setting a password has the side-effect of unlocking the account. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the password of a user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetPasswordHint"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="hint" direction="in" type="s"> <doc:doc> <doc:summary> The password hint. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Sets the users password hint. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.change-own-user-data</doc:term> <doc:definition>To change his own language</doc:definition> </doc:item> <doc:item> <doc:term>org.freedesktop.accounts.user-administration</doc:term> <doc:definition>To change the language of another user</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="SetAutomaticLogin"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="enabled" direction="in" type="b"> <doc:doc> <doc:summary> Whether to enable automatic login for this user. </doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Enables or disables automatic login for a user. </doc:para> <doc:para> Note that usually only one user can have automatic login enabled, so turning it on for a user will disable it for the previously configured autologin user. </doc:para> </doc:description> <doc:permission> The caller needs one of the following PolicyKit authorizations: <doc:list> <doc:item> <doc:term>org.freedesktop.accounts.set-login-option</doc:term> <doc:definition>To change the login screen configuration</doc:definition> </doc:item> </doc:list> </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <property name="Uid" type="t" access="read"> <doc:doc> <doc:description> <doc:para> The uid of the user. </doc:para> </doc:description> </doc:doc> </property> <property name="UserName" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The username of the user. </doc:para> </doc:description> </doc:doc> </property> <property name="RealName" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The users real name. </doc:para> </doc:description> </doc:doc> </property> <property name="AccountType" type="i" access="read"> <doc:doc> <doc:description> <doc:para> The users account type, encoded as an integer: <doc:list> <doc:item> <doc:term>0</doc:term> <doc:definition>Standard user</doc:definition> </doc:item> <doc:item> <doc:term>1</doc:term> <doc:definition>Administrator</doc:definition> </doc:item> </doc:list> </doc:para> </doc:description> </doc:doc> </property> <property name="HomeDirectory" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The users home directory. </doc:para> </doc:description> </doc:doc> </property> <property name="Shell" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The users shell. </doc:para> </doc:description> </doc:doc> </property> <property name="Email" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The email address. </doc:para> </doc:description> </doc:doc> </property> <property name="Language" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The users language, as a locale specification like "de_DE.UTF-8". </doc:para> </doc:description> </doc:doc> </property> <property name="XSession" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The users x session. </doc:para> </doc:description> </doc:doc> </property> <property name="Location" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The users location. </doc:para> </doc:description> </doc:doc> </property> <property name="LoginFrequency" type="t" access="read"> <doc:doc> <doc:description> <doc:para> How often the user has logged in. </doc:para> </doc:description> </doc:doc> </property> <property name="LoginTime" type="x" access="read"> <doc:doc> <doc:description> <doc:para> The last login time. </doc:para> </doc:description> </doc:doc> </property> <!-- <property name="LoginHistory" type="a(xxa{sv})" access="read"> <doc:doc> <doc:description> <doc:para> The login history for this user. Each entry in the array represents a login session. The first two members are the login time and logout time, as timestamps (seconds since the epoch). If the session is still running, the logout time is 0. </doc:para> <doc:para> The a{sv} member is a dictionary containing additional information about the session. Possible members include 'type' (with values like ':0', 'tty0', 'pts/0' etc). </doc:para> </doc:description> </doc:doc> </property> --> <property name="IconFile" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The filename of a png file containing the users icon. </doc:para> </doc:description> </doc:doc> </property> <property name="Locked" type="b" access="read"> <doc:doc> <doc:description> <doc:para> Whether the users account is locked. </doc:para> </doc:description> </doc:doc> </property> <property name="PasswordMode" type="i" access="read"> <doc:doc> <doc:description> <doc:para> The password mode for the user account, encoded as an integer: <doc:list> <doc:item> <doc:term>0</doc:term> <doc:definition>Regular password</doc:definition> </doc:item> <doc:item> <doc:term>1</doc:term> <doc:definition>Password must be set at next login</doc:definition> </doc:item> <doc:item> <doc:term>2</doc:term> <doc:definition>No password</doc:definition> </doc:item> </doc:list> </doc:para> </doc:description> </doc:doc> </property> <property name="PasswordHint" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The password hint for the user. </doc:para> </doc:description> </doc:doc> </property> <property name="AutomaticLogin" type="b" access="read"> <doc:doc> <doc:description> <doc:para> Whether automatic login is enabled for the user. </doc:para> </doc:description> </doc:doc> </property> <property name="SystemAccount" type="b" access="read"> <doc:doc> <doc:description> <doc:para> Whether this is a 'system' account, like 'root' or 'nobody'. System accounts should normally not appear in lists of users, and ListCachedUsers will not include such accounts. </doc:para> </doc:description> </doc:doc> </property> <property name="LocalAccount" type="b" access="read"> <doc:doc> <doc:description> <doc:para> Whether the user is a local account or not. </doc:para> </doc:description> </doc:doc> </property> <signal name="Changed"> <doc:doc> <doc:description> <doc:para> Emitted when the user is changed. </doc:para> </doc:description> </doc:doc> </signal> </interface> </node> 0707010000002F000081A40000000000000000000000016208D08F000021F7000000000000000000000000000000000000005C00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/org.freedesktop.Accounts.xml<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd" > <node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> <interface name="org.freedesktop.Accounts"> <!-- ************************************************************ --> <method name="ListCachedUsers"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="users" direction="out" type="ao"> <doc:doc><doc:summary>Object paths of cached users</doc:summary></doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Lists users which have logged into the system locally before. This is not meant to return an exhaustive list of all users. It is possible for <doc:ref type="method" to="Accounts.FindUserByName">FindUserByName()</doc:ref> to return a user that's not on the list. </doc:para> </doc:description> </doc:doc> </method> <method name="FindUserById"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="id" direction="in" type="x"> <doc:doc><doc:summary>The uid to look up</doc:summary></doc:doc> </arg> <arg name="user" direction="out" type="o"> <doc:doc><doc:summary>Object path of user</doc:summary></doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Finds a user by uid. </doc:para> </doc:description> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.Failed">if no user with the given uid exists</doc:error> </doc:errors> </doc:doc> </method> <method name="FindUserByName"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="name" direction="in" type="s"> <doc:doc><doc:summary>The username to look up</doc:summary></doc:doc> </arg> <arg name="user" direction="out" type="o"> <doc:doc><doc:summary>Object path of user</doc:summary></doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Finds a user by its username. </doc:para> </doc:description> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.Failed">if no user with the given username exists</doc:error> </doc:errors> </doc:doc> </method> <method name="CreateUser"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="name" direction="in" type="s"> <doc:doc><doc:summary>The username for the new user</doc:summary></doc:doc> </arg> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="fullname" direction="in" type="s"> <doc:doc><doc:summary>The real name for the new user</doc:summary></doc:doc> </arg> <arg name="user" direction="out" type="o"> <doc:doc><doc:summary>Object path of the new user</doc:summary></doc:doc> </arg> <arg name="accountType" direction="in" type="i"> <doc:doc> <doc:summary>The account type, encoded as an integer</doc:summary> </doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Creates a new user account. </doc:para> <doc:para> The accountType argument can take the following values: </doc:para> <doc:list> <doc:item> <doc:term>0</doc:term> <doc:definition>Standard user</doc:definition> </doc:item> <doc:item> <doc:term>1</doc:term> <doc:definition>Administrator</doc:definition> </doc:item> </doc:list> </doc:description> <doc:permission> The caller needs the org.freedesktop.accounts.user-administration PolicyKit authorization. </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <method name="CacheUser"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="name" direction="in" type="s"> <doc:doc><doc:summary>The username for the user</doc:summary></doc:doc> </arg> <arg name="user" direction="out" type="o"> <doc:doc><doc:summary>Object path of user</doc:summary></doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Caches a user account, so that it shows up in ListCachedUsers() output. The user name may be a remote user, but the system must be able to lookup the user name and resolve the user information. </doc:para> </doc:description> <doc:permission> The caller needs the org.freedesktop.accounts.user-administration PolicyKit authorization. </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.UserDoesNotExist">if the user name cannot be resolved</doc:error> </doc:errors> </doc:doc> </method> <method name="UncacheUser"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="name" direction="in" type="s"> <doc:doc><doc:summary>The username for the user</doc:summary></doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Releases all metadata about a user account, including icon, language and session. If the user account is from a remote server and the user has never logged in before, then that account will no longer show up in ListCachedUsers() output. </doc:para> </doc:description> <doc:permission> The caller needs the org.freedesktop.accounts.user-administration PolicyKit authorization. </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.UserDoesNotExist">if the user name cannot be resolved</doc:error> </doc:errors> </doc:doc> </method> <method name="DeleteUser"> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <arg name="id" direction="in" type="x"> <doc:doc><doc:summary>The uid to delete</doc:summary></doc:doc> </arg> <arg name="removeFiles" direction="in" type="b"> <doc:doc><doc:summary>Whether to remove the users files</doc:summary></doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Deletes a user account. </doc:para> </doc:description> <doc:permission> The caller needs the org.freedesktop.accounts.user-administration PolicyKit authorization. </doc:permission> <doc:errors> <doc:error name="org.freedesktop.Accounts.Error.PermissionDenied">if the caller lacks the appropriate PolicyKit authorization</doc:error> <doc:error name="org.freedesktop.Accounts.Error.Failed">if the operation failed</doc:error> </doc:errors> </doc:doc> </method> <signal name="UserAdded"> <arg name="user" type="o"> <doc:doc><doc:summary>Object path of the user that was added.</doc:summary></doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Emitted when a user is added. </doc:para> </doc:description> </doc:doc> </signal> <signal name="UserDeleted"> <arg name="user" type="o"> <doc:doc><doc:summary>Object path of the user that was deleted.</doc:summary></doc:doc> </arg> <doc:doc> <doc:description> <doc:para> Emitted when a user is deleted. </doc:para> </doc:description> </doc:doc> </signal> <property name="DaemonVersion" type="s" access="read"> <doc:doc> <doc:description> <doc:para> The version of the running daemon. </doc:para> </doc:description> </doc:doc> </property> </interface> </node> 07070100000030000081A40000000000000000000000016208D08F000004DA000000000000000000000000000000000000005900000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/qtaccountsserviceglobal.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #pragma once #include <QtCore/qglobal.h> #if defined(QT_BUILD_QTACCOUNTSSERVICE_LIB) #define Q_ACCOUNTS_SERVICE_EXPORT Q_DECL_EXPORT #else #define Q_ACCOUNTS_SERVICE_EXPORT Q_DECL_IMPORT #endif #define Q_ACCOUNTS_SERVICE_NO_EXPORT Q_DECL_HIDDEN 07070100000031000081A40000000000000000000000016208D08F00003A20000000000000000000000000000000000000004F00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/useraccount.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include "useraccount.h" #include "useraccount_p.h" #include <sys/types.h> #include <unistd.h> #include <pwd.h> namespace QtAccountsService { /* * UserAccountPrivate */ UserAccountPrivate::UserAccountPrivate(UserAccount *q) : bus(QDBusConnection::systemBus()) , user(nullptr) , accountType(UserAccount::StandardAccountType) , locked(false) , automaticLogin(false) , passwordMode(UserAccount::NonePasswordMode) , q_ptr(q) { } void UserAccountPrivate::initialize(const QDBusConnection &connection, const QString &objectPath) { Q_Q(UserAccount); bus = connection; if (user) { q->disconnect(user, &OrgFreedesktopAccountsUserInterface::Changed, q, &UserAccount::handleAccountChanged); user = nullptr; } user = new OrgFreedesktopAccountsUserInterface(QStringLiteral("org.freedesktop.Accounts"), objectPath, bus, q); q->connect(user, &OrgFreedesktopAccountsUserInterface::Changed, q, &UserAccount::handleAccountChanged); emitSignals(); } void UserAccountPrivate::emitSignals() { Q_Q(UserAccount); Q_EMIT q->userIdChanged(); Q_EMIT q->groupIdChanged(); Q_EMIT q->accountTypeChanged(); Q_EMIT q->lockedChanged(); Q_EMIT q->automaticLoginChanged(); Q_EMIT q->passwordModeChanged(); Q_EMIT q->userNameChanged(); Q_EMIT q->realNameChanged(); Q_EMIT q->displayNameChanged(); Q_EMIT q->homeDirectoryChanged(); Q_EMIT q->shellChanged(); Q_EMIT q->iconFileNameChanged(); Q_EMIT q->emailChanged(); Q_EMIT q->languageChanged(); Q_EMIT q->locationChanged(); Q_EMIT q->xsessionChanged(); } /*! \class UserAcccount \brief The UserAccount class describes user accounts. This class describes user accounts retrieved with AccountsManager. \author Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> \sa AccountsManager */ /*! Constructs a UserAccount object for the currently logged in user. */ UserAccount::UserAccount(const QDBusConnection &bus, QObject *parent) : QObject(parent) , d_ptr(new UserAccountPrivate(this)) { Q_D(UserAccount); QString objectPath = QStringLiteral("/org/freedesktop/Accounts/User") + QString::number(getuid()); d->initialize(bus, objectPath); } /*! \internal Constructs a UserAccount object from a specific objectPath in the form of /org/freedesktop/Accounts/UserUID where UID is user's uid. \param objectPath Accounts Service object path for the user account. */ UserAccount::UserAccount(const QString &objectPath, const QDBusConnection &bus, QObject *parent) : QObject(parent) , d_ptr(new UserAccountPrivate(this)) { Q_D(UserAccount); d->initialize(bus, objectPath); } /*! Returns the user identifier. */ qlonglong UserAccount::userId() const { Q_D(const UserAccount); return d->user->uid(); } /*! Change the user identifier to \c uid. The object will hold information for the requested user identifier. */ void UserAccount::setUserId(qlonglong uid) { Q_D(UserAccount); QString objectPath = QStringLiteral("/org/freedesktop/Accounts/User") + QString::number(uid); d->initialize(d->bus, objectPath); } /*! Returns group identifier. */ qlonglong UserAccount::groupId() const { Q_D(const UserAccount); size_t bufSize = 0; long sizeMax = ::sysconf(_SC_GETPW_R_SIZE_MAX); if (sizeMax <= 0) bufSize = 16384; else bufSize = static_cast<size_t>(sizeMax); char *buf = static_cast<char *>(::malloc(bufSize)); if (!buf) qFatal("Cannot allocate %lu bytes: %s", static_cast<long>(bufSize), strerror(errno)); struct passwd pwd; struct passwd *result; int s = ::getpwuid_r(d->user->uid(), &pwd, buf, bufSize, &result); if (!result) { if (s == 0) qCritical("User with uid %lld not found", d->user->uid()); else qCritical("Failed to get group information: %s", strerror(s)); return 0; } return pwd.pw_gid; } /*! Returns the account type. */ UserAccount::AccountType UserAccount::accountType() const { Q_D(const UserAccount); return static_cast<UserAccount::AccountType>(d->user->accountType()); } /*! Sets the account type to \a type. \param type Account type. */ void UserAccount::setAccountType(AccountType type) { Q_D(UserAccount); if (type == accountType()) return; d->accountType = type; d->user->SetAccountType(static_cast<int>(type)); Q_EMIT accountTypeChanged(); } /*! Returns whether this account is locked or not. */ bool UserAccount::isLocked() const { Q_D(const UserAccount); return d->user->locked(); } /*! Locks or unlocks the user account. Locking an account prevents the user from logging in. \param locked Whether to lock or unlock the user account. */ void UserAccount::setLocked(bool locked) { Q_D(UserAccount); if (isLocked() == locked) return; d->locked = locked; d->user->SetLocked(locked); Q_EMIT lockedChanged(); } /*! Returns whether the user account will automatically log in when the system starts up. */ bool UserAccount::automaticLogin() const { Q_D(const UserAccount); return d->user->automaticLogin(); } /*! Sets whether the user account will automatically log in when the system starts up. \param automaticLogin Whether automatic login is enabled for the user. */ void UserAccount::setAutomaticLogin(bool automaticLogin) { Q_D(UserAccount); if (this->automaticLogin() == automaticLogin) return; d->automaticLogin = automaticLogin; d->user->SetAutomaticLogin(automaticLogin); Q_EMIT automaticLoginChanged(); } /*! Returns how often the user has logged in. */ qlonglong UserAccount::loginFrequency() const { Q_D(const UserAccount); return d->user->loginFrequency(); } /*! Returns the last login time. */ qlonglong UserAccount::loginTime() const { Q_D(const UserAccount); return d->user->loginTime(); } /*! Returns the password mode for the user account. */ UserAccount::PasswordMode UserAccount::passwordMode() const { Q_D(const UserAccount); return static_cast<UserAccount::PasswordMode>(d->user->passwordMode()); } /*! Sets the password mode for the user account. \param mode Password mode. */ void UserAccount::setPasswordMode(UserAccount::PasswordMode mode) { Q_D(UserAccount); if (passwordMode() == mode) return; d->passwordMode = mode; d->user->SetPasswordMode(static_cast<int>(mode)); Q_EMIT passwordModeChanged(); } /*! Returns the password hint for the user. */ QString UserAccount::passwordHint() const { Q_D(const UserAccount); return d->user->passwordHint(); } /*! Returns whether the user is a local account or not. */ bool UserAccount::isLocalAccount() const { Q_D(const UserAccount); return d->user->localAccount(); } /*! Returns whether the user is a system account or not. */ bool UserAccount::isSystemAccount() const { Q_D(const UserAccount); return d->user->systemAccount(); } /*! Returns the user name. */ QString UserAccount::userName() const { Q_D(const UserAccount); return d->user->userName(); } /*! Sets the user name to \a userName. \param userName The new user name. */ void UserAccount::setUserName(const QString &userName) { Q_D(UserAccount); if (this->userName() == userName) return; d->userName = userName; d->user->SetUserName(userName); Q_EMIT userNameChanged(); Q_EMIT displayNameChanged(); } /*! Returns user's real name. */ QString UserAccount::realName() const { Q_D(const UserAccount); return d->user->realName(); } /*! Sets the user's real name to \a realName. \param realName Real name. */ void UserAccount::setRealName(const QString &realName) { Q_D(UserAccount); if (this->realName() == realName) return; d->realName = realName; d->user->SetRealName(realName); Q_EMIT realNameChanged(); Q_EMIT displayNameChanged(); } /*! Returns user's real name if not empty, otherwise the user name. */ QString UserAccount::displayName() const { if (realName().isEmpty()) return userName(); return realName(); } /*! Returns the home directory absolute path. */ QString UserAccount::homeDirectory() const { Q_D(const UserAccount); return d->user->homeDirectory(); } /*! Sets the home directory to \a homeDirectory. \param homeDirectory Home directory. */ void UserAccount::setHomeDirectory(const QString &homeDirectory) { Q_D(UserAccount); if (this->homeDirectory() == homeDirectory) return; d->user->SetHomeDirectory(homeDirectory); Q_EMIT homeDirectoryChanged(); } /*! Returns the login shell absolute path. */ QString UserAccount::shell() const { Q_D(const UserAccount); return d->user->shell(); } /*! Sets the login shell to \a shell. \param shell Login shell absolute path. */ void UserAccount::setShell(const QString &shell) { Q_D(UserAccount); if (this->shell() == shell) return; d->shell = shell; d->user->SetShell(shell); Q_EMIT shellChanged(); } /*! Returns user's picture absoulte path. */ QString UserAccount::iconFileName() const { Q_D(const UserAccount); return QFile::exists(d->user->iconFile()) ? d->user->iconFile() : QString(); } /*! Sets users' picture absolute path to \a fileName. \param fileName Picture absolute path. */ void UserAccount::setIconFileName(const QString &fileName) { Q_D(UserAccount); if (iconFileName() == fileName) return; d->iconFileName = fileName; d->user->SetIconFile(fileName); Q_EMIT iconFileNameChanged(); } /*! Returns user's email address. */ QString UserAccount::email() const { Q_D(const UserAccount); return d->user->email(); } /*! Sets user's email address to \a email. \param email Email address. */ void UserAccount::setEmail(const QString &email) { Q_D(UserAccount); if (this->email() == email) return; d->email = email; d->user->SetEmail(email); Q_EMIT emailChanged(); } /*! Returns user language. */ QString UserAccount::language() const { Q_D(const UserAccount); return d->user->language(); } /*! Sets user language to \a language. \param language Language. */ void UserAccount::setLanguage(const QString &language) { Q_D(UserAccount); if (this->language() == language) return; d->language = language; d->user->SetLanguage(language); Q_EMIT languageChanged(); } /*! Returns user location. */ QString UserAccount::location() const { Q_D(const UserAccount); return d->user->location(); } /*! Sets user \a location. \param location Location. */ void UserAccount::setLocation(const QString &location) { Q_D(UserAccount); if (this->location() == location) return; d->location = location; d->user->SetLocation(location); Q_EMIT locationChanged(); } /*! Returns the X11 session for the user account. */ QString UserAccount::xsession() const { Q_D(const UserAccount); return d->user->xSession(); } /*! Sets the X11 session for the user account. \param session X11 session name. */ void UserAccount::setXSession(const QString &session) { Q_D(UserAccount); if (xsession() == session) return; d->xsession = session; d->user->SetXSession(session); Q_EMIT xsessionChanged(); } /*! Sets the password for the user account. \param password. \param hint passwordHint. */ void UserAccount::setPassword(const QString &password, const QString &hint) { Q_D(UserAccount); d->user->SetPassword(password, hint); } /*! Sets the password hint for the user account. \param hint Password hint. */ void UserAccount::setPasswordHint(const QString &hint) { Q_D(UserAccount); d->user->SetPasswordHint(hint); } /*! \internal */ void UserAccount::handleAccountChanged() { // Catch changes outside of this API Q_D(UserAccount); if (d->accountType != accountType()) { d->accountType = accountType(); Q_EMIT accountTypeChanged(); } if (d->locked != isLocked()) { d->locked = isLocked(); Q_EMIT lockedChanged(); } if (d->automaticLogin != automaticLogin()) { d->automaticLogin = automaticLogin(); Q_EMIT automaticLoginChanged(); } if (d->passwordMode != passwordMode()) { d->passwordMode = passwordMode(); Q_EMIT passwordModeChanged(); } if (d->userName != userName()) { d->userName = userName(); Q_EMIT userNameChanged(); Q_EMIT displayNameChanged(); } if (d->realName != realName()) { d->realName = realName(); Q_EMIT realNameChanged(); Q_EMIT displayNameChanged(); } if (d->homeDirectory != homeDirectory()) { d->homeDirectory = homeDirectory(); Q_EMIT homeDirectoryChanged(); } if (d->shell != shell()) { d->shell = shell(); Q_EMIT shellChanged(); } if (d->iconFileName != iconFileName()) { d->iconFileName = iconFileName(); Q_EMIT iconFileNameChanged(); } if (d->email != email()) { d->email = email(); Q_EMIT emailChanged(); } if (d->language != language()) { d->language = language(); Q_EMIT languageChanged(); } if (d->location != location()) { d->location = location(); Q_EMIT locationChanged(); } if (d->xsession != xsession()) { d->xsession = xsession(); Q_EMIT xsessionChanged(); } } } #include "moc_useraccount.cpp" 07070100000032000081A40000000000000000000000016208D08F00001786000000000000000000000000000000000000004D00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/useraccount.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #ifndef QTACCOUNTSSERVICE_USERACCOUNT_H #define QTACCOUNTSSERVICE_USERACCOUNT_H #include <QtCore/QObject> #include <QtCore/QString> #include <QtDBus/QDBusConnection> #include <Qt5AccountsService/qt5accountsserviceglobal.h> namespace QtAccountsService { class AccountsManager; class AccountsManagerPrivate; class UserAccountPrivate; class QT5ACCOUNTSSERVICE_EXPORT UserAccount : public QObject { Q_OBJECT Q_PROPERTY(qlonglong userId READ userId WRITE setUserId NOTIFY userIdChanged) Q_PROPERTY(qlonglong groupId READ groupId NOTIFY groupIdChanged) Q_PROPERTY( AccountType accountType READ accountType WRITE setAccountType NOTIFY accountTypeChanged) Q_PROPERTY(bool locked READ isLocked WRITE setLocked NOTIFY lockedChanged) Q_PROPERTY(bool automaticLogin READ automaticLogin WRITE setAutomaticLogin NOTIFY automaticLoginChanged) Q_PROPERTY(qlonglong loginFrequency READ loginFrequency CONSTANT) Q_PROPERTY(qlonglong loginTime READ loginTime CONSTANT) Q_PROPERTY(PasswordMode passwordMode READ passwordMode WRITE setPasswordMode NOTIFY passwordModeChanged) Q_PROPERTY(QString passwordHint READ passwordHint CONSTANT) Q_PROPERTY(bool localAccount READ isLocalAccount CONSTANT) Q_PROPERTY(bool systemAccount READ isSystemAccount CONSTANT) Q_PROPERTY(QString userName READ userName WRITE setUserName NOTIFY userNameChanged) Q_PROPERTY(QString realName READ realName WRITE setRealName NOTIFY realNameChanged) Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged) Q_PROPERTY( QString homeDirectory READ homeDirectory WRITE setHomeDirectory NOTIFY homeDirectoryChanged) Q_PROPERTY(QString shell READ shell WRITE setShell NOTIFY shellChanged) Q_PROPERTY( QString iconFileName READ iconFileName WRITE setIconFileName NOTIFY iconFileNameChanged) Q_PROPERTY(QString email READ email WRITE setEmail NOTIFY emailChanged) Q_PROPERTY(QString language READ language WRITE setLanguage NOTIFY languageChanged) Q_PROPERTY(QString location READ location WRITE setLocation NOTIFY locationChanged) Q_PROPERTY(QString xsession READ xsession WRITE setXSession NOTIFY xsessionChanged) Q_DECLARE_PRIVATE(UserAccount) public: enum AccountType { StandardAccountType = 0, AdministratorAccountType }; Q_ENUM(AccountType) enum PasswordMode { RegularPasswordMode = 0, SetAtLoginPasswordMode, NonePasswordMode }; Q_ENUM(PasswordMode) UserAccount(const QDBusConnection &bus = QDBusConnection::systemBus(), QObject *parent = nullptr); qlonglong userId() const; void setUserId(qlonglong uid); qlonglong groupId() const; AccountType accountType() const; void setAccountType(AccountType type); bool isLocked() const; void setLocked(bool locked); bool automaticLogin() const; void setAutomaticLogin(bool automaticLogin); qlonglong loginFrequency() const; qlonglong loginTime() const; PasswordMode passwordMode() const; void setPasswordMode(PasswordMode mode); QString passwordHint() const; bool isLocalAccount() const; bool isSystemAccount() const; QString userName() const; void setUserName(const QString &userName); QString realName() const; void setRealName(const QString &realName); QString displayName() const; QString homeDirectory() const; void setHomeDirectory(const QString &homeDirectory); QString shell() const; void setShell(const QString &shell); QString iconFileName() const; void setIconFileName(const QString &fileName); QString email() const; void setEmail(const QString &email); QString language() const; void setLanguage(const QString &language); QString location() const; void setLocation(const QString &location); QString xsession() const; void setXSession(const QString &session); Q_INVOKABLE void setPassword(const QString &password, const QString &hint = QString()); Q_INVOKABLE void setPasswordHint(const QString &hint); Q_SIGNALS: void accountChanged(); void userIdChanged(); void groupIdChanged(); void accountTypeChanged(); void lockedChanged(); void automaticLoginChanged(); void passwordModeChanged(); void userNameChanged(); void realNameChanged(); void displayNameChanged(); void homeDirectoryChanged(); void shellChanged(); void iconFileNameChanged(); void emailChanged(); void languageChanged(); void locationChanged(); void xsessionChanged(); private: friend class AccountsManager; friend class AccountsManagerPrivate; UserAccountPrivate *const d_ptr; UserAccount(const QString &objectPath, const QDBusConnection &bus = QDBusConnection::systemBus(), QObject *parent = nullptr); private Q_SLOTS: void handleAccountChanged(); }; typedef QList<UserAccount *> UserAccountList; } #endif // QTACCOUNTSSERVICE_USERACCOUNT_H 07070100000033000081A40000000000000000000000016208D08F00000885000000000000000000000000000000000000004F00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/useraccount_p.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #ifndef QTACCOUNTSSERVICE_USERACCOUNT_P_H #define QTACCOUNTSSERVICE_USERACCOUNT_P_H #include "useraccount.h" #include "user_interface.h" // // W A R N I N G // ------------- // // This file is not part of the Qt AccountsService API. It exists // purely as an implementation detail. This header file may change from // version to version without notice, or even be removed. // // We mean it. // namespace QtAccountsService { class UserAccountPrivate { Q_DECLARE_PUBLIC(UserAccount) Q_DISABLE_COPY(UserAccountPrivate) public: explicit UserAccountPrivate(UserAccount *q); void initialize(const QDBusConnection &connection, const QString &objectPath); void emitSignals(); QDBusConnection bus; OrgFreedesktopAccountsUserInterface *user; UserAccount::AccountType accountType; bool locked; bool automaticLogin; UserAccount::PasswordMode passwordMode; QString userName; QString realName; QString homeDirectory; QString shell; QString iconFileName; QString email; QString language; QString location; QString xsession; protected: UserAccount *q_ptr; }; } #endif // QTACCOUNTSSERVICE_USERACCOUNT_P_H 07070100000034000081A40000000000000000000000016208D08F000019EE000000000000000000000000000000000000004E00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/usersmodel.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtGui/QPixmap> #include "usersmodel.h" #include "usersmodel_p.h" namespace QtAccountsService { /* * UsersModelPrivate */ UsersModelPrivate::UsersModelPrivate(UsersModel *q) : manager(new AccountsManager()) , q_ptr(q) { } UsersModelPrivate::~UsersModelPrivate() { delete manager; } void UsersModelPrivate::_q_userAdded(UserAccount *account) { Q_Q(UsersModel); q->connect(account, &UserAccount::accountChanged, q, [account, q, this]() { auto index = q->index(list.indexOf(account)); if (index.isValid()) Q_EMIT q->dataChanged(index, index); }); q->beginInsertRows(QModelIndex(), list.size(), list.size()); list.append(account); q->endInsertRows(); } void UsersModelPrivate::_q_userDeleted(qlonglong uid) { Q_Q(UsersModel); for (int i = 0; i < list.size(); i++) { UserAccount *curAccount = list.at(i); if (curAccount->userId() == uid) { q->beginRemoveRows(QModelIndex(), i, i); list.removeOne(curAccount); q->endRemoveRows(); break; } } } /* * UsersModel */ UsersModel::UsersModel(QObject *parent) : QAbstractListModel(parent) , d_ptr(new UsersModelPrivate(this)) { Q_D(UsersModel); connect(d->manager, SIGNAL(userAdded(UserAccount *)), // clazy:exclude=old-style-connect this, SLOT(_q_userAdded(UserAccount *))); connect(d->manager, SIGNAL(userDeleted(qlonglong)), // clazy:exclude=old-style-connect this, SLOT(_q_userDeleted(qlonglong))); connect(d->manager, &AccountsManager::listCachedUsersFinished, this, [d](const UserAccountList &list) { for (auto account : list) d->_q_userAdded(account); }); d->manager->listCachedUsers(); } QHash<int, QByteArray> UsersModel::roleNames() const { QHash<int, QByteArray> roles = QAbstractItemModel::roleNames(); roles[UserAccountRole] = "userAccount"; roles[UserIdRole] = "userId"; roles[AccountTypeRole] = "accountType"; roles[LockedRole] = "locked"; roles[AutomaticLoginRole] = "automaticLogin"; roles[LoginFrequencyRole] = "loginFrequency"; roles[LoginTimeRole] = "loginTime"; roles[PasswordModeRole] = "passwordMode"; roles[PasswordHintRole] = "passwordHint"; roles[LocalAccount] = "localAccount"; roles[SystemAccount] = "systemAccount"; roles[UserNameRole] = "userName"; roles[RealNameRole] = "realName"; roles[DisplayNameRole] = "displayNameRole"; roles[HomeDirectoryRole] = "homeDirectory"; roles[ShellRole] = "shell"; roles[IconFileNameRole] = "iconFileName"; roles[LanguageRole] = "language"; roles[EmailRole] = "email"; roles[LocationRole] = "location"; roles[XSessionRole] = "xsession"; return roles; } int UsersModel::rowCount(const QModelIndex &parent) const { Q_D(const UsersModel); if (parent == QModelIndex()) return d->list.size(); return 0; } QVariant UsersModel::data(const QModelIndex &index, int role) const { UserAccount *user = userAccount(index); if (!user) return QVariant(); switch (role) { case Qt::DisplayRole: case DisplayNameRole: return user->displayName(); case Qt::DecorationRole: return QPixmap(user->iconFileName()); case UserAccountRole: return QVariant::fromValue(user); case UserIdRole: return user->userId(); case AccountTypeRole: return user->accountType(); case LockedRole: return user->isLocked(); case AutomaticLoginRole: return user->automaticLogin(); case LoginFrequencyRole: return user->loginFrequency(); case LoginTimeRole: return user->loginTime(); case PasswordModeRole: return user->passwordMode(); case PasswordHintRole: return user->passwordHint(); case LocalAccount: return user->isLocalAccount(); case SystemAccount: return user->isSystemAccount(); case UserNameRole: return user->userName(); case RealNameRole: return user->realName(); case HomeDirectoryRole: return user->homeDirectory(); case ShellRole: return user->shell(); case IconFileNameRole: return user->iconFileName(); case EmailRole: return user->email(); case LanguageRole: return user->language(); case LocationRole: return user->location(); case XSessionRole: return user->xsession(); default: break; } return QVariant(); } bool UsersModel::setData(const QModelIndex &index, const QVariant &value, int role) { UserAccount *user = userAccount(index); if (!user) return false; switch (role) { case UsersModel::UserNameRole: user->setUserName(value.toString()); break; case UsersModel::RealNameRole: user->setRealName(value.toString()); break; case UsersModel::IconFileNameRole: user->setIconFileName(value.toString()); break; case UsersModel::AccountTypeRole: user->setAccountType((UserAccount::AccountType)value.toInt()); break; case UsersModel::LanguageRole: user->setLanguage(value.toString()); break; default: return false; } return true; } UserAccount *UsersModel::userAccount(const QModelIndex &index) const { Q_D(const UsersModel); if (!index.isValid()) return nullptr; if (index.row() >= d->list.size()) return nullptr; return d->list[index.row()]; } } #include "moc_usersmodel.cpp" 07070100000035000081A40000000000000000000000016208D08F000009CD000000000000000000000000000000000000004C00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/usersmodel.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #ifndef QTACCOUNTSSERVICE_USERSMODEL_H #define QTACCOUNTSSERVICE_USERSMODEL_H #include <QtCore/QAbstractListModel> #include <Qt5AccountsService/qt5accountsserviceglobal.h> namespace QtAccountsService { class UserAccount; class UsersModelPrivate; class QT5ACCOUNTSSERVICE_EXPORT UsersModel : public QAbstractListModel { Q_OBJECT Q_DECLARE_PRIVATE(UsersModel) public: enum Roles { UserAccountRole = Qt::UserRole + 1, UserIdRole, AccountTypeRole, LockedRole, AutomaticLoginRole, LoginFrequencyRole, LoginTimeRole, PasswordModeRole, PasswordHintRole, LocalAccount, SystemAccount, UserNameRole, RealNameRole, DisplayNameRole, HomeDirectoryRole, ShellRole, IconFileNameRole, EmailRole, LanguageRole, LocationRole, XSessionRole }; Q_ENUM(Roles) explicit UsersModel(QObject *parent = nullptr); QHash<int, QByteArray> roleNames() const; int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role) const; bool setData(const QModelIndex &index, const QVariant &value, int role); UserAccount *userAccount(const QModelIndex &index) const; private: UsersModelPrivate *const d_ptr; Q_PRIVATE_SLOT(d_func(), void _q_userAdded(UserAccount *account)) Q_PRIVATE_SLOT(d_func(), void _q_userDeleted(qlonglong uid)) }; } #endif // QTACCOUNTSSERVICE_USERSMODEL_H 07070100000036000081A40000000000000000000000016208D08F00000753000000000000000000000000000000000000004E00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/accountsservice/usersmodel_p.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #ifndef QTACCOUNTSSERVICE_USERSMODEL_P_H #define QTACCOUNTSSERVICE_USERSMODEL_P_H #include <Qt5AccountsService/AccountsManager> #include <Qt5AccountsService/UserAccount> // // W A R N I N G // ------------- // // This file is not part of the Qt AccountsService API. It exists // purely as an implementation detail. This header file may change from // version to version without notice, or even be removed. // // We mean it. // namespace QtAccountsService { class UsersModel; class UsersModelPrivate { Q_DECLARE_PUBLIC(UsersModel) public: UsersModelPrivate(UsersModel *q); ~UsersModelPrivate(); void populate(); AccountsManager *manager; UserAccountList list; public Q_SLOTS: void _q_userAdded(UserAccount *account); void _q_userDeleted(qlonglong uid); protected: UsersModel *q_ptr; }; } #endif // QTACCOUNTSSERVICE_USERSMODEL_P_H 07070100000037000081A40000000000000000000000016208D08F00000240000000000000000000000000000000000000003E00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/deployment.qbsimport qbs 1.0 Project { name: "Deployment" InstallPackage { name: "qtaccountsservice-artifacts" targetName: name builtByDefault: false archiver.type: "tar" archiver.outputDirectory: project.buildDirectory Depends { name: "Qt5AccountsService" } Depends { name: "Qt5AccountsService-cmake" } Depends { name: "Qt5AccountsService-pkgconfig" } Depends { name: "Qt5AccountsService-qbs" } Depends { name: "qtaccountsserviceplugin" } Depends { productTypes: ["installable"] } } } 07070100000038000041ED0000000000000000000000036208D08F00000000000000000000000000000000000000000000003700000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/imports07070100000039000041ED0000000000000000000000026208D08F00000000000000000000000000000000000000000000004700000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/imports/accountsservice0707010000003A000081A40000000000000000000000016208D08F0000014B000000000000000000000000000000000000005600000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/imports/accountsservice/CMakeLists.txtliri_add_qml_plugin(qtaccountsservice MODULE_PATH "QtAccountsService" VERSION "1.0" SOURCES main.cpp QML_FILES qmldir DEFINES QT_NO_CAST_FROM_ASCII QT_NO_FOREACH PUBLIC_LIBRARIES Liri::Qt5AccountsService ) liri_finalize_qml_plugin(qtaccountsservice) 0707010000003B000081A40000000000000000000000016208D08F000000C4000000000000000000000000000000000000005B00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/imports/accountsservice/accountsservice.qbsimport qbs 1.0 LiriQmlPlugin { name: "qtaccountsserviceplugin" pluginPath: "QtAccountsService" Depends { name: "Qt5AccountsService" } files: ["*.cpp", "qmldir", "*.qmltypes"] } 0707010000003C000081A40000000000000000000000016208D08F000007B2000000000000000000000000000000000000005000000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/imports/accountsservice/main.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtQml/qqmlextensionplugin.h> #include <QtQml/qqml.h> #include <QtQml/qqmlengine.h> #include <QtQml/qqmlcomponent.h> #include <Qt5AccountsService/AccountsManager> #include <Qt5AccountsService/UserAccount> #include <Qt5AccountsService/UsersModel> QT_BEGIN_NAMESPACE class QtAccountsServicePlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") public: QtAccountsServicePlugin(QObject *parent = nullptr) : QQmlExtensionPlugin(parent) { } void registerTypes(const char *uri) override { Q_ASSERT(QLatin1String(uri) == QLatin1String("QtAccountsService")); qmlRegisterType<QtAccountsService::AccountsManager>(uri, 1, 0, "AccountsManager"); qmlRegisterType<QtAccountsService::UserAccount>(uri, 1, 0, "UserAccount"); qmlRegisterType<QtAccountsService::UsersModel>(uri, 1, 0, "UsersModel"); } }; QT_END_NAMESPACE #include "main.moc" 0707010000003D000081A40000000000000000000000016208D08F000016DF000000000000000000000000000000000000005800000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/imports/accountsservice/plugins.qmltypesimport QtQuick.tooling 1.2 // This file describes the plugin-supplied types contained in the library. // It is used for QML tooling purposes only. // // This file was auto-generated by: // 'qmlplugindump-qt5 -noinstantiate -nonrelocatable QtAccountsService 1.0 /home/plfiorini/git/liri/lirios/.build/install-root/lib/qml' Module { dependencies: ["QtQuick 2.8"] Component { name: "QtAccountsService::AccountsManager" prototype: "QObject" exports: ["QtAccountsService/AccountsManager 1.0"] exportMetaObjectRevisions: [0] Signal { name: "userAdded" Parameter { name: "account"; type: "UserAccount"; isPointer: true } } Signal { name: "userDeleted" Parameter { name: "uid"; type: "qlonglong" } } Signal { name: "userCached" Parameter { name: "userName"; type: "string" } } Signal { name: "userUncached" Parameter { name: "userName"; type: "string" } } Signal { name: "listCachedUsersFinished" Parameter { name: "userList"; type: "UserAccountList" } } Method { name: "cacheUser" Parameter { name: "userName"; type: "string" } } Method { name: "uncacheUser" Parameter { name: "userName"; type: "string" } } Method { name: "listCachedUsers" } Method { name: "cachedUser" type: "UserAccount*" Parameter { name: "userName"; type: "string" } } Method { name: "findUserById" type: "UserAccount*" Parameter { name: "uid"; type: "qlonglong" } } Method { name: "findUserByName" type: "UserAccount*" Parameter { name: "userName"; type: "string" } } Method { name: "createUser" type: "bool" Parameter { name: "userName"; type: "string" } Parameter { name: "fullName"; type: "string" } Parameter { name: "accountType"; type: "UserAccount::AccountType" } } Method { name: "deleteUser" type: "bool" Parameter { name: "uid"; type: "qlonglong" } Parameter { name: "removeFiles"; type: "bool" } } } Component { name: "QtAccountsService::UserAccount" prototype: "QObject" exports: ["QtAccountsService/UserAccount 1.0"] exportMetaObjectRevisions: [0] Enum { name: "AccountType" values: { "StandardAccountType": 0, "AdministratorAccountType": 1 } } Enum { name: "PasswordMode" values: { "RegularPasswordMode": 0, "SetAtLoginPasswordMode": 1, "NonePasswordMode": 2 } } Property { name: "userId"; type: "qlonglong" } Property { name: "groupId"; type: "qlonglong"; isReadonly: true } Property { name: "accountType"; type: "AccountType" } Property { name: "locked"; type: "bool" } Property { name: "automaticLogin"; type: "bool" } Property { name: "loginFrequency"; type: "qlonglong"; isReadonly: true } Property { name: "loginTime"; type: "qlonglong"; isReadonly: true } Property { name: "passwordMode"; type: "PasswordMode" } Property { name: "passwordHint"; type: "string"; isReadonly: true } Property { name: "localAccount"; type: "bool"; isReadonly: true } Property { name: "systemAccount"; type: "bool"; isReadonly: true } Property { name: "userName"; type: "string" } Property { name: "realName"; type: "string" } Property { name: "displayName"; type: "string"; isReadonly: true } Property { name: "homeDirectory"; type: "string" } Property { name: "shell"; type: "string" } Property { name: "iconFileName"; type: "string" } Property { name: "email"; type: "string" } Property { name: "language"; type: "string" } Property { name: "location"; type: "string" } Property { name: "xsession"; type: "string" } Signal { name: "accountChanged" } Method { name: "setPassword" Parameter { name: "password"; type: "string" } Parameter { name: "hint"; type: "string" } } Method { name: "setPassword" Parameter { name: "password"; type: "string" } } Method { name: "setPasswordHint" Parameter { name: "hint"; type: "string" } } } Component { name: "QtAccountsService::UsersModel" prototype: "QAbstractListModel" exports: ["QtAccountsService/UsersModel 1.0"] exportMetaObjectRevisions: [0] Enum { name: "Roles" values: { "UserAccountRole": 257, "UserIdRole": 258, "AccountTypeRole": 259, "LockedRole": 260, "AutomaticLoginRole": 261, "LoginFrequencyRole": 262, "LoginTimeRole": 263, "PasswordModeRole": 264, "PasswordHintRole": 265, "LocalAccount": 266, "SystemAccount": 267, "UserNameRole": 268, "RealNameRole": 269, "DisplayNameRole": 270, "HomeDirectoryRole": 271, "ShellRole": 272, "IconFileNameRole": 273, "EmailRole": 274, "LanguageRole": 275, "LocationRole": 276, "XSessionRole": 277 } } } } 0707010000003E000081A40000000000000000000000016208D08F00000070000000000000000000000000000000000000004E00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/imports/accountsservice/qmldirmodule QtAccountsService plugin qtaccountsserviceplugin class QtAccountsServicePlugin typeinfo plugins.qmltypes 0707010000003F000081A40000000000000000000000016208D08F0000007C000000000000000000000000000000000000004300000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/src/imports/imports.qbsimport qbs 1.0 Project { name: "QML Plugins" references: [ "accountsservice/accountsservice.qbs", ] } 07070100000040000041ED0000000000000000000000036208D08F00000000000000000000000000000000000000000000003100000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests07070100000041000041ED0000000000000000000000036208D08F00000000000000000000000000000000000000000000003600000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto07070100000042000041ED0000000000000000000000026208D08F00000000000000000000000000000000000000000000003A00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/api07070100000043000081A40000000000000000000000016208D08F0000016F000000000000000000000000000000000000004900000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/api/CMakeLists.txtliri_add_test(tst_qtaccountsservice SOURCES fakeaccounts.cpp fakeaccounts.h fakeuser.cpp fakeuser.h tst_api.cpp DBUS_ADAPTOR_SOURCES ../../../src/accountsservice/org.freedesktop.Accounts.xml ../../../src/accountsservice/org.freedesktop.Accounts.User.xml LIBRARIES Liri::Qt5AccountsService ) 07070100000044000081A40000000000000000000000016208D08F000002C2000000000000000000000000000000000000004200000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/api/api.qbsimport qbs 1.0 QtApplication { name: "tst_qtaccountsservice" condition: project.autotestEnabled type: base.concat(["autotest"]) Depends { name: "Qt"; submodules: ["core", "dbus", "testlib"]; versionAtLeast: project.minimumQtVersion } Depends { name: "Qt5AccountsService" } files: [ "fakeaccounts.cpp", "fakeaccounts.h", "fakeuser.cpp", "fakeuser.h", "tst_api.cpp" ] Group { name: "D-Bus Interfaces" files: [ "../../../src/accountsservice/org.freedesktop.Accounts.xml", "../../../src/accountsservice/org.freedesktop.Accounts.User.xml" ] fileTags: ["qt.dbus.adaptor"] } } 07070100000045000081A40000000000000000000000016208D08F00000E2B000000000000000000000000000000000000004B00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/api/fakeaccounts.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtDBus/QDBusConnection> #include <QtDBus/QDBusError> #include "fakeaccounts.h" #include "user_adaptor.h" FakeAccounts::FakeAccounts(QObject *parent) : QObject(parent) , m_lastUid(1000) { QDBusConnection bus = QDBusConnection::sessionBus(); if (!bus.registerObject(QStringLiteral("/org/freedesktop/Accounts"), this)) qFatal("Unable to register object: %s", qPrintable(bus.lastError().message())); if (!bus.registerService(QStringLiteral("org.freedesktop.Accounts"))) qFatal("Unable to register service: %s", qPrintable(bus.lastError().message())); } FakeAccounts::~FakeAccounts() { qDeleteAll(m_users); } QString FakeAccounts::daemonVersion() const { return QStringLiteral("42"); } QDBusObjectPath FakeAccounts::CacheUser(const QString &name) { for (FakeUser *entry : qAsConst(m_users)) { if (entry->userName() == name) { entry->cached = true; return entry->path(); } } return QDBusObjectPath(); } void FakeAccounts::UncacheUser(const QString &name) { for (FakeUser *entry : qAsConst(m_users)) { if (entry->userName() == name) { entry->cached = false; return; } } } QList<QDBusObjectPath> FakeAccounts::ListCachedUsers() { QList<QDBusObjectPath> paths; for (FakeUser *entry : qAsConst(m_users)) { if (entry->cached) paths.append(entry->path()); } return paths; } QDBusObjectPath FakeAccounts::CreateUser(const QString &name, const QString &fullName, int accountType) { const QString path = QStringLiteral("/org/freedesktop/Accounts/User%1").arg(m_lastUid); FakeUser *entry = new FakeUser(path, m_lastUid, name, fullName, accountType, this); new UserAdaptor(entry); m_users.append(entry); m_lastUid++; return entry->path(); } void FakeAccounts::DeleteUser(qlonglong id, bool removeFiles) { Q_UNUSED(removeFiles); for (FakeUser *entry : qAsConst(m_users)) { if ((qlonglong)entry->uid() == id) { m_users.removeOne(entry); delete entry; return; } } } QDBusObjectPath FakeAccounts::FindUserById(qlonglong id) { for (FakeUser *entry : qAsConst(m_users)) { if ((qlonglong)entry->uid() == id) return entry->path(); } return QDBusObjectPath(); } QDBusObjectPath FakeAccounts::FindUserByName(const QString &name) { for (FakeUser *entry : qAsConst(m_users)) { if (entry->userName() == name) return entry->path(); } return QDBusObjectPath(); } 07070100000046000081A40000000000000000000000016208D08F0000078D000000000000000000000000000000000000004900000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/api/fakeaccounts.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #ifndef FAKEACCOUNTS_H #define FAKEACCOUNTS_H #include <QtCore/QObject> #include "fakeuser.h" class FakeAccounts : public QObject { Q_OBJECT Q_PROPERTY(QString DaemonVersion READ daemonVersion CONSTANT) public: FakeAccounts(QObject *parent = 0); ~FakeAccounts(); QString daemonVersion() const; public Q_SLOTS: QDBusObjectPath CacheUser(const QString &name); void UncacheUser(const QString &name); QList<QDBusObjectPath> ListCachedUsers(); QDBusObjectPath CreateUser(const QString &name, const QString &fullName, int accountType); void DeleteUser(qlonglong id, bool removeFiles); QDBusObjectPath FindUserById(qlonglong id); QDBusObjectPath FindUserByName(const QString &name); Q_SIGNALS: void UserAdded(const QDBusObjectPath &user); void UserDeleted(const QDBusObjectPath &user); private: qlonglong m_lastUid; QList<FakeUser *> m_users; }; #endif // FAKEACCOUNTS_H 07070100000047000081A40000000000000000000000016208D08F00001027000000000000000000000000000000000000004700000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/api/fakeuser.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtDBus/QDBusConnection> #include <QtDBus/QDBusError> #include "fakeuser.h" FakeUser::FakeUser(const QString &path, qlonglong uid, const QString &name, const QString &fullName, int accountType, QObject *parent) : QObject(parent) , cached(false) , m_uid(uid) , m_name(name) , m_fullName(fullName) , m_accountType(accountType) , m_path(QDBusObjectPath(path)) { QDBusConnection bus = QDBusConnection::sessionBus(); if (!bus.registerObject(path, this)) qFatal("Unable to register object: %s", qPrintable(bus.lastError().message())); } int FakeUser::accountType() const { return m_accountType; } bool FakeUser::automaticLogin() const { return false; } QString FakeUser::email() const { return QString(); } QString FakeUser::homeDirectory() const { return QString(); } QString FakeUser::iconFile() const { return QString(); } QString FakeUser::language() const { return QString(); } bool FakeUser::localAccount() const { return false; } QString FakeUser::location() const { return QString(); } bool FakeUser::locked() const { return false; } qulonglong FakeUser::loginFrequency() const { return 0; } qlonglong FakeUser::loginTime() const { return 0; } QString FakeUser::passwordHint() const { return QString(); } int FakeUser::passwordMode() const { return 0; } QString FakeUser::realName() const { return m_fullName; } QString FakeUser::shell() const { return QString(); } bool FakeUser::systemAccount() const { return false; } qulonglong FakeUser::uid() const { return m_uid; } QString FakeUser::userName() const { return m_name; } QString FakeUser::xSession() const { return QString(); } QDBusObjectPath FakeUser::path() const { return m_path; } void FakeUser::SetAccountType(int accountType) { if (m_accountType == accountType) return; m_accountType = accountType; Q_EMIT Changed(); } void FakeUser::SetAutomaticLogin(bool enabled) { Q_UNUSED(enabled); } void FakeUser::SetEmail(const QString &email) { Q_UNUSED(email); } void FakeUser::SetHomeDirectory(const QString &homedir) { Q_UNUSED(homedir); } void FakeUser::SetIconFile(const QString &filename) { Q_UNUSED(filename); } void FakeUser::SetLanguage(const QString &language) { Q_UNUSED(language); } void FakeUser::SetLocation(const QString &location) { Q_UNUSED(location); } void FakeUser::SetLocked(bool locked) { Q_UNUSED(locked); } void FakeUser::SetPassword(const QString &password, const QString &hint) { Q_UNUSED(password); Q_UNUSED(hint); } void FakeUser::SetPasswordMode(int mode) { Q_UNUSED(mode); } void FakeUser::SetRealName(const QString &name) { if (m_fullName == name) return; m_fullName = name; Q_EMIT Changed(); } void FakeUser::SetShell(const QString &shell) { Q_UNUSED(shell); } void FakeUser::SetUserName(const QString &name) { if (m_name == name) return; m_name = name; Q_EMIT Changed(); } void FakeUser::SetXSession(const QString &x_session) { Q_UNUSED(x_session); } 07070100000048000081A40000000000000000000000016208D08F00000F1B000000000000000000000000000000000000004500000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/api/fakeuser.h/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #ifndef FAKEUSER_H #define FAKEUSER_H #include <QtCore/QObject> #include <QtDBus/QDBusObjectPath> class FakeUser : public QObject { Q_OBJECT Q_PROPERTY(int AccountType READ accountType CONSTANT) Q_PROPERTY(bool AutomaticLogin READ automaticLogin CONSTANT) Q_PROPERTY(QString Email READ email CONSTANT) Q_PROPERTY(QString HomeDirectory READ homeDirectory CONSTANT) Q_PROPERTY(QString IconFile READ iconFile CONSTANT) Q_PROPERTY(QString Language READ language CONSTANT) Q_PROPERTY(bool LocalAccount READ localAccount CONSTANT) Q_PROPERTY(QString Location READ location CONSTANT) Q_PROPERTY(bool Locked READ locked CONSTANT) Q_PROPERTY(qulonglong LoginFrequency READ loginFrequency CONSTANT) Q_PROPERTY(qlonglong LoginTime READ loginTime CONSTANT) Q_PROPERTY(QString PasswordHint READ passwordHint CONSTANT) Q_PROPERTY(int PasswordMode READ passwordMode CONSTANT) Q_PROPERTY(QString RealName READ realName CONSTANT) Q_PROPERTY(QString Shell READ shell CONSTANT) Q_PROPERTY(bool SystemAccount READ systemAccount CONSTANT) Q_PROPERTY(qulonglong Uid READ uid CONSTANT) Q_PROPERTY(QString UserName READ userName CONSTANT) Q_PROPERTY(QString XSession READ xSession CONSTANT) public: FakeUser(const QString &path, qlonglong uid, const QString &name, const QString &fullName, int accountType, QObject *parent = 0); int accountType() const; bool automaticLogin() const; QString email() const; QString homeDirectory() const; QString iconFile() const; QString language() const; bool localAccount() const; QString location() const; bool locked() const; qulonglong loginFrequency() const; qlonglong loginTime() const; QString passwordHint() const; int passwordMode() const; QString realName() const; QString shell() const; bool systemAccount() const; qulonglong uid() const; QString userName() const; QString xSession() const; QDBusObjectPath path() const; bool cached; public Q_SLOTS: void SetAccountType(int accountType); void SetAutomaticLogin(bool enabled); void SetEmail(const QString &email); void SetHomeDirectory(const QString &homedir); void SetIconFile(const QString &filename); void SetLanguage(const QString &language); void SetLocation(const QString &location); void SetLocked(bool locked); void SetPassword(const QString &password, const QString &hint); void SetPasswordMode(int mode); void SetRealName(const QString &name); void SetShell(const QString &shell); void SetUserName(const QString &name); void SetXSession(const QString &x_session); Q_SIGNALS: void Changed(); private: qulonglong m_uid; QString m_name; QString m_fullName; int m_accountType; QDBusObjectPath m_path; }; #endif // FAKEUSER_H 07070100000049000081A40000000000000000000000016208D08F00000E76000000000000000000000000000000000000004600000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/api/tst_api.cpp/**************************************************************************** * This file is part of Qt AccountsService. * * Copyright (C) 2018 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> * * $BEGIN_LICENSE:LGPLv3+$ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * $END_LICENSE$ ***************************************************************************/ #include <QtTest/QtTest> #include <Qt5AccountsService/AccountsManager> #include <Qt5AccountsService/UserAccount> #include "fakeaccounts.h" #include "accounts_adaptor.h" using namespace QtAccountsService; class TestApi : public QObject { Q_OBJECT public: TestApi(QObject *parent = nullptr) : QObject(parent) , accounts(nullptr) , manager(nullptr) { } private Q_SLOTS: void initTestCase() { accounts = new FakeAccounts(this); new AccountsAdaptor(accounts); manager = new AccountsManager(QDBusConnection::sessionBus()); } void cleanupTestCase() { delete manager; manager = nullptr; delete accounts; accounts = nullptr; } void createAccounts() { // Find a user that doesn't exist QVERIFY(manager->findUserById(1000) == nullptr); // Create user bool ret = manager->createUser(QStringLiteral("testuser"), QStringLiteral("Test User"), UserAccount::StandardAccountType); QVERIFY(ret == true); // Find the same user UserAccount *account = manager->findUserById(1000); QVERIFY(account != nullptr); if (account) QCOMPARE(account->userName(), QStringLiteral("testuser")); } void cacheAccounts() { UserAccountList cachedUsers; // We start with no cached users cachedUsers = manager->listCachedUsersSync(); QCOMPARE(cachedUsers.size(), 0); // Cache one user QSignalSpy spyCacheUser(manager, SIGNAL(userCached(QString))); manager->cacheUser(QStringLiteral("testuser")); QVERIFY(spyCacheUser.wait(1000)); QCOMPARE(spyCacheUser.count(), 1); QList<QVariant> arguments = spyCacheUser.takeFirst(); QCOMPARE(arguments.at(0).toString(), QStringLiteral("testuser")); UserAccount *account = manager->cachedUser(arguments.at(0).toString()); QVERIFY(account != nullptr); if (account) QCOMPARE(account->userName(), QStringLiteral("testuser")); // Verify we have 1 cached user cachedUsers = manager->listCachedUsersSync(); QCOMPARE(cachedUsers.size(), 1); // Uncache the user manager->uncacheUser(QStringLiteral("testuser")); // No cached users cachedUsers = manager->listCachedUsersSync(); QCOMPARE(cachedUsers.size(), 0); } void deleteAccounts() { bool ret = manager->deleteUser(1000, false); QVERIFY(ret == true); } private: FakeAccounts *accounts; AccountsManager *manager; }; QTEST_MAIN(TestApi) #include "tst_api.moc" 0707010000004A000081A40000000000000000000000016208D08F0000023D000000000000000000000000000000000000003F00000000qt5-qtaccountsservice-1.3.0.26+git.e8a9950/tests/auto/auto.qbsimport qbs 1.0 import qbs.FileInfo Project { name: "Autotests" references: [ "api/api.qbs" ] AutotestRunner { Depends { name: "lirideployment" } builtByDefault: project.autotestEnabled name: "qtaccountsservice-autotest" arguments: project.autotestArguments wrapper: project.autotestWrapper environment: { var env = base; env.push("LD_LIBRARY_PATH=" + FileInfo.joinPaths(qbs.installRoot, qbs.installPrefix, lirideployment.libDir)); return env; } } } 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!359 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor