signon-ui/0000775000175000017500000000000014615655426012676 5ustar coucoufcoucoufsignon-ui/COPYING0000664000175000017500000010451314615655426013735 0ustar coucoufcoucouf GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . signon-ui/INSTALL0000664000175000017500000000003614615655426013726 0ustar coucoufcoucoufqmake make sudo make install signon-ui/NOTES0000664000175000017500000000000114615655426013500 0ustar coucoufcoucouf signon-ui/README0000664000175000017500000000000114615655426013545 0ustar coucoufcoucouf signon-ui/TODO0000664000175000017500000000000114615655426013355 0ustar coucoufcoucouf signon-ui/common-installs-config.pri0000664000175000017500000000277114615655426020003 0ustar coucoufcoucouf#----------------------------------------------------------------------------- # Common installation configuration for all projects. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # default installation target for applications #----------------------------------------------------------------------------- contains( TEMPLATE, app ) { target.path = $${INSTALL_PREFIX}/bin INSTALLS += target message("====") message("==== INSTALLS += target") } #----------------------------------------------------------------------------- # default installation target for libraries #----------------------------------------------------------------------------- contains( TEMPLATE, lib ) { target.path = $${INSTALL_PREFIX}/lib INSTALLS += target message("====") message("==== INSTALLS += target") # reset the .pc file's `prefix' variable #include( tools/fix-pc-prefix.pri ) } #----------------------------------------------------------------------------- # target for header files #----------------------------------------------------------------------------- !isEmpty( headers.files ) { headers.path = $${INSTALL_PREFIX}/include/$${TARGET} INSTALLS += headers message("====") message("==== INSTALLS += headers") } else { message("====") message("==== NOTE: Remember to add your API headers into `headers.files' for installation!") } # End of File signon-ui/common-project-config.pri0000664000175000017500000000232714615655426017615 0ustar coucoufcoucouf#----------------------------------------------------------------------------- # Common configuration for all projects. #----------------------------------------------------------------------------- CONFIG += link_pkgconfig # we don't like warnings... QMAKE_CXXFLAGS -= -Werror -Wno-write-strings # Disable RTTI QMAKE_CXXFLAGS += -fno-exceptions -fno-rtti TOP_SRC_DIR = $$PWD TOP_BUILD_DIR = $${TOP_SRC_DIR}/$(BUILD_DIR) include( coverage.pri ) #----------------------------------------------------------------------------- # setup the installation prefix #----------------------------------------------------------------------------- INSTALL_PREFIX = /usr # default installation prefix # default prefix can be overriden by defining PREFIX when running qmake isEmpty(PREFIX) { message("====") message("==== NOTE: To override the installation path run: `qmake PREFIX=/custom/path'") message("==== (current installation path is `$${INSTALL_PREFIX}')") } else { INSTALL_PREFIX = $${PREFIX} message("====") message("==== install prefix set to `$${INSTALL_PREFIX}'") } isEmpty(LIBDIR) { LIBDIR = "$${INSTALL_PREFIX}/lib" } isEmpty(LIBEXECDIR) { LIBEXECDIR = "$${INSTALL_PREFIX}/libexec" } signon-ui/common-vars.pri0000664000175000017500000000140514615655426015653 0ustar coucoufcoucouf#----------------------------------------------------------------------------- # Common variables for all projects. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- # Project name (used e.g. in include file and doc install path). # remember to update debian/* files if you changes this #----------------------------------------------------------------------------- PROJECT_NAME = signon-ui #----------------------------------------------------------------------------- # Project version # remember to update debian/* files if you changes this #----------------------------------------------------------------------------- PROJECT_VERSION = 0.15 # End of File signon-ui/coverage.pri0000664000175000017500000000355514615655426015215 0ustar coucoufcoucouf# Coverage CONFIG(coverage) { OBJECTS_DIR = MOC_DIR = TOP_SRC_DIR = $$PWD LIBS += -lgcov QMAKE_CXXFLAGS += --coverage QMAKE_LDFLAGS += --coverage QMAKE_EXTRA_TARGETS += coverage cov QMAKE_EXTRA_TARGETS += clean-gcno clean-gcda coverage-html \ generate-coverage-html clean-coverage-html coverage-gcovr \ generate-gcovr generate-coverage-gcovr clean-coverage-gcovr clean-gcno.commands = \ "@echo Removing old coverage instrumentation"; \ "find -name '*.gcno' -print | xargs -r rm" clean-gcda.commands = \ "@echo Removing old coverage results"; \ "find -name '*.gcda' -print | xargs -r rm" coverage-html.depends = clean-gcda check generate-coverage-html generate-coverage-html.commands = \ "@echo Collecting coverage data"; \ "lcov --directory $${TOP_SRC_DIR} --capture --output-file coverage.info --no-checksum --compat-libtool"; \ "lcov --extract coverage.info \"*/src/*.cpp\" -o coverage.info"; \ "lcov --remove coverage.info \"moc_*.cpp\" -o coverage.info"; \ "LANG=C genhtml --prefix $${TOP_SRC_DIR} --output-directory coverage-html --title \"Code Coverage\" --legend --show-details coverage.info" clean-coverage-html.depends = clean-gcda clean-coverage-html.commands = \ "lcov --directory $${TOP_SRC_DIR} -z"; \ "rm -rf coverage.info coverage-html" coverage-gcovr.depends = clean-gcda check generate-coverage-gcovr generate-coverage-gcovr.commands = \ "@echo Generating coverage GCOVR report"; \ "gcovr -x -r $${TOP_SRC_DIR} -o $${TOP_SRC_DIR}/coverage.xml -e \".*/moc_.*\" -e \"tests/.*\" -e \".*\\.h\"" clean-coverage-gcovr.depends = clean-gcda clean-coverage-gcovr.commands = \ "rm -rf $${TOP_SRC_DIR}/coverage.xml" QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml } signon-ui/po/0000775000175000017500000000000014615655426013314 5ustar coucoufcoucoufsignon-ui/po/Makefile0000664000175000017500000000104114615655426014750 0ustar coucoufcoucouf# Add here the language codes for the translated .po files: LINGUAS = I18N_DOMAIN = signon-ui PO_FILES = $(addsuffix .po, $(LINGUAS)) MO_FILES = $(addsuffix .mo, $(LINGUAS)) DEL_FILE = rm -f INSTALL = /usr/bin/install -c -m 644 MKDIR = mkdir -p all: $(MO_FILES) install: all for lang in $(LINGUAS); do \ dir=$(INSTALL_ROOT)/usr/share/locale/$$lang/LC_MESSAGES; \ $(MKDIR) $$dir; \ $(INSTALL) $$lang.mo $$dir/$(I18N_DOMAIN).mo; \ done %.mo: %.po msgfmt -o "$@" "$<" clean: -$(DEL_FILE) $(MO_FILES) distclean: clean check: all signon-ui/po/signon-ui.pot0000664000175000017500000000344714615655426015760 0ustar coucoufcoucouf# SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2012-03-28 10:13+0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: browser-request.cpp:268 msgid "" "The authentication process is complete.\n" "You may now close this dialog and return to the application." msgstr "" #: browser-request.cpp:274 msgid "Done" msgstr "" #: browser-request.cpp:291 msgid "Web authentication for %1" msgstr "" #: browser-request.cpp:294 msgid "Web authentication" msgstr "" #: dialog-request.cpp:105 msgid "Enter your credentials to login" msgstr "" #: dialog-request.cpp:107 msgid "Previous authentication attempt failed. Please try again." msgstr "" #: dialog-request.cpp:142 msgid "Enter your credentials" msgstr "" #: dialog-request.cpp:166 msgid "Username:" msgstr "" #: dialog-request.cpp:176 msgid "Password:" msgstr "" #: dialog-request.cpp:182 msgid "" "As an additional security measure, please fill in the text from the picture " "below:" msgstr "" #: dialog-request.cpp:191 msgid "Text from the picture:" msgstr "" #: indicator-service.cpp:140 msgid "Applications can no longer access some of your Web Accounts" msgstr "" #: indicator-service.cpp:143 msgid "Applications can no longer access your %1 Web Account" msgstr "" #: indicator-service.cpp:147 msgid "" "Choose Web Accounts from the user menu to reinstate access to this " "account." msgstr "" signon-ui/po/update_pot.sh0000775000175000017500000000006214615655426016015 0ustar coucoufcoucouf#! /bin/bash cd ../src make ../po/signon-ui.pot signon-ui/signon-ui.pro0000664000175000017500000000044614615655426015334 0ustar coucoufcoucoufinclude(common-vars.pri) include(common-project-config.pri) TEMPLATE = subdirs CONFIG += ordered SUBDIRS = \ src \ tests include(common-installs-config.pri) DISTNAME = $${PROJECT_NAME}-$${PROJECT_VERSION} dist.commands = "bzr export $${DISTNAME}.tar.bz2" QMAKE_EXTRA_TARGETS += dist signon-ui/src/0000775000175000017500000000000014615655426013465 5ustar coucoufcoucoufsignon-ui/src/animation-label.cpp0000664000175000017500000000345714615655426017236 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (c) 2009 Nokia Corporation * Copyright (C) 2012 Canonical Ltd. * * Contact: David King * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "animation-label.h" AnimationLabel::AnimationLabel(const QString &animationPath, QWidget *parent): QWidget(parent) { m_animation = new QMovie(animationPath, QByteArray(), this); // We need a container for the QMovie. QLabel *container = new QLabel(this); container->setMovie(m_animation); QVBoxLayout *layout = new QVBoxLayout(this); layout->setAlignment(Qt::AlignCenter); layout->setSpacing(0); layout->setContentsMargins(0, 0, 0, 0); layout->addWidget(container); setLayout(layout); } AnimationLabel::~AnimationLabel() { } void AnimationLabel::start() { // Let's check if the movie can be started. if (m_animation->state() == QMovie::NotRunning || m_animation->state() == QMovie::Paused) { // It can so start the animation. m_animation->start(); } } void AnimationLabel::stop() { // Check if the animation can be stopped. if (m_animation->state() == QMovie::Running) { // It can so stop the animation. m_animation->stop(); } } signon-ui/src/animation-label.h0000664000175000017500000000235014615655426016672 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (c) 2009 Nokia Corporation * Copyright (C) 2012 Canonical Ltd. * * Contact: David King * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef ANIMATIONLABEL_H_ #define ANIMATIONLABEL_H_ #include #include #include /** * AnimationLabel * * Uses animation from the path to display it in a QLabel. */ class AnimationLabel : public QWidget { Q_OBJECT public: AnimationLabel(const QString &animationPath, QWidget *parent); virtual ~AnimationLabel(); public Q_SLOTS: void start(); void stop(); private: QMovie *m_animation; }; #endif /* ANIMATIONLABEL_H_ */ signon-ui/src/animationlabel.qrc0000664000175000017500000000013614615655426017153 0ustar coucoufcoucouf spinner-26.gif signon-ui/src/browser-request.cpp0000664000175000017500000001620014615655426017341 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * Copyright (C) 2017 Alberto Mardegan * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "browser-request.h" #include "debug.h" #include "qquick-dialog.h" #include "errors.h" #include "i18n.h" #include #include #include #include #include using namespace SignOnUi; using namespace SignOnUi::QQuick; namespace SignOnUi { class BrowserRequestPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(BrowserRequest) Q_PROPERTY(QUrl pageComponentUrl READ pageComponentUrl CONSTANT) Q_PROPERTY(QUrl currentUrl READ currentUrl WRITE setCurrentUrl) Q_PROPERTY(QUrl startUrl READ startUrl CONSTANT) Q_PROPERTY(QUrl finalUrl READ finalUrl CONSTANT) public: BrowserRequestPrivate(BrowserRequest *request); ~BrowserRequestPrivate(); void start(); void setCurrentUrl(const QUrl &url); QUrl pageComponentUrl() const; QUrl currentUrl() const { return m_currentUrl; } QUrl startUrl() const { return m_startUrl; } QUrl finalUrl() const { return m_finalUrl; } QUrl responseUrl() const { return m_responseUrl; } public Q_SLOTS: void cancel(); void onLoadStarted(); void onLoadFinished(bool ok); private Q_SLOTS: void onFailTimer(); void onFinished(); private: void buildDialog(const QVariantMap ¶ms); private: Dialog *m_dialog; QUrl m_currentUrl; QUrl m_startUrl; QUrl m_finalUrl; QUrl m_responseUrl; QTimer m_failTimer; mutable BrowserRequest *q_ptr; }; } // namespace BrowserRequestPrivate::BrowserRequestPrivate( BrowserRequest *request): QObject(request), m_dialog(0), q_ptr(request) { m_failTimer.setSingleShot(true); m_failTimer.setInterval(3000); QObject::connect(&m_failTimer, SIGNAL(timeout()), this, SLOT(onFailTimer())); } BrowserRequestPrivate::~BrowserRequestPrivate() { delete m_dialog; } void BrowserRequestPrivate::start() { Q_Q(BrowserRequest); const QVariantMap ¶ms = q->parameters(); TRACE() << params; QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); QDir rootDir = cachePath + QString("/id-%1").arg(q->identity()); if (!rootDir.exists()) { rootDir.mkpath("."); } m_finalUrl = params.value(SSOUI_KEY_FINALURL).toString(); m_startUrl = params.value(SSOUI_KEY_OPENURL).toString(); buildDialog(params); QObject::connect(m_dialog, SIGNAL(finished(int)), this, SLOT(onFinished())); QUrl webview("qrc:/MainWindow.qml"); QDir qmlDir("/usr/share/signon-ui/qml"); if (qmlDir.exists()) { QFileInfo qmlFile(qmlDir.absolutePath() + "/MainWindow.qml"); if (qmlFile.exists()) webview.setUrl(qmlFile.absoluteFilePath()); } m_dialog->rootContext()->setContextProperty("request", this); m_dialog->rootContext()->setContextProperty("rootDir", QUrl::fromLocalFile(rootDir.absolutePath())); m_dialog->setSource(webview); } QUrl BrowserRequestPrivate::pageComponentUrl() const { Q_Q(const BrowserRequest); /* We define the X-PageComponent key to let the clients override the QML * component to be used to build the authentication page. * To prevent a malicious client to show it's own UI, we require that the * file path begins with "/usr/share/signon-ui/" (where Ubuntu click * packages cannot install files). */ QUrl providedUrl = q->clientData().value("X-PageComponent").toString(); if (providedUrl.isValid() && providedUrl.isLocalFile() && providedUrl.path().startsWith("/usr/share/signon-ui/")) { return providedUrl; } else { return QStringLiteral("DefaultPage.qml"); } } void BrowserRequestPrivate::setCurrentUrl(const QUrl &url) { TRACE() << "Url changed:" << url; m_failTimer.stop(); if (url.host() == m_finalUrl.host() && url.path() == m_finalUrl.path()) { m_responseUrl = url; if (!m_dialog->isVisible()) { /* Do not show the notification page. */ m_dialog->accept(); } else { /* Replace the web page with an information screen */ /* TODO */ m_dialog->accept(); } } } void BrowserRequestPrivate::cancel() { Q_Q(BrowserRequest); TRACE() << "Client requested to cancel"; q->setCanceled(); if (m_dialog) { m_dialog->close(); } } void BrowserRequestPrivate::onLoadStarted() { m_failTimer.stop(); } void BrowserRequestPrivate::onLoadFinished(bool ok) { Q_Q(BrowserRequest); TRACE() << "Load finished" << ok; if (!ok) { m_failTimer.start(); return; } if (!m_dialog->isVisible()) { if (m_responseUrl.isEmpty()) { q->setWindow(m_dialog); } else { onFinished(); } } } void BrowserRequestPrivate::onFailTimer() { Q_Q(BrowserRequest); TRACE() << "Page loading failed"; if (m_dialog) { m_dialog->close(); } q->setResult(QVariantMap()); } void BrowserRequestPrivate::onFinished() { Q_Q(BrowserRequest); TRACE() << "Browser dialog closed"; QObject::disconnect(m_dialog, SIGNAL(finished(int)), this, SLOT(onFinished())); QVariantMap reply; QUrl url = m_responseUrl.isEmpty() ? m_currentUrl : m_responseUrl; reply[SSOUI_KEY_URLRESPONSE] = url.toString(); m_dialog->close(); q->setResult(reply); } void BrowserRequestPrivate::buildDialog(const QVariantMap ¶ms) { m_dialog = new Dialog; QString title; if (params.contains(SSOUI_KEY_TITLE)) { title = params[SSOUI_KEY_TITLE].toString(); } else if (params.contains(SSOUI_KEY_CAPTION)) { title = _("Web authentication for %1"). arg(params[SSOUI_KEY_CAPTION].toString()); } else { title = _("Web authentication"); } m_dialog->setTitle(title); TRACE() << "Dialog was built"; } BrowserRequest::BrowserRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent): Request(connection, message, parameters, parent), d_ptr(new BrowserRequestPrivate(this)) { } BrowserRequest::~BrowserRequest() { } void BrowserRequest::start() { Q_D(BrowserRequest); Request::start(); d->start(); } #include "browser-request.moc" signon-ui/src/browser-request.h0000664000175000017500000000263214615655426017012 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2014 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_BROWSER_REQUEST_H #define SIGNON_UI_BROWSER_REQUEST_H #include "request.h" #include namespace SignOnUi { class BrowserRequestPrivate; class BrowserRequest: public Request { Q_OBJECT public: explicit BrowserRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); ~BrowserRequest(); // reimplemented virtual methods void start(); private: BrowserRequestPrivate *d_ptr; Q_DECLARE_PRIVATE(BrowserRequest) }; } // namespace #endif // SIGNON_UI_BROWSER_REQUEST_H signon-ui/src/com.canonical.indicators.webcredentials.service.in0000664000175000017500000000040014615655426025302 0ustar coucoufcoucouf[D-BUS Service] Name=com.canonical.indicators.webcredentials Exec=/bin/sh -c "'if [ ! -x $${target.path}/$${TARGET} ] || [ \"$QT_QPA_PLATFORM\" = \"ubuntumirclient\" ]; then exec /usr/bin/online-accounts-service; else exec $${target.path}/$${TARGET}; fi'" signon-ui/src/com.canonical.indicators.webcredentials.xml0000664000175000017500000000554714615655426024056 0ustar coucoufcoucouf signon-ui/src/com.nokia.singlesignonui.service.in0000664000175000017500000000036114615655426022366 0ustar coucoufcoucouf[D-BUS Service] Name=com.nokia.singlesignonui Exec=/bin/sh -c "'if [ ! -x $${target.path}/$${TARGET} ] || [ \"$QT_QPA_PLATFORM\" = \"ubuntumirclient\" ]; then exec /usr/bin/online-accounts-service; else exec $${target.path}/$${TARGET}; fi'" signon-ui/src/cookie-jar-manager.cpp0000664000175000017500000001226214615655426017627 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #define QT_DISABLE_DEPRECATED_BEFORE QT_VERSION_CHECK(4, 0, 0) #include "cookie-jar-manager.h" #include "debug.h" #include #include #include #include #include #include #include #include using namespace SignOnUi; static CookieJarManager *m_instance = 0; static const unsigned int JAR_VERSION = 1; namespace SignOnUi { QList CookieJar::cookiesForUrl(const QUrl &url) const { return QNetworkCookieJar::cookiesForUrl(url); } bool CookieJar::setCookiesFromUrl(const QList &cookieList, const QUrl &url) { TRACE() << "Setting cookies for url:" << url; TRACE() << cookieList; queueSave(); return QNetworkCookieJar::setCookiesFromUrl(cookieList, url); } class CookieJarManagerPrivate { Q_DECLARE_PUBLIC(CookieJarManager) private: mutable CookieJarManager *q_ptr; QHash cookieJars; QDir cookieDir; }; } // namespace QDataStream &operator<<(QDataStream &stream, const QList &list) { stream << JAR_VERSION; stream << quint32(list.size()); foreach (const QNetworkCookie &cookie, list) { stream << cookie.toRawForm(); } return stream; } QDataStream &operator>>(QDataStream &stream, QList &list) { list.clear(); quint32 version; stream >> version; if (version != JAR_VERSION) return stream; quint32 count; stream >> count; for (quint32 i = 0; i < count; i++) { QByteArray value; stream >> value; QList newCookies = QNetworkCookie::parseCookies(value); if (newCookies.count() == 0 && value.length() != 0) { qWarning() << "CookieJar: Unable to parse saved cookie:" << value; } foreach (const QNetworkCookie &cookie, newCookies) { list.append(cookie); } if (stream.atEnd()) break; } return stream; } CookieJar::CookieJar(QString cookiePath, QObject *parent): QNetworkCookieJar(parent), m_cookiePath(cookiePath) { // Prepare the auto-save timer m_saveTimer.setInterval(10 * 1000); m_saveTimer.setSingleShot(true); QObject::connect(&m_saveTimer, SIGNAL(timeout()), this, SLOT(save())); // Load any saved cookies QFile file(m_cookiePath); file.open(QIODevice::ReadOnly); QDataStream in(&file); QList cookies; in >> cookies; setAllCookies(cookies); } void CookieJar::save() { TRACE() << "saving to" << m_cookiePath; QFile file(m_cookiePath); file.open(QIODevice::WriteOnly); QDataStream out(&file); out << allCookies(); /* clear any running timer */ m_saveTimer.stop(); } void CookieJar::queueSave() { m_saveTimer.start(); } CookieJarManager::CookieJarManager(QObject *parent): QObject(parent), d_ptr(new CookieJarManagerPrivate) { Q_D(CookieJarManager); qDBusRegisterMetaType(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) qRegisterMetaTypeStreamOperators >("QList"); #endif d->cookieDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/cookies"; if (!d->cookieDir.exists()) { d->cookieDir.mkpath("."); } QObject::connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(saveAll())); } CookieJarManager::~CookieJarManager() { delete d_ptr; } CookieJarManager *CookieJarManager::instance() { if (m_instance == 0) { m_instance = new CookieJarManager(); } return m_instance; } CookieJar *CookieJarManager::cookieJarForIdentity(uint id) { Q_D(CookieJarManager); if (d->cookieJars.contains(id)) { return d->cookieJars[id]; } else { QString fileName = QString::fromLatin1("%1.jar").arg(id); CookieJar *cookieJar = new CookieJar(d->cookieDir.absoluteFilePath(fileName), this); d->cookieJars.insert(id, cookieJar); return cookieJar; } } void CookieJarManager::removeForIdentity(uint id) { Q_D(CookieJarManager); TRACE() << id; QString fileName = QString::fromLatin1("%1.jar").arg(id); d->cookieDir.remove(fileName); } void CookieJarManager::saveAll() { Q_D(CookieJarManager); foreach (CookieJar *jar, d->cookieJars) { jar->save(); } } signon-ui/src/cookie-jar-manager.h0000664000175000017500000000410314615655426017267 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_COOKIE_JAR_MANAGER_H #define SIGNON_UI_COOKIE_JAR_MANAGER_H #include #include #include #include #include namespace SignOnUi { typedef QMap RawCookies; class CookieJar: public QNetworkCookieJar { Q_OBJECT public: CookieJar(QString cookiePath, QObject *parent = 0); ~CookieJar() {} QList cookiesForUrl(const QUrl &url) const; bool setCookiesFromUrl(const QList &cookieList, const QUrl &url); void setCookies(const QList &cookieList) { queueSave(); setAllCookies(cookieList); } public Q_SLOTS: void save(); private: void queueSave(); private: QString m_cookiePath; QTimer m_saveTimer; }; class CookieJarManagerPrivate; class CookieJarManager: public QObject { Q_OBJECT public: ~CookieJarManager(); static CookieJarManager *instance(); CookieJar *cookieJarForIdentity(uint id); void removeForIdentity(uint id); public Q_SLOTS: void saveAll(); protected: explicit CookieJarManager(QObject *parent = 0); private: CookieJarManagerPrivate *d_ptr; Q_DECLARE_PRIVATE(CookieJarManager) }; } // namespace Q_DECLARE_METATYPE(SignOnUi::RawCookies) #endif // SIGNON_UI_COOKIE_JAR_MANAGER_H signon-ui/src/debug.cpp0000664000175000017500000000216114615655426015257 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" Q_LOGGING_CATEGORY(DBG_SIGNON_UI, "signon", QtWarningMsg) int appLoggingLevel = 1; // criticals void setLoggingLevel(int level) { if (level >= 1) { QLoggingCategory::setFilterRules("signon.warning=true"); if (level >= 2) { QLoggingCategory::setFilterRules("signon.debug=true"); } } appLoggingLevel = level; } signon-ui/src/debug.h0000664000175000017500000000235314615655426014727 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_DEBUG_H #define SIGNON_UI_DEBUG_H #include Q_DECLARE_LOGGING_CATEGORY(DBG_SIGNON_UI) /* 0 - fatal, 1 - critical(default), 2 - info/debug */ extern int appLoggingLevel; static inline int loggingLevel() { return appLoggingLevel; } void setLoggingLevel(int level); #define TRACE() \ qCDebug(DBG_SIGNON_UI) << __FILE__ << __LINE__ << __func__ #define BLAME() \ qCWarning(DBG_SIGNON_UI) << __FILE__ << __LINE__ << __func__ #endif // SIGNON_UI_DEBUG_H signon-ui/src/dialog-request.cpp0000664000175000017500000002057114615655426017123 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "dialog-request.h" #include "debug.h" #include "dialog.h" #include "i18n.h" #include "network-access-manager.h" #include #include #include #include #include #include #include #include #include #include using namespace SignOnUi; using namespace SignOn; namespace SignOnUi { class DialogRequestPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(DialogRequest) public: DialogRequestPrivate(DialogRequest *request); ~DialogRequestPrivate(); void buildDialog(const QVariantMap ¶ms); void start(); private Q_SLOTS: void onAccepted(); void onRejected(); void onCaptchaRetrieved(QNetworkReply *reply); private: QString messageFromId(int id); void requestCaptcha(const QUrl &url); private: mutable DialogRequest *q_ptr; Dialog *m_dialog; bool m_queryUsername; bool m_queryPassword; QLineEdit *m_wUsername; QLineEdit *m_wPassword; QLineEdit *m_wCaptchaText; QLabel *m_wCaptcha; QNetworkAccessManager *m_networkAccessManager; }; } // namespace DialogRequestPrivate::DialogRequestPrivate(DialogRequest *request): QObject(request), q_ptr(request), m_dialog(0), m_queryUsername(false), m_queryPassword(false), m_wUsername(0), m_wPassword(0), m_wCaptchaText(0), m_wCaptcha(0), m_networkAccessManager(0) { } DialogRequestPrivate::~DialogRequestPrivate() { delete m_dialog; } QString DialogRequestPrivate::messageFromId(int id) { static QString error = QLatin1String("%1"); static QString msg = QLatin1String("%1"); switch (id) { case QUERY_MESSAGE_LOGIN: return msg.arg(_("Enter your credentials to login")); case QUERY_MESSAGE_NOT_AUTHORIZED: return error.arg(_("Previous authentication attempt failed. Please try again.")); case QUERY_MESSAGE_EMPTY: default: return QString(); } } void DialogRequestPrivate::requestCaptcha(const QUrl &url) { TRACE() << url; if (m_networkAccessManager == 0) { m_networkAccessManager = NetworkAccessManager::instance(); } QNetworkRequest request = QNetworkRequest(url); QNetworkReply *reply = m_networkAccessManager->get(request); if (reply->isFinished()) { onCaptchaRetrieved(reply); } else { // FIXME: handle download asynchronously QEventLoop loop; QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); loop.exec(); onCaptchaRetrieved(reply); } } void DialogRequestPrivate::buildDialog(const QVariantMap ¶ms) { m_dialog = new Dialog; m_dialog->setObjectName("LoginDialog"); m_dialog->setMinimumWidth(400); QString title = params.value(SSOUI_KEY_TITLE, _("Enter your credentials")).toString(); m_dialog->setWindowTitle(title); QFormLayout *formLayout = new QFormLayout(m_dialog); QString message = params.value(SSOUI_KEY_MESSAGE).toString(); if (message.isEmpty()) { // Check whether a predefined message id is set if (params.contains(SSOUI_KEY_MESSAGEID)) { message = messageFromId(params.value(SSOUI_KEY_MESSAGEID).toInt()); } } if (!message.isEmpty()) { QLabel *wMessage = new QLabel(message); wMessage->setObjectName("Message"); formLayout->addRow(wMessage); } m_queryUsername = params.value(SSOUI_KEY_QUERYUSERNAME, false).toBool(); bool showUsername = m_queryUsername || params.contains(SSOUI_KEY_USERNAME); if (showUsername) { m_wUsername = new QLineEdit; m_wUsername->setObjectName("UsernameField"); m_wUsername->setEnabled(m_queryUsername); #ifndef QT_NO_ACCESSIBILITY m_wUsername->setAccessibleName("username"); #endif m_wUsername->setText(params.value(SSOUI_KEY_USERNAME).toString()); formLayout->addRow(_("Username:"), m_wUsername); } m_queryPassword = params.value(SSOUI_KEY_QUERYPASSWORD, false).toBool(); bool showPassword = m_queryPassword || params.contains(SSOUI_KEY_PASSWORD); if (showPassword) { m_wPassword = new QLineEdit; m_wPassword->setObjectName("PasswordField"); m_wPassword->setEnabled(m_queryPassword); m_wPassword->setEchoMode(QLineEdit::Password); m_wPassword->setText(params.value(SSOUI_KEY_PASSWORD).toString()); formLayout->addRow(_("Password:"), m_wPassword); } QString captchaUrl = params.value(SSOUI_KEY_CAPTCHAURL).toString(); if (!captchaUrl.isEmpty()) { QLabel *wCaptchaMsg = new QLabel(QString::fromLatin1("%1"). arg(_("As an additional security measure, please " "fill in the text from the picture below:"))); wCaptchaMsg->setWordWrap(true); formLayout->addRow(wCaptchaMsg); m_wCaptcha = new QLabel; m_wCaptcha->setAlignment(Qt::AlignCenter); formLayout->addRow(m_wCaptcha); m_wCaptchaText = new QLineEdit; m_wCaptchaText->setObjectName("CaptchaField"); formLayout->addRow(_("Text from the picture:"), m_wCaptchaText); requestCaptcha(QUrl::fromEncoded(captchaUrl.toLatin1())); } QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), m_dialog, SLOT(accept())); connect(buttonBox, SIGNAL(rejected()), m_dialog, SLOT(reject())); formLayout->addRow(buttonBox); TRACE() << "Dialog was built"; } void DialogRequestPrivate::start() { Q_Q(DialogRequest); buildDialog(q->parameters()); q->setWidget(m_dialog); QObject::connect(m_dialog, SIGNAL(accepted()), this, SLOT(onAccepted())); QObject::connect(m_dialog, SIGNAL(rejected()), this, SLOT(onRejected())); } void DialogRequestPrivate::onAccepted() { Q_Q(DialogRequest); TRACE() << "Dialog is accepted"; QVariantMap reply; if (m_queryUsername) { Q_ASSERT(m_wUsername != 0); reply[SSOUI_KEY_USERNAME] = m_wUsername->text(); } if (m_queryPassword) { Q_ASSERT(m_wPassword != 0); reply[SSOUI_KEY_PASSWORD] = m_wPassword->text(); } if (m_wCaptchaText != 0) { reply[SSOUI_KEY_CAPTCHARESP] = m_wCaptchaText->text(); } q->setResult(reply); } void DialogRequestPrivate::onRejected() { Q_Q(DialogRequest); TRACE() << "Dialog is rejected"; q->setCanceled(); } void DialogRequestPrivate::onCaptchaRetrieved(QNetworkReply *reply) { TRACE() << "Got captcha"; reply->deleteLater(); if (reply->error()) { // TODO handle error TRACE() << "Got error:" << reply->errorString(); return; } QUrl newUrl = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl(); if (newUrl.isEmpty()) { QByteArray captchaData = reply->readAll(); QPixmap pixmap; pixmap.loadFromData(captchaData); m_wCaptcha->setPixmap(pixmap); } else { QUrl url = reply->url().resolved(newUrl); requestCaptcha(url); } } DialogRequest::DialogRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent): Request(connection, message, parameters, parent), d_ptr(new DialogRequestPrivate(this)) { } DialogRequest::~DialogRequest() { } void DialogRequest::start() { Q_D(DialogRequest); Request::start(); d->start(); } #include "dialog-request.moc" signon-ui/src/dialog-request.h0000664000175000017500000000261614615655426016570 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_DIALOG_REQUEST_H #define SIGNON_UI_DIALOG_REQUEST_H #include "request.h" #include namespace SignOnUi { class DialogRequestPrivate; class DialogRequest: public Request { Q_OBJECT public: explicit DialogRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); ~DialogRequest(); // reimplemented virtual methods void start(); private: DialogRequestPrivate *d_ptr; Q_DECLARE_PRIVATE(DialogRequest) }; } // namespace #endif // SIGNON_UI_DIALOG_REQUEST_H signon-ui/src/dialog.cpp0000664000175000017500000000176714615655426015443 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "dialog.h" #include "debug.h" using namespace SignOnUi; Dialog::Dialog(QWidget *parent, Qt::WindowFlags f): QDialog(parent, f) { } Dialog::~Dialog() { } void Dialog::closeEvent(QCloseEvent *e) { reject(); QDialog::closeEvent(e); } signon-ui/src/dialog.h0000664000175000017500000000216714615655426015103 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_DIALOG_H #define SIGNON_UI_DIALOG_H #include #include namespace SignOnUi { class Dialog: public QDialog { Q_OBJECT public: explicit Dialog(QWidget *parent = 0, Qt::WindowFlags f = {}); ~Dialog(); protected: // reimplemented virtual methods void closeEvent(QCloseEvent *e); }; } // namespace #endif // SIGNON_UI_DIALOG_H signon-ui/src/errors.h0000664000175000017500000000205314615655426015152 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_ERRORS_H #define SIGNON_UI_ERRORS_H #define SIGNON_UI_ERROR_PREFIX "com.canonical.SignonUi" #define SIGNON_UI_ERROR_EMBEDDING_FAILED \ SIGNON_UI_ERROR_PREFIX ".EmbeddingFailed" #define SIGNON_UI_ERROR_INTERNAL \ SIGNON_UI_ERROR_PREFIX ".InternalError" #endif // SIGNON_UI_ERRORS_H signon-ui/src/http-warning.cpp0000664000175000017500000000410214615655426016610 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "http-warning.h" #include "debug.h" #include "i18n.h" #include #include #include #include #include using namespace SignOnUi; HttpWarning::HttpWarning(QWidget *parent): QWidget(parent) { QVBoxLayout *vLayout = new QVBoxLayout; vLayout->setContentsMargins(0, 0, 0, 0); setLayout(vLayout); QFrame *separator = new QFrame; separator->setFrameShape(QFrame::HLine); separator->setFrameShadow(QFrame::Raised); separator->setContentsMargins(0, 0, 0, 0); vLayout->addWidget(separator); QWidget *labels = new QWidget; vLayout->addWidget(labels); QHBoxLayout *labelsLayout = new QHBoxLayout; labelsLayout->setContentsMargins(0, 0, 0, 0); labels->setLayout(labelsLayout); QLabel *label = new QLabel; label->setPixmap(QPixmap(":security-low.png")); labelsLayout->addWidget(label); label = new QLabel; label->setTextFormat(Qt::RichText); QString text = _("This site uses an insecure connection."); #ifdef HTTP_WARNING_HELP text.append(QString(" %1"). arg(_("What does this mean?"))); #endif label->setText(text); label->setOpenExternalLinks(true); labelsLayout->addWidget(label); labelsLayout->addStretch(); } HttpWarning::~HttpWarning() { } signon-ui/src/http-warning.h0000664000175000017500000000204014615655426016254 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_HTTP_WARNING_H #define SIGNON_UI_HTTP_WARNING_H #include #include namespace SignOnUi { class HttpWarning: public QWidget { Q_OBJECT public: HttpWarning(QWidget *parent = 0); ~HttpWarning(); }; } // namespace #endif // SIGNON_UI_HTTP_WARNING_H signon-ui/src/http-warning.qrc0000664000175000017500000000013014615655426016610 0ustar coucoufcoucouf security-low.png signon-ui/src/i18n.cpp0000664000175000017500000000210214615655426014743 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #define NO_TR_OVERRIDE #include "i18n.h" #include namespace SignOnUi { void initTr(const char *domain, const char *localeDir) { bindtextdomain(domain, localeDir); textdomain(domain); } QString _(const char *text, const char *domain) { return QString::fromUtf8(dgettext(domain, text)); } }; // namespace signon-ui/src/i18n.h0000664000175000017500000000175414615655426014424 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_I18N_H #define SIGNON_UI_I18N_H #include namespace SignOnUi { void initTr(const char *domain, const char *localeDir); QString _(const char *text, const char *domain = 0); } // namespace #endif // SIGNON_UI_I18N_H signon-ui/src/inactivity-timer.cpp0000664000175000017500000000335014615655426017473 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "inactivity-timer.h" #include "debug.h" #include using namespace SignOnUi; InactivityTimer::InactivityTimer(int interval, QObject *parent): QObject(parent), m_interval(interval) { m_timer.setSingleShot(true); QObject::connect(&m_timer, SIGNAL(timeout()), this, SLOT(onTimeout())); } void InactivityTimer::watchObject(QObject *object) { connect(object, SIGNAL(isIdleChanged()), SLOT(onIdleChanged())); m_watchedObjects.append(object); /* Force an initial check */ onIdleChanged(); } void InactivityTimer::onIdleChanged() { if (allObjectsAreIdle()) { m_timer.start(m_interval); } } void InactivityTimer::onTimeout() { TRACE(); if (allObjectsAreIdle()) { Q_EMIT timeout(); } } bool InactivityTimer::allObjectsAreIdle() const { foreach (const QObject *object, m_watchedObjects) { if (!object->property("isIdle").toBool()) { return false; } } return true; } signon-ui/src/inactivity-timer.h0000664000175000017500000000255014615655426017141 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_INACTIVITY_TIMER_H #define SIGNON_UI_INACTIVITY_TIMER_H #include #include #include namespace SignOnUi { class InactivityTimer: public QObject { Q_OBJECT public: InactivityTimer(int interval, QObject *parent = 0); ~InactivityTimer() {} void watchObject(QObject *object); Q_SIGNALS: void timeout(); private Q_SLOTS: void onIdleChanged(); void onTimeout(); private: bool allObjectsAreIdle() const; private: QList m_watchedObjects; QTimer m_timer; int m_interval; }; } // namespace #endif // SIGNON_UI_INACTIVITY_TIMER_H signon-ui/src/indicator-service.cpp0000664000175000017500000002452614615655426017614 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "indicator-service.h" #include "debug.h" #include "i18n.h" #include "reauthenticator.h" #include "webcredentials_adaptor.h" #include #include #undef signals #include #include using namespace SignOnUi; QDBusArgument &operator<<(QDBusArgument &argument, const QSet &set) { argument.beginArray(qMetaTypeId()); foreach (uint id, set) { argument << id; } argument.endArray(); return argument; } const QDBusArgument &operator>>(const QDBusArgument &argument, QSet &set) { argument.beginArray(); while (!argument.atEnd()) { uint id; argument >> id; set.insert(id); } argument.endArray(); return argument; } namespace SignOnUi { static IndicatorService *m_instance = 0; class IndicatorServicePrivate: public QObject, QDBusContext { Q_OBJECT Q_DECLARE_PUBLIC(IndicatorService) public: Q_PROPERTY(QSet Failures READ failures) Q_PROPERTY(bool ErrorStatus READ errorStatus) IndicatorServicePrivate(IndicatorService *service); ~IndicatorServicePrivate() {}; QSet failures() const { return m_failures; } bool errorStatus() const { return m_errorStatus; } public Q_SLOTS: void ClearErrorStatus(); void RemoveFailures(const QSet &accountIds); void ReportFailure(uint accountId, const QVariantMap ¬ification); bool ReauthenticateAccount(uint accountId, const QVariantMap &extraParameters); private: void showNotification(const QVariantMap ¶meters); void notifyPropertyChanged(const char *propertyName); private Q_SLOTS: void onReauthenticatorFinished(bool success); private: mutable IndicatorService *q_ptr; WebcredentialsAdaptor *m_adaptor; QSet m_failures; QMap > m_failureClientData; QMap m_reauthenticators; QDBusMessage m_clientMessage; bool m_errorStatus; }; } // namespace IndicatorServicePrivate::IndicatorServicePrivate(IndicatorService *service): QObject(service), q_ptr(service), m_adaptor(new WebcredentialsAdaptor(this)), m_errorStatus(false) { qDBusRegisterMetaType< QSet >(); notify_init("webcredentials-indicator"); } void IndicatorServicePrivate::ClearErrorStatus() { if (m_errorStatus) { m_errorStatus = false; notifyPropertyChanged("ErrorStatus"); } } void IndicatorServicePrivate::RemoveFailures(const QSet &accountIds) { Q_Q(IndicatorService); m_failures.subtract(accountIds); notifyPropertyChanged("Failures"); if (q->isIdle()) { Q_EMIT q->isIdleChanged(); } } void IndicatorServicePrivate::ReportFailure(uint accountId, const QVariantMap ¬ification) { Q_Q(IndicatorService); bool wasIdle = q->isIdle(); m_failures.insert(accountId); if (wasIdle) { Q_EMIT q->isIdleChanged(); } /* If the original client data is provided, we remember it: it can * be used to replay the authentication later. */ if (notification.contains("ClientData")) { /* If the key is not found, the QMap's [] operator inserts an empty * element in the map and return a reference to it. So the following * line of code returns a valid QList even if the account never failed * before. */ QList &failedAuthentications = m_failureClientData[accountId]; AuthData authData; authData.sessionData = notification["ClientData"].toMap(); authData.identity = quint32(notification["Identity"].toUInt()); authData.method = notification["Method"].toString(); authData.mechanism = notification["Mechanism"].toString(); failedAuthentications.append(authData); } notifyPropertyChanged("Failures"); showNotification(notification); } bool IndicatorServicePrivate::ReauthenticateAccount(uint accountId, const QVariantMap &extraParameters) { if (!m_failureClientData.contains(accountId)) { /* Nothing we can do about this account */ TRACE() << "No reauthentication data for account" << accountId; return false; } if (m_reauthenticators.contains(accountId)) { /* A reauthenticator for this account is already at work. This * shouldn't happen in a real world scenario. */ qWarning() << "Reauthenticator already active on" << accountId; return false; } TRACE() << "Reauthenticating account" << accountId; /* If we need to reauthenticate, we are delivering the result * after iterating the event loop, so we must inform QtDBus that * it shouldn't use this method's return value as a result. */ setDelayedReply(true); m_clientMessage = message(); QList &failedAuthentications = m_failureClientData[accountId]; Reauthenticator *reauthenticator = new Reauthenticator(failedAuthentications, extraParameters, this); m_reauthenticators[accountId] = reauthenticator; QObject::connect(reauthenticator, SIGNAL(finished(bool)), this, SLOT(onReauthenticatorFinished(bool)), Qt::QueuedConnection); reauthenticator->start(); return true; // ignored, see setDelayedReply() above. } void IndicatorServicePrivate::showNotification(const QVariantMap ¶meters) { /* Don't show more than one notification, until the error status is * cleared */ if (m_errorStatus) return; m_errorStatus = true; notifyPropertyChanged("ErrorStatus"); QString applicationName = parameters.value("DisplayName").toString(); QString summary; if (applicationName.isEmpty()) { summary = _("Applications can no longer access " "some of your Online Accounts"); } else { summary = _("Applications can no longer access " "your %1 Online Account").arg(applicationName); } QString message = _("Choose Online Accounts from the user " "menu to reinstate access to this account."); QByteArray summaryUtf8 = summary.toUtf8(); QByteArray messageUtf8 = message.toUtf8(); NotifyNotification *notification = notify_notification_new(summaryUtf8.constData(), messageUtf8.constData(), NULL); GError *error = NULL; if (!notify_notification_show(notification, &error)) { BLAME() << "Couldn't show notification:" << error->message; g_clear_error(&error); } g_object_unref(notification); } void IndicatorServicePrivate::notifyPropertyChanged(const char *propertyName) { QDBusMessage signal = QDBusMessage::createSignal(WEBCREDENTIALS_OBJECT_PATH, "org.freedesktop.DBus.Properties", "PropertiesChanged"); signal << WEBCREDENTIALS_INTERFACE; QVariantMap changedProps; changedProps.insert(QString::fromLatin1(propertyName), property(propertyName)); signal << changedProps; signal << QStringList(); QDBusConnection::sessionBus().send(signal); } void IndicatorServicePrivate::onReauthenticatorFinished(bool success) { Q_Q(IndicatorService); Reauthenticator *reauthenticator = qobject_cast(sender()); /* Find the account; searching a map by value is inefficient, but * in this case it's extremely likely that the map contains just * one element. :-) */ uint accountId = 0; QMap::const_iterator i; for (i = m_reauthenticators.constBegin(); i != m_reauthenticators.constEnd(); i++) { if (i.value() == reauthenticator) { accountId = i.key(); break; } } Q_ASSERT (accountId != 0); QDBusMessage reply = m_clientMessage.createReply(success); QDBusConnection::sessionBus().send(reply); if (success) { m_failureClientData.remove(accountId); m_failures.remove(accountId); notifyPropertyChanged("Failures"); if (m_failures.isEmpty()) { ClearErrorStatus(); Q_EMIT q->isIdleChanged(); } } m_reauthenticators.remove(accountId); reauthenticator->deleteLater(); } IndicatorService::IndicatorService(QObject *parent): QObject(parent), d_ptr(new IndicatorServicePrivate(this)) { if (m_instance == 0) { m_instance = this; } else { BLAME() << "Instantiating a second IndicatorService!"; } } IndicatorService::~IndicatorService() { m_instance = 0; delete d_ptr; } IndicatorService *IndicatorService::instance() { return m_instance; } QObject *IndicatorService::serviceObject() const { return d_ptr; } void IndicatorService::clearErrorStatus() { Q_D(IndicatorService); d->ClearErrorStatus(); } void IndicatorService::removeFailures(const QSet &accountIds) { Q_D(IndicatorService); d->RemoveFailures(accountIds); } void IndicatorService::reportFailure(uint accountId, const QVariantMap ¬ification) { Q_D(IndicatorService); d->ReportFailure(accountId, notification); } QSet IndicatorService::failures() const { Q_D(const IndicatorService); return d->m_failures; } bool IndicatorService::errorStatus() const { Q_D(const IndicatorService); return d->m_errorStatus; } bool IndicatorService::isIdle() const { Q_D(const IndicatorService); return d->m_failures.isEmpty(); } #include "indicator-service.moc" signon-ui/src/indicator-service.h0000664000175000017500000000355614615655426017261 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_INDICATOR_SERVICE_H #define SIGNON_UI_INDICATOR_SERVICE_H #include #include #include namespace SignOnUi { #define WEBCREDENTIALS_OBJECT_PATH "/com/canonical/indicators/webcredentials" #define WEBCREDENTIALS_INTERFACE "com.canonical.indicators.webcredentials" #define WEBCREDENTIALS_BUS_NAME WEBCREDENTIALS_INTERFACE class IndicatorServicePrivate; class IndicatorService: public QObject { Q_OBJECT Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) public: explicit IndicatorService(QObject *parent = 0); ~IndicatorService(); static IndicatorService *instance(); QObject *serviceObject() const; void clearErrorStatus(); void removeFailures(const QSet &accountIds); void reportFailure(uint accountId, const QVariantMap ¬ification); QSet failures() const; bool errorStatus() const; bool isIdle() const; Q_SIGNALS: void isIdleChanged(); private: IndicatorServicePrivate *d_ptr; Q_DECLARE_PRIVATE(IndicatorService) }; } // namespace Q_DECLARE_METATYPE(QSet) #endif // SIGNON_UI_INDICATOR_SERVICE_H signon-ui/src/main.cpp0000664000175000017500000001007214615655426015115 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" #include "i18n.h" #include "inactivity-timer.h" #include "indicator-service.h" #include "my-network-proxy-factory.h" #include "service.h" #include #include #include #include #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #else #include #endif using namespace SignOnUi; /* This is where signond expects to find us */ static const char serviceName[] = "com.nokia.singlesignonui"; static const char objectPath[] = "/SignonUi"; int main(int argc, char **argv) { QApplication app(argc, argv); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QtWebEngine::initialize(); #else QtWebEngineQuick::initialize(); #endif app.setApplicationName("signon-ui"); app.setQuitOnLastWindowClosed(false); /* read environment variables */ QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); if (environment.contains(QLatin1String("SSOUI_LOGGING_LEVEL"))) { bool isOk; int value = environment.value( QLatin1String("SSOUI_LOGGING_LEVEL")).toInt(&isOk); if (isOk) setLoggingLevel(value); } /* default daemonTimeout to 30 */ int daemonTimeout = 30; /* override daemonTimeout if SSOUI_DAEMON_TIMEOUT is set */ if (environment.contains(QLatin1String("SSOUI_DAEMON_TIMEOUT"))) { bool isOk; int value = environment.value( QLatin1String("SSOUI_DAEMON_TIMEOUT")).toInt(&isOk); if (isOk) daemonTimeout = value; } QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QLatin1String("/etc")); initTr(I18N_DOMAIN, NULL); /* Use a libproxy-based proxy factory; this code will no longer be * needed when https://bugreports.qt-project.org/browse/QTBUG-26295 * is fixed. */ MyNetworkProxyFactory *proxyFactory = new MyNetworkProxyFactory(); QNetworkProxyFactory::setApplicationProxyFactory(proxyFactory); Service *service = new Service(); QDBusConnection connection = QDBusConnection::sessionBus(); connection.registerService(QLatin1String(serviceName)); connection.registerObject(QLatin1String(objectPath), service, QDBusConnection::ExportAllContents); IndicatorService *indicatorService = new IndicatorService(); connection.registerService(QLatin1String(WEBCREDENTIALS_BUS_NAME)); connection.registerObject(QLatin1String(WEBCREDENTIALS_OBJECT_PATH), indicatorService->serviceObject()); InactivityTimer *inactivityTimer = 0; if (daemonTimeout > 0) { inactivityTimer = new InactivityTimer(daemonTimeout * 1000); inactivityTimer->watchObject(service); inactivityTimer->watchObject(indicatorService); QObject::connect(inactivityTimer, SIGNAL(timeout()), &app, SLOT(quit())); } int ret = app.exec(); connection.unregisterService(QLatin1String(WEBCREDENTIALS_BUS_NAME)); connection.unregisterObject(QLatin1String(WEBCREDENTIALS_OBJECT_PATH)); delete indicatorService; connection.unregisterService(QLatin1String(serviceName)); connection.unregisterObject(QLatin1String(objectPath)); delete service; delete inactivityTimer; return ret; } signon-ui/src/my-network-proxy-factory.cpp0000664000175000017500000001217714615655426021141 0ustar coucoufcoucouf/* * Copied from * https://codereview.qt-project.org/cat/29453%2C6%2Csrc/network/kernel/qnetworkproxy_libproxy.cpp%5E0 * * With minor modifications by * Alberto Mardegan */ /**************************************************************************** ** ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/ ** ** This file is part of the QtNetwork module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** GNU Lesser General Public License Usage ** This file may be used under the terms of the GNU Lesser General Public ** License version 2.1 as published by the Free Software Foundation and ** appearing in the file LICENSE.LGPL included in the packaging of this ** file. Please review the following information to ensure the GNU Lesser ** General Public License version 2.1 requirements will be met: ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. ** ** In addition, as a special exception, Nokia gives you certain additional ** rights. These rights are described in the Nokia Qt LGPL Exception ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU General ** Public License version 3.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of this ** file. Please review the following information to ensure the GNU General ** Public License version 3.0 requirements will be met: ** http://www.gnu.org/copyleft/gpl.html. ** ** Other Usage ** Alternatively, this file may be used in accordance with the terms and ** conditions contained in a signed written agreement between you and Nokia. ** ** ** ** ** ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include "my-network-proxy-factory.h" #include #include #include #include class QLibProxyWrapper { public: QLibProxyWrapper() : factory(px_proxy_factory_new()) { } ~QLibProxyWrapper() { px_proxy_factory_free(factory); } QList getProxies(const QUrl &url); private: pxProxyFactory *factory; }; Q_GLOBAL_STATIC(QLibProxyWrapper, libProxyWrapper); /* Gets the list of proxies from libproxy, converted to QUrl list. Thread safe, according to libproxy documentation. */ QList QLibProxyWrapper::getProxies(const QUrl &url) { QList ret; if (factory) { char **proxies = px_proxy_factory_get_proxies(factory, url.toEncoded()); if (proxies) { for (int i = 0; proxies[i]; i++) { ret.append(QUrl::fromEncoded(proxies[i])); free(proxies[i]); } free(proxies); } } return ret; } QList MyNetworkProxyFactory::queryProxy(const QNetworkProxyQuery &query) { QList proxyList; QUrl queryUrl; QNetworkProxy::Capabilities requiredCapabilities(0); switch (query.queryType()) { //URL requests are directly supported by libproxy case QNetworkProxyQuery::UrlRequest: queryUrl = query.url(); break; // fake URLs to get libproxy to tell us the SOCKS proxy case QNetworkProxyQuery::TcpSocket: queryUrl.setScheme(QLatin1String("tcp")); queryUrl.setHost(query.peerHostName()); queryUrl.setPort(query.peerPort()); requiredCapabilities |= QNetworkProxy::TunnelingCapability; break; case QNetworkProxyQuery::UdpSocket: queryUrl.setScheme(QLatin1String("udp")); queryUrl.setHost(query.peerHostName()); queryUrl.setPort(query.peerPort()); requiredCapabilities |= QNetworkProxy::UdpTunnelingCapability; break; default: proxyList.append(QNetworkProxy(QNetworkProxy::NoProxy)); return proxyList; } QList rawProxies = libProxyWrapper()->getProxies(queryUrl); bool haveDirectConnection = false; foreach (const QUrl& url, rawProxies) { QNetworkProxy::ProxyType type; if (url.scheme() == QLatin1String("http")) { type = QNetworkProxy::HttpProxy; } else if (url.scheme() == QLatin1String("socks") || url.scheme() == QLatin1String("socks5")) { type = QNetworkProxy::Socks5Proxy; } else if (url.scheme() == QLatin1String("ftp")) { type = QNetworkProxy::FtpCachingProxy; } else if (url.scheme() == QLatin1String("direct")) { type = QNetworkProxy::NoProxy; haveDirectConnection = true; } else { continue; //unsupported proxy type e.g. socks4 } QNetworkProxy proxy(type, url.host(), url.port(), url.userName(), url.password()); if ((proxy.capabilities() & requiredCapabilities) == requiredCapabilities) proxyList.append(proxy); } // fallback is direct connection if (proxyList.isEmpty() || !haveDirectConnection) proxyList.append(QNetworkProxy(QNetworkProxy::NoProxy)); return proxyList; } signon-ui/src/my-network-proxy-factory.h0000664000175000017500000000215114615655426020575 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_MY_NETWORK_PROXY_FACTORY_H #define SIGNON_UI_MY_NETWORK_PROXY_FACTORY_H #include class MyNetworkProxyFactory: public QNetworkProxyFactory { public: // reimplemented virtual methods QList queryProxy(const QNetworkProxyQuery &query = QNetworkProxyQuery()); }; #endif // SIGNON_UI_MY_NETWORK_PROXY_FACTORY_H signon-ui/src/network-access-manager.cpp0000664000175000017500000000262414615655426020535 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "network-access-manager.h" #include "debug.h" using namespace SignOnUi; static NetworkAccessManager *m_instance = 0; /* At the moment the only reason for using this class is reusing the NAM across * network requests. * We might want to add here proxy settings, or specialized cookie jars * integrated with the user's desktop browser. */ NetworkAccessManager::NetworkAccessManager(QObject *parent): QNetworkAccessManager(parent) { } NetworkAccessManager::~NetworkAccessManager() { } NetworkAccessManager *NetworkAccessManager::instance() { if (m_instance == 0) { m_instance = new NetworkAccessManager(); } return m_instance; } signon-ui/src/network-access-manager.h0000664000175000017500000000227114615655426020200 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_NETWORK_ACCESS_MANAGER_H #define SIGNON_UI_NETWORK_ACCESS_MANAGER_H #include #include namespace SignOnUi { class NetworkAccessManager: public QNetworkAccessManager { Q_OBJECT public: ~NetworkAccessManager(); static NetworkAccessManager *instance(); protected: explicit NetworkAccessManager(QObject *parent = 0); }; } // namespace #endif // SIGNON_UI_NETWORK_ACCESS_MANAGER_H signon-ui/src/qml/0000775000175000017500000000000014615655426014256 5ustar coucoufcoucoufsignon-ui/src/qml/DefaultPage.qml0000664000175000017500000000025614615655426017155 0ustar coucoufcoucoufimport QtQuick 2.0 Loader { id: loader anchors { fill: parent bottomMargin: osk.height } focus: true sourceComponent: browserComponent } signon-ui/src/qml/KeyboardRectangle.qml0000664000175000017500000000346514615655426020366 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ import QtQuick 2.0 Item { id: keyboardRect anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom height: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0 Behavior on height { StandardAnimation { } } function recursiveFindFocusedItem(parent) { if (parent.activeFocus) { return parent; } for (var i in parent.children) { var child = parent.children[i]; if (child.activeFocus) { return child; } var item = recursiveFindFocusedItem(child); if (item != null) { return item; } } return null; } Connections { target: Qt.inputMethod onVisibleChanged: { if (!Qt.inputMethod.visible) { var focusedItem = recursiveFindFocusedItem(keyboardRect.parent); if (focusedItem != null) { focusedItem.focus = false; } } } } } signon-ui/src/qml/MainWindow.qml0000664000175000017500000000070714615655426017051 0ustar coucoufcoucoufimport QtQuick 2.0 Item { id: root width: 600 height: 400 property var signonRequest: request Loader { id: loader property Component webView: browserComponent property Item osk: osk anchors.fill: parent focus: true source: request.pageComponentUrl } KeyboardRectangle { id: osk } Component { id: browserComponent WebView { } } } signon-ui/src/qml/ProgressBar.qml0000664000175000017500000000034714615655426017226 0ustar coucoufcoucoufimport QtQuick 2.0 Item { id: root property real value: 0 Rectangle { anchors { left: parent.left; top: parent.top; bottom: parent.bottom } color: "red" width: root.value * root.width } } signon-ui/src/qml/StandardAnimation.qml0000664000175000017500000000152114615655426020370 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ import QtQuick 2.0 NumberAnimation { duration: 300 easing.type: Easing.InOutQuad } signon-ui/src/qml/UserAgent.qml0000664000175000017500000000617414615655426016676 0ustar coucoufcoucouf/* * Copyright 2013 Canonical Ltd. * * This file is part of webbrowser-app. * * webbrowser-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * webbrowser-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import QtQuick 2.0 import QtQuick.Window 2.0 import Ubuntu.Components 0.1 import "ua-overrides.js" as Overrides /* * Useful documentation: * http://en.wikipedia.org/wiki/User_agent#Format * https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference * https://wiki.mozilla.org/B2G/User_Agent * https://github.com/mozilla-b2g/gaia/blob/master/build/ua-override-prefs.js * https://developers.google.com/chrome/mobile/docs/user-agent */ // This is an Item, not a QtObject, because it needs information about the Screen. Item { // %1: form factor (Mobile, Tablet, Desktop) // %2: WebKit version readonly property string _template: "Mozilla/5.0 (Ubuntu; %1) WebKit/%2" // See Source/WebCore/Configurations/Version.xcconfig in QtWebKit’s source tree // TODO: determine this value at runtime readonly property string _webkitVersion: "537.21" // FIXME: this is a quick hack that will become increasingly unreliable // as we support more devices, so we need a better solution for this // FIXME: only handling phone and tablet for now, need to handle desktop too readonly property string _formFactor: (Screen.width >= units.gu(60)) ? "Tablet" : "Mobile" property string defaultUA: _template.arg(_formFactor).arg(_webkitVersion) property var overrides: Overrides.overrides function getDomain(url) { var domain = url.toString() var indexOfScheme = domain.indexOf("://") if (indexOfScheme !== -1) { domain = domain.slice(indexOfScheme + 3) } var indexOfPath = domain.indexOf("/") if (indexOfPath !== -1) { domain = domain.slice(0, indexOfPath) } return domain } function getDomains(domain) { var components = domain.split(".") var domains = [] for (var i = 0; i < components.length; i++) { domains.push(components.slice(i).join(".")) } return domains } function getUAString(url) { var ua = defaultUA var domains = getDomains(getDomain(url)) for (var i = 0; i < domains.length; i++) { var domain = domains[i] if (domain in overrides) { var form = overrides[domain] if (typeof form == "string") { return form } else if (typeof form == "object") { return ua.replace(form[0], form[1]) } } } return ua } } signon-ui/src/qml/WebView.qml0000664000175000017500000000201414615655426016336 0ustar coucoufcoucoufimport QtQuick 2.0 import QtWebEngine 1.1 WebEngineView { id: root property bool lastLoadFailed: false Component.onCompleted: url = signonRequest.startUrl onLoadingChanged: loadingInfo => { console.log("Loading changed") if (loading && !lastLoadFailed) { signonRequest.onLoadStarted() } else if (loadingInfo.status == WebEngineView.LoadSucceededStatus) { lastLoadFailed = false signonRequest.onLoadFinished(true) } else if (loadingInfo.status == WebEngineView.LoadFailedStatus) { lastLoadFailed = true signonRequest.onLoadFinished(false) } } onUrlChanged: signonRequest.currentUrl = url profile: WebEngineProfile { cachePath: rootDir persistentStoragePath: rootDir } ProgressBar { anchors.top: parent.top anchors.left: parent.left anchors.right: parent.right height: 6 visible: root.loading value: root.loadProgress / 100 } } signon-ui/src/qml/browser-process.cpp0000664000175000017500000001676014615655426020133 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "browser-process.h" #include "debug.h" #include "dialog.h" #include "i18n.h" #include "remote-request-interface.h" #include #include #include #include #include #include using namespace SignOnUi; namespace SignOnUi { class BrowserProcessPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(BrowserProcess) Q_PROPERTY(QUrl pageComponentUrl READ pageComponentUrl CONSTANT) Q_PROPERTY(QUrl currentUrl READ currentUrl WRITE setCurrentUrl) Q_PROPERTY(QUrl startUrl READ startUrl CONSTANT) Q_PROPERTY(QUrl finalUrl READ finalUrl CONSTANT) public: BrowserProcessPrivate(BrowserProcess *request); ~BrowserProcessPrivate(); void processClientRequest(); void setCurrentUrl(const QUrl &url); QUrl pageComponentUrl() const; QUrl currentUrl() const { return m_currentUrl; } QUrl startUrl() const { return m_startUrl; } QUrl finalUrl() const { return m_finalUrl; } QUrl responseUrl() const { return m_responseUrl; } WId windowId() const { return m_clientData[SSOUI_KEY_WINDOWID].toUInt(); } bool embeddedUi() const { return m_clientData[SSOUI_KEY_EMBEDDED].toBool(); } public Q_SLOTS: void onLoadStarted(); void onLoadFinished(bool ok); void cancel(); private Q_SLOTS: void start(const QVariantMap ¶ms); void onFailTimer(); void onFinished(); private: void buildDialog(const QVariantMap ¶ms); private: Dialog *m_dialog; QVariantMap m_clientData; QUrl m_currentUrl; QUrl m_startUrl; QUrl m_finalUrl; QUrl m_responseUrl; QString m_host; QFile m_input; QFile m_output; RemoteRequestServer m_server; QTimer m_failTimer; mutable BrowserProcess *q_ptr; }; } // namespace BrowserProcessPrivate::BrowserProcessPrivate(BrowserProcess *process): QObject(process), m_dialog(0), q_ptr(process) { m_failTimer.setSingleShot(true); m_failTimer.setInterval(3000); QObject::connect(&m_failTimer, SIGNAL(timeout()), this, SLOT(onFailTimer())); } BrowserProcessPrivate::~BrowserProcessPrivate() { delete m_dialog; } QUrl BrowserProcessPrivate::pageComponentUrl() const { /* We define the X-PageComponent key to let the clients override the QML * component to be used to build the authentication page. * To prevent a malicious client to show it's own UI, we require that the * file path begins with "/usr/share/signon-ui/" (where Ubuntu click * packages cannot install files). */ QUrl providedUrl = m_clientData.value("X-PageComponent").toString(); if (providedUrl.isValid() && providedUrl.isLocalFile() && providedUrl.path().startsWith("/usr/share/signon-ui/")) { return providedUrl; } else { return QStringLiteral("DefaultPage.qml"); } } void BrowserProcessPrivate::processClientRequest() { TRACE(); m_input.open(stdin, QIODevice::ReadOnly); m_output.open(stdout, QIODevice::WriteOnly); QObject::connect(&m_server, SIGNAL(started(const QVariantMap&)), this, SLOT(start(const QVariantMap&))); QObject::connect(&m_server, SIGNAL(canceled()), this, SLOT(cancel())); /* This effectively starts the communication with the client */ m_server.setChannels(&m_input, &m_output); } void BrowserProcessPrivate::setCurrentUrl(const QUrl &url) { TRACE() << "Url changed:" << url; m_failTimer.stop(); if (url.host() == m_finalUrl.host() && url.path() == m_finalUrl.path()) { m_responseUrl = url; if (!m_dialog->isVisible()) { /* Do not show the notification page. */ m_dialog->accept(); } else { /* Replace the web page with an information screen */ /* TODO */ m_dialog->accept(); } } } void BrowserProcessPrivate::onLoadStarted() { m_failTimer.stop(); } void BrowserProcessPrivate::onLoadFinished(bool ok) { TRACE() << "Load finished" << ok; if (!ok) { m_failTimer.start(); return; } if (!m_dialog->isVisible()) { if (m_responseUrl.isEmpty()) { Dialog::ShowMode mode = (windowId() == 0) ? Dialog::TopLevel : embeddedUi() ? Dialog::Embedded : Dialog::Transient; m_dialog->show(windowId(), mode); } else { onFinished(); } } } void BrowserProcessPrivate::start(const QVariantMap ¶ms) { TRACE() << params; if (params.contains(SSOUI_KEY_CLIENT_DATA)) { m_clientData = params[SSOUI_KEY_CLIENT_DATA].toMap(); } m_finalUrl = params.value(SSOUI_KEY_FINALURL).toString(); m_startUrl = params.value(SSOUI_KEY_OPENURL).toString(); buildDialog(params); QObject::connect(m_dialog, SIGNAL(finished(int)), this, SLOT(onFinished())); QUrl webview("qrc:/MainWindow.qml"); QDir qmlDir("/usr/share/signon-ui/qml"); if (qmlDir.exists()) { QFileInfo qmlFile(qmlDir.absolutePath() + "/MainWindow.qml"); if (qmlFile.exists()) webview.setUrl(qmlFile.absoluteFilePath()); } m_dialog->rootContext()->setContextProperty("request", this); m_dialog->setSource(webview); } void BrowserProcessPrivate::cancel() { Q_Q(BrowserProcess); TRACE() << "Client requested to cancel"; m_server.setCanceled(); if (m_dialog) { m_dialog->close(); } Q_EMIT q->finished(); } void BrowserProcessPrivate::onFailTimer() { Q_Q(BrowserProcess); TRACE() << "Page loading failed"; m_server.setResult(QVariantMap()); if (m_dialog) { m_dialog->close(); } Q_EMIT q->finished(); } void BrowserProcessPrivate::onFinished() { Q_Q(BrowserProcess); TRACE() << "Browser dialog closed"; QVariantMap reply; QUrl url = m_responseUrl.isEmpty() ? m_currentUrl : m_responseUrl; reply[SSOUI_KEY_URLRESPONSE] = url.toString(); m_server.setResult(reply); m_dialog->close(); Q_EMIT q->finished(); } void BrowserProcessPrivate::buildDialog(const QVariantMap ¶ms) { m_dialog = new Dialog; QString title; if (params.contains(SSOUI_KEY_TITLE)) { title = params[SSOUI_KEY_TITLE].toString(); } else if (params.contains(SSOUI_KEY_CAPTION)) { title = _("Web authentication for %1"). arg(params[SSOUI_KEY_CAPTION].toString()); } else { title = _("Web authentication"); } m_dialog->setTitle(title); TRACE() << "Dialog was built"; } BrowserProcess::BrowserProcess(QObject *parent): QObject(parent), d_ptr(new BrowserProcessPrivate(this)) { } BrowserProcess::~BrowserProcess() { } void BrowserProcess::processClientRequest() { Q_D(BrowserProcess); d->processClientRequest(); } #include "browser-process.moc" signon-ui/src/qml/browser-process.h0000664000175000017500000000232214615655426017565 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_BROWSER_PROCESS_H #define SIGNON_UI_BROWSER_PROCESS_H #include namespace SignOnUi { class BrowserProcessPrivate; class BrowserProcess: public QObject { Q_OBJECT public: BrowserProcess(QObject *parent = 0); ~BrowserProcess(); void processClientRequest(); Q_SIGNALS: void finished(); private: BrowserProcessPrivate *d_ptr; Q_DECLARE_PRIVATE(BrowserProcess) }; } // namespace #endif // SIGNON_UI_BROWSER_PROCESS_H signon-ui/src/qml/browser-process.pro0000664000175000017500000000215014615655426020135 0ustar coucoufcoucoufinclude(../../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) TEMPLATE = app TARGET = browser-process target.path = $${LIBEXECDIR}/signon-ui INSTALLS += target I18N_DOMAIN = signon-ui CONFIG += \ link_pkgconfig \ qt QT += \ core \ gui \ quick PKGCONFIG += \ signon-plugins-common INCLUDEPATH += .. HEADERS = \ browser-process.h \ debug.h \ dialog.h \ ../i18n.h \ ../remote-request-interface.h SOURCES = \ browser-process.cpp \ dialog.cpp \ main.cpp \ ../i18n.cpp \ ../remote-request-interface.cpp DEFINES += \ DEBUG_ENABLED \ I18N_DOMAIN=\\\"$${I18N_DOMAIN}\\\" CONFIG(force-foreign-qwindow) { DEFINES += FORCE_FOREIGN_QWINDOW } OTHER_FILES += \ DefaultPage.qml \ KeyboardRectangle.qml \ MainWindow.qml \ StandardAnimation.qml \ UserAgent.qml \ WebView.qml \ ua-overrides.js RESOURCES += \ qml.qrc QMAKE_SUBSTITUTES += \ signon-ui-browser-process.desktop.in desktop.path = $${INSTALL_PREFIX}/share/applications desktop.files += signon-ui-browser-process.desktop INSTALLS += desktop signon-ui/src/qml/debug.h0000664000175000017500000000214414615655426015516 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_DEBUG_H #define SIGNON_UI_DEBUG_H #include #ifdef DEBUG_ENABLED #define TRACE() \ qDebug() << __FILE__ << __LINE__ << __func__ #define BLAME() \ qCritical() << __FILE__ << __LINE__ << __func__ #else #define TRACE() while (0) qDebug() #define BLAME() while (0) qDebug() #endif #endif // SIGNON_UI_DEBUG_H signon-ui/src/qml/main.cpp0000664000175000017500000000374514615655426015717 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "browser-process.h" #include "debug.h" #include #include #include #include #include using namespace SignOnUi; void stderrMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg) { Q_UNUSED(context); QByteArray localMsg = msg.toLocal8Bit(); switch (type) { case QtDebugMsg: fprintf(stderr, "Debug: %s\n", localMsg.constData()); break; case QtWarningMsg: fprintf(stderr, "Warning: %s\n", localMsg.constData()); break; case QtCriticalMsg: fprintf(stderr, "Critical: %s\n", localMsg.constData()); break; case QtFatalMsg: fprintf(stderr, "Fatal: %s\n", localMsg.constData()); abort(); } } int main(int argc, char **argv) { qInstallMessageHandler(stderrMessage); TRACE() << "started"; QGuiApplication app(argc, argv); app.setQuitOnLastWindowClosed(false); fcntl(fileno(stdin), F_SETFL, fcntl(fileno(stdin), F_GETFL, 0) | O_NONBLOCK); BrowserProcess browserProcess; QObject::connect(&browserProcess, SIGNAL(finished()), &app, SLOT(quit())); browserProcess.processClientRequest(); return app.exec(); } signon-ui/src/qml/qml.qrc0000664000175000017500000000043614615655426015561 0ustar coucoufcoucouf DefaultPage.qml KeyboardRectangle.qml MainWindow.qml ProgressBar.qml StandardAnimation.qml WebView.qml signon-ui/src/qml/signon-ui-browser-process.desktop.in0000664000175000017500000000033514615655426023324 0ustar coucoufcoucouf[Desktop Entry] Encoding=UTF-8 Version=1.0 Name=Account authentication Comment=Login to online accounts Exec=$${target.path}/$$TARGET Icon= Type=Application Terminal=false NoDisplay=true X-Ubuntu-Gettext-Domain=signon-ui signon-ui/src/qml/ua-overrides.js0000664000175000017500000001067514615655426017232 0ustar coucoufcoucouf/* * Copyright 2013 Canonical Ltd. * * This file is part of webbrowser-app. * * webbrowser-app is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 3. * * webbrowser-app is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ .pragma library // B2G’s list of overrides: https://github.com/mozilla-b2g/gaia/blob/master/build/ua-override-prefs.js // List of user agent string overrides in the form of an object. // Each key is a domain name for which the default user agent string doesn’t // work well enough. Values can either be a string (full override) or an array // containing two values that are passed to the String.replace method (the // first value may be either a string or a regular expression, the second value // must be a string). // Examples of valid entries: // "example.org": "full override" // "example.com": ["Ubuntu", "Ubuntu Edge"] // "google.com": [/mobi/i, "b"] // The original list was initially built from the top 100 entries // at http://www.alexa.com/topsites (2013-08-16), using Chrome on // Android as a reference. var overrides = { "mail.google.com": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"], "google.com": ["Mobile", "Android; Mobile"], "youtube.com": ["Mobile", "Android; Mobile"], "yahoo.com": ["Mobile", "Android; Mobile"], "baidu.com": ["Mobile", "Android; Mobile"], "qq.com": [/WebKit\/[.0-9]*/, "Apple$& Mobile"], "amazon.com": ["Mobile", "Android; Mobile"], "linkedin.com": ["Mobile", "Android; Mobile"], "blogspot.com": ["Mobile", "Android; Mobile"], "taobao.com": ["Mobile", "Android; Mobile"], "google.co.in": ["Mobile", "Android; Mobile"], "bing.com": ["Mobile", "Android; Mobile"], "yahoo.co.jp": ["Ubuntu", "Linux; Android 4; Galaxy Build/"], "yandex.ru": ["Mobile", "Android; Mobile"], "sina.com.cn": ["Mobile", "Android; Mobile"], "ebay.com": ["Mobile", "Android; Mobile"], "google.de": ["Mobile", "Android; Mobile"], "tumblr.com": ["Mobile", "Android; Mobile"], "google.co.uk": ["Mobile", "Android; Mobile"], "msn.com": ["Mobile", "Android; Mobile"], "google.fr": ["Mobile", "Android; Mobile"], "mail.ru": ["Ubuntu", "Linux; Android 4; Galaxy Build/"], "google.com.br": ["Mobile", "Android; Mobile"], "google.co.jp": ["Mobile", "Android; Mobile"], "hao123.com": ["Mobile", "Android; Mobile"], "ask.com": ["Mobile", "Android; Mobile"], "google.com.hk": ["Mobile", "Android; Mobile"], "google.ru": ["Mobile", "Android; Mobile"], "blogger.com": ["Mobile", "Android; Mobile"], "imdb.com": ["Mobile", "Android; Mobile"], "google.it": ["Mobile", "Android; Mobile"], "google.es": ["Mobile", "Android; Mobile"], "amazon.co.jp": ["Mobile", "Android; Mobile"], "tmall.com": ["Mobile", "Android; Mobile"], "fc2.com": ["Mobile", "Android; Mobile"], "google.com.mx": ["Mobile", "Android; Mobile"], "google.ca": ["Mobile", "Android; Mobile"], "soso.com": ["Mobile", "Android; Mobile"], "delta-search.com": ["Mobile", "Android; Mobile"], "odnoklassniki.ru": ["Mobile", "Android; Mobile"], "alibaba.com": ["Mobile", "Android; Mobile"], "flickr.com": ["Mobile", "Android; Mobile"], "amazon.de": ["Mobile", "Android; Mobile"], "blogspot.in": ["Mobile", "Android; Mobile"], "ifeng.com": ["Mobile", "Android; Mobile"], "360.cn": ["Mobile", "Android; Mobile"], "google.com.tr": ["Mobile", "Android; Mobile"], "google.com.au": ["Mobile", "Android; Mobile"], "youku.com": ["Mobile", "Android; Mobile"], "ebay.de": ["Mobile", "Android; Mobile"], "uol.com.br": ["Mobile", "Android; Mobile"], "aol.com": ["Mobile", "Android; Mobile"], "google.pl": ["Mobile", "Android; Mobile"], "alipay.com": ["Mobile", "Android; Mobile"], "dailymotion.com": ["Mobile", "Android; Mobile Safari"], "amazon.co.uk": ["Mobile", "Android; Mobile"], "ebay.co.uk": ["Mobile", "Android; Mobile"], "facebook.com": [/WebKit\/[.0-9]*/, "Apple$& Firefox/18"], "nytimes.com": ["Mobile", "Android; Mobile Safari"], }; signon-ui/src/qquick-dialog.cpp0000664000175000017500000000245214615655426016726 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "qquick-dialog.h" #include "debug.h" #include using namespace SignOnUi::QQuick; Dialog::Dialog(QWindow *parent): QQuickView(parent) { setResizeMode(QQuickView::SizeRootObjectToView); } Dialog::~Dialog() { } void Dialog::accept() { done(Dialog::Accepted); } void Dialog::reject() { done(Dialog::Rejected); } void Dialog::done(int result) { setVisible(false); Q_EMIT finished(result); } bool Dialog::event(QEvent *e) { if (e->type() == QEvent::Close) { reject(); } return QQuickView::event(e); } signon-ui/src/qquick-dialog.h0000664000175000017500000000260714615655426016375 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2014 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_QQUICK_DIALOG_H #define SIGNON_UI_QQUICK_DIALOG_H #include #include namespace SignOnUi { namespace QQuick { class Dialog: public QQuickView { Q_OBJECT public: enum DialogCode { Rejected = 0, Accepted, }; enum ShowMode { TopLevel = 0, Transient, Embedded, }; explicit Dialog(QWindow *parent = 0); ~Dialog(); public Q_SLOTS: void accept(); void reject(); void done(int result); Q_SIGNALS: void finished(int result); protected: bool event(QEvent *e); }; } // namespace } // namespace #endif // SIGNON_UI_QQUICK_DIALOG_H signon-ui/src/reauthenticator.cpp0000664000175000017500000001032014615655426017366 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "reauthenticator.h" #include "debug.h" #include #include using namespace SignOnUi; using namespace SignOn; namespace SignOnUi { class ReauthenticatorPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(Reauthenticator) public: ReauthenticatorPrivate(const QList &clientData, const QVariantMap &extraParameters, Reauthenticator *reauthenticator); ~ReauthenticatorPrivate(); void start(); private: void checkFinished(); private Q_SLOTS: void onError(const SignOn::Error &error); void onResponse(const SignOn::SessionData &response); private: mutable Reauthenticator *q_ptr; QList m_clientData; QVariantMap m_extraParameters; int m_errorCount; int m_responseCount; }; } // namespace ReauthenticatorPrivate::ReauthenticatorPrivate( const QList &clientData, const QVariantMap &extraParameters, Reauthenticator *request): QObject(request), q_ptr(request), m_clientData(clientData), m_extraParameters(extraParameters), m_errorCount(0), m_responseCount(0) { } ReauthenticatorPrivate::~ReauthenticatorPrivate() { } void ReauthenticatorPrivate::start() { foreach (const AuthData &authData, m_clientData) { Identity *identity = Identity::existingIdentity(authData.identity, this); if (identity == 0) { m_errorCount++; continue; } AuthSession *authSession = identity->createSession(authData.method); if (authSession == 0) { m_errorCount++; continue; } QObject::connect(authSession, SIGNAL(error(const SignOn::Error &)), this, SLOT(onError(const SignOn::Error &))); QObject::connect(authSession, SIGNAL(response(const SignOn::SessionData &)), this, SLOT(onResponse(const SignOn::SessionData &))); /* Prepare the session data, adding the extra parameters. */ QVariantMap sessionData = authData.sessionData; QVariantMap::const_iterator i; for (i = m_extraParameters.constBegin(); i != m_extraParameters.constEnd(); i++) { sessionData[i.key()] = i.value(); } /* Start the session right now; signon-ui is queueing them anyway. */ authSession->process(sessionData, authData.mechanism); } checkFinished(); } void ReauthenticatorPrivate::checkFinished() { Q_Q(Reauthenticator); if (m_errorCount + m_responseCount < m_clientData.count()) return; Q_EMIT q->finished(m_errorCount == 0); } void ReauthenticatorPrivate::onError(const SignOn::Error &error) { TRACE() << "Got error:" << error.message(); m_errorCount++; checkFinished(); } void ReauthenticatorPrivate::onResponse( const SignOn::SessionData &response) { TRACE() << "Got response:" << response.toMap(); m_responseCount++; checkFinished(); } Reauthenticator::Reauthenticator(const QList &clientData, const QVariantMap &extraParameters, QObject *parent): QObject(parent), d_ptr(new ReauthenticatorPrivate(clientData, extraParameters, this)) { } Reauthenticator::~Reauthenticator() { } void Reauthenticator::start() { Q_D(Reauthenticator); d->start(); } #include "reauthenticator.moc" signon-ui/src/reauthenticator.h0000664000175000017500000000276014615655426017044 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_REAUTHENTICATOR_H #define SIGNON_UI_REAUTHENTICATOR_H #include #include #include namespace SignOnUi { struct AuthData { quint32 identity; QString method; QString mechanism; QVariantMap sessionData; }; class ReauthenticatorPrivate; class Reauthenticator: public QObject { Q_OBJECT public: Reauthenticator(const QList &clientData, const QVariantMap &extraParameters, QObject *parent = 0); ~Reauthenticator(); public Q_SLOTS: void start(); Q_SIGNALS: void finished(bool success); private: ReauthenticatorPrivate *d_ptr; Q_DECLARE_PRIVATE(Reauthenticator) }; } // namespace #endif // SIGNON_UI_REAUTHENTICATOR_H signon-ui/src/remote-request-interface.cpp0000664000175000017500000002071014615655426021110 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "remote-request-interface.h" #include "debug.h" #include #include #include #include using namespace SignOnUi; namespace SignOnUi { static const QByteArray welcomeMessage = "SsoUi"; class IpcHandler: public QObject { Q_OBJECT public: enum Code { Start = 1, Cancel, SetResult, SetCanceled, }; IpcHandler(); ~IpcHandler(); void setChannels(QIODevice *readChannel, QIODevice *writeChannel); void write(const QByteArray &data); Q_SIGNALS: void dataReady(const QByteArray &data); private Q_SLOTS: void onReadyRead(); private: bool waitWelcomeMessage(); private: QIODevice *m_readChannel; QIODevice *m_writeChannel; int m_expectedLength; bool m_gotWelcomeMessage; QByteArray m_readBuffer; }; } // namespace IpcHandler::IpcHandler(): QObject(), m_readChannel(0), m_writeChannel(0), m_expectedLength(0), m_gotWelcomeMessage(false) { } IpcHandler::~IpcHandler() { } void IpcHandler::setChannels(QIODevice *readChannel, QIODevice *writeChannel) { m_readChannel = readChannel; m_writeChannel = writeChannel; QObject::connect(m_readChannel, SIGNAL(readyRead()), this, SLOT(onReadyRead())); /* QFile need special handling */ QFile *file = qobject_cast(m_readChannel); if (file != 0) { QSocketNotifier *notifier = new QSocketNotifier(file->handle(), QSocketNotifier::Read, this); QObject::connect(notifier, SIGNAL(activated(int)), this, SLOT(onReadyRead())); } onReadyRead(); if (m_writeChannel != 0) { m_writeChannel->write(welcomeMessage); } } void IpcHandler::write(const QByteArray &data) { int length = data.count(); m_writeChannel->write((char *)&length, sizeof(length)); m_writeChannel->write(data); } void IpcHandler::onReadyRead() { while (true) { if (m_expectedLength == 0) { /* We are beginning a new read */ /* skip all noise */ if (!waitWelcomeMessage()) break; int length; int bytesRead = m_readChannel->read((char *)&length, sizeof(length)); if (bytesRead < int(sizeof(length))) break; m_expectedLength = length; m_readBuffer.clear(); } int neededBytes = m_expectedLength - m_readBuffer.length(); QByteArray buffer = m_readChannel->read(neededBytes); m_readBuffer += buffer; if (buffer.length() < neededBytes) break; if (m_readBuffer.length() == m_expectedLength) { Q_EMIT dataReady(m_readBuffer); m_expectedLength = 0; } } } bool IpcHandler::waitWelcomeMessage() { if (m_gotWelcomeMessage) return true; /* All Qt applications on the Nexus 4 write some just to stdout when * starting. So, skip all input until a well-defined welcome message is * found */ QByteArray buffer; int startCheckIndex = 0; do { buffer = m_readChannel->peek(40); int found = buffer.indexOf(welcomeMessage, startCheckIndex); int skip = (found >= 0) ? found : buffer.length() - welcomeMessage.length(); if (found >= 0) { buffer = m_readChannel->read(skip + welcomeMessage.length()); m_gotWelcomeMessage = true; return true; } if (skip > 0) { buffer = m_readChannel->read(skip); } else { buffer.clear(); } } while (!buffer.isEmpty()); return false; } namespace SignOnUi { class RemoteRequestClientPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(RemoteRequestClient) public: RemoteRequestClientPrivate(RemoteRequestClient *client); ~RemoteRequestClientPrivate() {}; private Q_SLOTS: void onDataReady(const QByteArray &data); private: IpcHandler m_handler; mutable RemoteRequestClient *q_ptr; }; } // namespace RemoteRequestClientPrivate::RemoteRequestClientPrivate(RemoteRequestClient *client): QObject(client), q_ptr(client) { QObject::connect(&m_handler, SIGNAL(dataReady(const QByteArray&)), this, SLOT(onDataReady(const QByteArray&))); } void RemoteRequestClientPrivate::onDataReady(const QByteArray &data) { Q_Q(RemoteRequestClient); QDataStream dataStream(data); // All messages start with the operation code int code; dataStream >> code; if (code == IpcHandler::SetResult) { QVariantMap result; dataStream >> result; Q_EMIT q->result(result); } else if (code == IpcHandler::SetCanceled) { Q_EMIT q->canceled(); } else { qWarning() << "Unsupported opcode" << code; } } RemoteRequestClient::RemoteRequestClient(QObject *parent): QObject(parent), d_ptr(new RemoteRequestClientPrivate(this)) { } RemoteRequestClient::~RemoteRequestClient() { } void RemoteRequestClient::setChannels(QIODevice *readChannel, QIODevice *writeChannel) { Q_D(RemoteRequestClient); d->m_handler.setChannels(readChannel, writeChannel); } void RemoteRequestClient::start(const QVariantMap ¶meters) { Q_D(RemoteRequestClient); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << int(IpcHandler::Start); dataStream << parameters; d->m_handler.write(data); } void RemoteRequestClient::cancel() { Q_D(RemoteRequestClient); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << int(IpcHandler::Cancel); d->m_handler.write(data); } namespace SignOnUi { class RemoteRequestServerPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(RemoteRequestServer) public: RemoteRequestServerPrivate(RemoteRequestServer *server); ~RemoteRequestServerPrivate() {}; private Q_SLOTS: void onDataReady(const QByteArray &data); private: IpcHandler m_handler; mutable RemoteRequestServer *q_ptr; }; } // namespace RemoteRequestServerPrivate::RemoteRequestServerPrivate(RemoteRequestServer *server): QObject(server), q_ptr(server) { QObject::connect(&m_handler, SIGNAL(dataReady(const QByteArray&)), this, SLOT(onDataReady(const QByteArray&))); } void RemoteRequestServerPrivate::onDataReady(const QByteArray &data) { Q_Q(RemoteRequestServer); QDataStream dataStream(data); // All messages start with the operation code int code; dataStream >> code; if (code == IpcHandler::Start) { QVariantMap parameters; dataStream >> parameters; Q_EMIT q->started(parameters); } else if (code == IpcHandler::Cancel) { Q_EMIT q->canceled(); } else { qWarning() << "Unsupported opcode" << code; } } RemoteRequestServer::RemoteRequestServer(QObject *parent): QObject(parent), d_ptr(new RemoteRequestServerPrivate(this)) { } RemoteRequestServer::~RemoteRequestServer() { } void RemoteRequestServer::setChannels(QIODevice *readChannel, QIODevice *writeChannel) { Q_D(RemoteRequestServer); d->m_handler.setChannels(readChannel, writeChannel); } void RemoteRequestServer::setResult(const QVariantMap &result) { Q_D(RemoteRequestServer); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << int(IpcHandler::SetResult); dataStream << result; d->m_handler.write(data); } void RemoteRequestServer::setCanceled() { Q_D(RemoteRequestServer); QByteArray data; QDataStream dataStream(&data, QIODevice::WriteOnly); dataStream << int(IpcHandler::SetCanceled); d->m_handler.write(data); } #include "remote-request-interface.moc" signon-ui/src/remote-request-interface.h0000664000175000017500000000365014615655426020561 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_REMOTE_REQUEST_INTERFACE_H #define SIGNON_UI_REMOTE_REQUEST_INTERFACE_H #include #include namespace SignOnUi { class RemoteRequestClientPrivate; class RemoteRequestClient: public QObject { Q_OBJECT public: RemoteRequestClient(QObject *parent = 0); ~RemoteRequestClient(); void setChannels(QIODevice *readChannel, QIODevice *writeChannel); void start(const QVariantMap ¶meters); void cancel(); Q_SIGNALS: void result(const QVariantMap &result); void canceled(); private: RemoteRequestClientPrivate *d_ptr; Q_DECLARE_PRIVATE(RemoteRequestClient) }; class RemoteRequestServerPrivate; class RemoteRequestServer: public QObject { Q_OBJECT public: RemoteRequestServer(QObject *parent = 0); ~RemoteRequestServer(); void setChannels(QIODevice *readChannel, QIODevice *writeChannel); void setResult(const QVariantMap &result); void setCanceled(); Q_SIGNALS: void started(const QVariantMap ¶meters); void canceled(); private: RemoteRequestServerPrivate *d_ptr; Q_DECLARE_PRIVATE(RemoteRequestServer) }; } // namespace #endif // SIGNON_UI_REMOTE_REQUEST_INTERFACE_H signon-ui/src/request.cpp0000664000175000017500000002370114615655426015664 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #define HAS_FOREIGN_QWINDOW (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0) || \ defined(FORCE_FOREIGN_QWINDOW)) #include "request.h" #include "browser-request.h" #include "debug.h" #include "dialog-request.h" #include "errors.h" #include "indicator-service.h" #ifndef UNIT_TESTS #include "webcredentials_interface.h" #else #include "fake-webcredentials-interface.h" #endif #include #include #include #include #include #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) #include #include #endif #if HAS_FOREIGN_QWINDOW #include #endif #include #include using namespace SignOnUi; using namespace com::canonical; namespace SignOnUi { class RequestPrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(Request) public: RequestPrivate(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, Request *request); ~RequestPrivate(); WId windowId() const { return m_clientData[SSOUI_KEY_WINDOWID].toUInt(); } bool embeddedUi() const { return m_clientData[SSOUI_KEY_EMBEDDED].toBool(); } private Q_SLOTS: void onIndicatorCallFinished(QDBusPendingCallWatcher *watcher); private: bool setWindow(QWindow *window); Accounts::Account *findAccount(); bool dispatchToIndicator(); void onIndicatorCallSucceeded(); private: mutable Request *q_ptr; QDBusConnection m_connection; QDBusMessage m_message; QVariantMap m_parameters; QVariantMap m_clientData; bool m_inProgress; Accounts::Manager *m_accountManager; QPointer m_window; }; } // namespace RequestPrivate::RequestPrivate(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, Request *request): QObject(request), q_ptr(request), m_connection(connection), m_message(message), m_parameters(parameters), m_inProgress(false), m_accountManager(0), m_window(0) { if (parameters.contains(SSOUI_KEY_CLIENT_DATA)) { QVariant variant = parameters[SSOUI_KEY_CLIENT_DATA]; m_clientData = (variant.type() == QVariant::Map) ? variant.toMap() : qdbus_cast(variant.value()); } } RequestPrivate::~RequestPrivate() { } bool RequestPrivate::setWindow(QWindow *window) { if (m_window != 0) { BLAME() << "Widget already set"; return false; } m_window = window; #if HAS_FOREIGN_QWINDOW if (embeddedUi() && windowId() != 0) { TRACE() << "Requesting window embedding"; QWindow *host = QWindow::fromWinId(windowId()); window->show(); window->setParent(host); return true; } #endif /* If the window has no parent and the webcredentials indicator service is * up, dispatch the request to it. */ if (windowId() == 0 && dispatchToIndicator()) { return false; } window->setModality(Qt::WindowModal); window->show(); #if HAS_FOREIGN_QWINDOW if (windowId() != 0) { TRACE() << "Requesting window reparenting"; QWindow *parent = QWindow::fromWinId(windowId()); window->setTransientParent(parent); } #endif return true; } Accounts::Account *RequestPrivate::findAccount() { if (!m_parameters.contains(SSOUI_KEY_IDENTITY)) return 0; uint identity = m_parameters.value(SSOUI_KEY_IDENTITY).toUInt(); if (identity == 0) return 0; /* Find the account using this identity. * FIXME: there might be more than one! */ if (m_accountManager == 0) { m_accountManager = new Accounts::Manager(this); } foreach (Accounts::AccountId accountId, m_accountManager->accountList()) { Accounts::Account *account = m_accountManager->account(accountId); if (account == 0) continue; QVariant value(QVariant::UInt); if (account->value("CredentialsId", value) != Accounts::NONE && value.toUInt() == identity) { return account; } } // Not found return 0; } bool RequestPrivate::dispatchToIndicator() { Q_Q(Request); Accounts::Account *account = findAccount(); if (account == 0) { return false; } QVariantMap notification; notification["DisplayName"] = account->displayName(); notification["ClientData"] = m_clientData; notification["Identity"] = q->identity(); notification["Method"] = q->method(); notification["Mechanism"] = q->mechanism(); indicators::webcredentials *webcredentialsIf = new indicators::webcredentials(WEBCREDENTIALS_BUS_NAME, WEBCREDENTIALS_OBJECT_PATH, m_connection, this); QDBusPendingReply<> reply = webcredentialsIf->ReportFailure(account->id(), notification); if (reply.isFinished()) { if (reply.isError() && /* if this is a fake D-Bus interface, we get the * "Disconnected" error. */ reply.error().type() != QDBusError::Disconnected) { BLAME() << "Error dispatching to indicator:" << reply.error().message(); return false; } else { onIndicatorCallSucceeded(); return true; } } QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this); QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), this, SLOT(onIndicatorCallFinished(QDBusPendingCallWatcher*))); return true; } void RequestPrivate::onIndicatorCallFinished(QDBusPendingCallWatcher *watcher) { if (watcher->isError()) { /* if the notification could not be delivered to the indicator, show * the widget. */ if (m_window != 0) m_window->show(); } else { onIndicatorCallSucceeded(); } } void RequestPrivate::onIndicatorCallSucceeded() { Q_Q(Request); /* the account has been reported as failing. We can now close this * request, and tell the application that UI interaction is forbidden. */ QVariantMap result; result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_FORBIDDEN; q->setResult(result); } Request *Request::newRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent) { if (parameters.contains(SSOUI_KEY_OPENURL)) { return new BrowserRequest(connection, message, parameters, parent); } else { return new DialogRequest(connection, message, parameters, parent); } } Request::Request(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent): QObject(parent), d_ptr(new RequestPrivate(connection, message, parameters, this)) { } Request::~Request() { } QString Request::id(const QVariantMap ¶meters) { return parameters[SSOUI_KEY_REQUESTID].toString(); } QString Request::id() const { Q_D(const Request); return Request::id(d->m_parameters); } void Request::setWidget(QWidget *widget) { Q_D(Request); if (d->setWindow(widget->windowHandle())) { widget->show(); } } void Request::setWindow(QWindow *window) { Q_D(Request); d->setWindow(window); } uint Request::identity() const { Q_D(const Request); return d->m_parameters.value(SSOUI_KEY_IDENTITY).toUInt(); } QString Request::method() const { Q_D(const Request); return d->m_parameters.value(SSOUI_KEY_METHOD).toString(); } QString Request::mechanism() const { Q_D(const Request); return d->m_parameters.value(SSOUI_KEY_MECHANISM).toString(); } WId Request::windowId() const { Q_D(const Request); return d->windowId(); } bool Request::embeddedUi() const { Q_D(const Request); return d->embeddedUi(); } bool Request::isInProgress() const { Q_D(const Request); return d->m_inProgress; } const QVariantMap &Request::parameters() const { Q_D(const Request); return d->m_parameters; } const QVariantMap &Request::clientData() const { Q_D(const Request); return d->m_clientData; } void Request::start() { Q_D(Request); if (d->m_inProgress) { BLAME() << "Request already started!"; return; } d->m_inProgress = true; } void Request::cancel() { setCanceled(); } void Request::fail(const QString &name, const QString &message) { Q_D(Request); QDBusMessage reply = d->m_message.createErrorReply(name, message); d->m_connection.send(reply); Q_EMIT completed(); } void Request::setCanceled() { QVariantMap result; result[SSOUI_KEY_ERROR] = SignOn::QUERY_ERROR_CANCELED; setResult(result); } void Request::setResult(const QVariantMap &result) { Q_D(Request); QDBusMessage reply = d->m_message.createReply(result); d->m_connection.send(reply); Q_EMIT completed(); } #include "request.moc" signon-ui/src/request.h0000664000175000017500000000434514615655426015334 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_REQUEST_H #define SIGNON_UI_REQUEST_H #include #include #include #include #include namespace SignOnUi { class RequestPrivate; class Request: public QObject { Q_OBJECT public: static Request *newRequest(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); ~Request(); static QString id(const QVariantMap ¶meters); QString id() const; uint identity() const; QString method() const; QString mechanism() const; WId windowId() const; bool embeddedUi() const; bool isInProgress() const; const QVariantMap ¶meters() const; const QVariantMap &clientData() const; public Q_SLOTS: virtual void start(); void cancel(); Q_SIGNALS: void completed(); protected: explicit Request(const QDBusConnection &connection, const QDBusMessage &message, const QVariantMap ¶meters, QObject *parent = 0); void setWidget(QWidget *widget); void setWindow(QWindow *window); protected Q_SLOTS: void fail(const QString &name, const QString &message); void setCanceled(); void setResult(const QVariantMap &result); private: RequestPrivate *d_ptr; Q_DECLARE_PRIVATE(Request) }; } // namespace #endif // SIGNON_UI_REQUEST_H signon-ui/src/security-low.png0000664000175000017500000000075314615655426016646 0ustar coucoufcoucouf‰PNG  IHDRóÿasBIT|dˆ pHYs × ×B(›xtEXtSoftwarewww.inkscape.org›î<hIDAT8u±JA†¿½xäPPSؤ‰¦Ðg| KL­9¸f.UbR"°±·P{ñ|;!…H@Sáv-܄͙X–™ÿÛF´Z­­u¨«@|O@CDž­õ%p¬[qœ[¥R©ômËÀ0X°ÉZá—^·Zë›<ÏŽœ:=›}¬C­õ°mÏ50,ô¬¹€Ð­ˆÈ PwRÀkPvÅ0€òÔfb ”: ðj](¥TlKù ðêäþŒ1ƒ$IFiš61m+Ž’$EQtáˆHæÀ*ÖÕØíɲìÓ àoö ,RcL[DÄÉkWà["ö÷‰£È×SL7?oÖÁŒfòø±ÅòtÏ€E{»€wÛ|Øív—,,:Ƙvš¦M€~¿_VJYÍÛÔ²ˆ<»¾9=ñ "û'À=P´;/ÆÀÐø¦@}-›DéIEND®B`‚signon-ui/src/service.cpp0000664000175000017500000001420314615655426015631 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "service.h" #include "cookie-jar-manager.h" #include "debug.h" #include "request.h" #include #include using namespace SignOnUi; namespace SignOnUi { typedef QQueue RequestQueue; static QVariant dbusValueToVariant(const QDBusArgument &argument) { QVariant ret; /* Note: this function should operate recursively, but it doesn't. */ if (argument.currentType() == QDBusArgument::MapType) { /* Assume that all maps are a{sv} */ ret = qdbus_cast(argument); } else { /* We don't know how to handle other types */ ret = argument.asVariant(); } return ret; } static QVariantMap expandDBusArguments(const QVariantMap &dbusMap) { QVariantMap map; QMapIterator it(dbusMap); while (it.hasNext()) { it.next(); if (qstrcmp(it.value().typeName(), "QDBusArgument") == 0) { QDBusArgument dbusValue = it.value().value(); map.insert(it.key(), dbusValueToVariant(dbusValue)); } else { map.insert(it.key(), it.value()); } } return map; } class ServicePrivate: public QObject { Q_OBJECT Q_DECLARE_PUBLIC(Service) public: ServicePrivate(Service *service); ~ServicePrivate(); RequestQueue &queueForWindowId(WId windowId); void enqueue(Request *request); void runQueue(RequestQueue &queue); void cancelUiRequest(const QString &requestId); void removeIdentityData(quint32 id); private Q_SLOTS: void onRequestCompleted(); private: mutable Service *q_ptr; /* each window Id has a different queue */ QMap m_requests; }; } // namespace ServicePrivate::ServicePrivate(Service *service): QObject(service), q_ptr(service) { } ServicePrivate::~ServicePrivate() { } RequestQueue &ServicePrivate::queueForWindowId(WId windowId) { if (!m_requests.contains(windowId)) { RequestQueue queue; m_requests.insert(windowId, queue); } return m_requests[windowId]; } void ServicePrivate::enqueue(Request *request) { Q_Q(Service); bool wasIdle = q->isIdle(); WId windowId = request->windowId(); RequestQueue &queue = queueForWindowId(windowId); queue.enqueue(request); if (wasIdle) { Q_EMIT q->isIdleChanged(); } runQueue(queue); } void ServicePrivate::runQueue(RequestQueue &queue) { Request *request = queue.head(); TRACE() << "Head:" << request; if (request->isInProgress()) { TRACE() << "Already in progress"; return; // Nothing to do } QObject::connect(request, SIGNAL(completed()), this, SLOT(onRequestCompleted())); request->start(); } void ServicePrivate::onRequestCompleted() { Q_Q(Service); Request *request = qobject_cast(sender()); WId windowId = request->windowId(); RequestQueue &queue = queueForWindowId(windowId); if (request != queue.head()) { BLAME() << "Completed request is not first in queue!"; return; } queue.dequeue(); request->deleteLater(); if (queue.isEmpty()) { m_requests.remove(windowId); } else { /* start the next request */ runQueue(queue); } if (q->isIdle()) { Q_EMIT q->isIdleChanged(); } } void ServicePrivate::cancelUiRequest(const QString &requestId) { Request *request = 0; /* Find the request; we don't know in which queue it is, so we must search * all queues. */ foreach (RequestQueue queue, m_requests) { foreach (Request *r, queue) { if (r->id() == requestId) { request = r; break; } } } TRACE() << "Cancelling request" << request; if (request != 0) { request->cancel(); } } void ServicePrivate::removeIdentityData(quint32 id) { /* Remove any data associated with the given identity. */ /* The BrowserRequest class uses CookieJarManager to store the cookies */ CookieJarManager::instance()->removeForIdentity(id); } Service::Service(QObject *parent): QObject(parent), d_ptr(new ServicePrivate(this)) { } Service::~Service() { } bool Service::isIdle() const { Q_D(const Service); return d->m_requests.isEmpty(); } QVariantMap Service::queryDialog(const QVariantMap ¶meters) { Q_D(Service); QVariantMap cleanParameters = expandDBusArguments(parameters); TRACE() << "Got request:" << cleanParameters; Request *request = Request::newRequest(connection(), message(), cleanParameters, this); d->enqueue(request); /* The following line tells QtDBus not to generate a reply now */ setDelayedReply(true); return QVariantMap(); } QVariantMap Service::refreshDialog(const QVariantMap &newParameters) { QVariantMap cleanParameters = expandDBusArguments(newParameters); QString requestId = Request::id(cleanParameters); // TODO find the request and update it /* The following line tells QtDBus not to generate a reply now */ setDelayedReply(true); return QVariantMap(); } void Service::cancelUiRequest(const QString &requestId) { Q_D(Service); d->cancelUiRequest(requestId); } void Service::removeIdentityData(quint32 id) { Q_D(Service); d->removeIdentityData(id); } #include "service.moc" signon-ui/src/service.h0000664000175000017500000000311714615655426015300 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2011 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_SERVICE_H #define SIGNON_UI_SERVICE_H #include #include #include namespace SignOnUi { class ServicePrivate; class Service: public QObject, protected QDBusContext { Q_OBJECT Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) Q_CLASSINFO("D-Bus Interface", "com.nokia.singlesignonui") public: explicit Service(QObject *parent = 0); ~Service(); bool isIdle() const; public Q_SLOTS: QVariantMap queryDialog(const QVariantMap ¶meters); QVariantMap refreshDialog(const QVariantMap &newParameters); Q_NOREPLY void cancelUiRequest(const QString &requestId); void removeIdentityData(quint32 id); Q_SIGNALS: void isIdleChanged(); private: ServicePrivate *d_ptr; Q_DECLARE_PRIVATE(Service) }; } // namespace #endif // SIGNON_UI_SERVICE_H signon-ui/src/signon-ui.desktop.in0000664000175000017500000000033514615655426017376 0ustar coucoufcoucouf[Desktop Entry] Encoding=UTF-8 Version=1.0 Name=Account authentication Comment=Login to online accounts Exec=$${target.path}/$$TARGET Icon= Type=Application Terminal=false NoDisplay=true X-Ubuntu-Gettext-Domain=signon-ui signon-ui/src/signon-ui.pro0000664000175000017500000000522714615655426016125 0ustar coucoufcoucoufinclude(../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) include($${TOP_SRC_DIR}/common-installs-config.pri) TEMPLATE = app TARGET = signon-ui I18N_DOMAIN = signon-ui CONFIG += \ link_pkgconfig \ qt QT += \ core \ dbus \ gui \ network \ quick lessThan(QT_MAJOR_VERSION, 6) { QT += webengine } else { QT += webenginequick } PKGCONFIG += \ signon-plugins-common \ libnotify \ libproxy-1.0 QT += \ widgets PKGCONFIG += \ accounts-qt$$QT_MAJOR_VERSION \ libsignon-qt$$QT_MAJOR_VERSION CONFIG(force-foreign-qwindow) { DEFINES += FORCE_FOREIGN_QWINDOW } HEADERS = \ animation-label.h \ browser-request.h \ cookie-jar-manager.h \ debug.h \ dialog-request.h \ dialog.h \ errors.h \ http-warning.h \ i18n.h \ inactivity-timer.h \ indicator-service.h \ network-access-manager.h \ qquick-dialog.h \ reauthenticator.h \ request.h \ service.h \ webcredentials_interface.h SOURCES = \ animation-label.cpp \ browser-request.cpp \ cookie-jar-manager.cpp \ debug.cpp \ dialog-request.cpp \ dialog.cpp \ http-warning.cpp \ i18n.cpp \ inactivity-timer.cpp \ indicator-service.cpp \ main.cpp \ my-network-proxy-factory.cpp \ network-access-manager.cpp \ qquick-dialog.cpp \ reauthenticator.cpp \ request.cpp \ service.cpp \ webcredentials_interface.cpp OTHER_FILES += \ qml/DefaultPage.qml \ qml/KeyboardRectangle.qml \ qml/MainWindow.qml \ qml/StandardAnimation.qml \ qml/WebView.qml RESOURCES += \ qml/qml.qrc QMAKE_SUBSTITUTES += \ signon-ui.desktop.in desktop.path = $${INSTALL_PREFIX}/share/applications desktop.files += signon-ui.desktop INSTALLS += desktop DEFINES += \ DEBUG_ENABLED \ I18N_DOMAIN=\\\"$${I18N_DOMAIN}\\\" RESOURCES += \ animationlabel.qrc \ http-warning.qrc SIGNONUI_DBUS_ADAPTORS += \ com.canonical.indicators.webcredentials.xml SIGNONUI_DBUS_INCLUDES += \ indicator-service.h include(signonui_dbus_adaptor.pri) po.target = ../po/signon-ui.pot po.depends = $${SOURCES} po.commands = xgettext -o $@ -d $${I18N_DOMAIN} --keyword=_ $^ QMAKE_EXTRA_TARGETS += \ po QMAKE_SUBSTITUTES += \ com.canonical.indicators.webcredentials.service.in \ com.nokia.singlesignonui.service.in service.path = $${INSTALL_PREFIX}/share/dbus-1/services service.files = \ com.canonical.indicators.webcredentials.service \ com.nokia.singlesignonui.service INSTALLS += service # Help file for HTTP authentication warning !isEmpty(HTTP_WARNING_HELP) { DEFINES += HTTP_WARNING_HELP=\\\"$${HTTP_WARNING_HELP}\\\" } signon-ui/src/signonui_dbus_adaptor.pri0000664000175000017500000000425314615655426020567 0ustar coucoufcoucouf# This script is a modified copy of Qt's mkspecs/features/dbusadaptors.prf, # written to allow passing extra "-i" options to qdbusxml2cpp qtPrepareTool(QMAKE_QDBUSXML2CPP, qdbusxml2cpp) for(SIGNONUI_DBUS_ADAPTOR, $$list($$unique(SIGNONUI_DBUS_ADAPTORS))) { !contains(SIGNONUI_DBUS_ADAPTOR, .*\\w\\.xml$) { warning("Invalid D-BUS adaptor: '$${DBUS_ADAPTOR}', please use 'com.mydomain.myinterface.xml' instead.") next() } SIGNONUI_DBUS_ADAPTOR_LIST += $${SIGNONUI_DBUS_ADAPTOR} } for(SIGNONUI_DBUS_INCLUDE, $$list($$unique(SIGNONUI_DBUS_INCLUDES))) { QDBUS_EXTRA_OPTIONS += -i $${SIGNONUI_DBUS_INCLUDE} } signonui_dbus_adaptor_header.commands = $$QMAKE_QDBUSXML2CPP -a ${QMAKE_FILE_OUT}: ${QMAKE_FILE_IN} signonui_dbus_adaptor_header.output_function = signonui_dbus_adaptor_header_output signonui_dbus_adaptor_header.name = DBUSXML2CPP ADAPTOR HEADER ${QMAKE_FILE_IN} signonui_dbus_adaptor_header.variable_out = SIGNONUI_DBUS_ADAPTOR_HEADERS signonui_dbus_adaptor_header.input = SIGNONUI_DBUS_ADAPTOR_LIST defineReplace(signonui_dbus_adaptor_header_output) { return("$$lower($$section($$list($$basename(1)),.,-2,-2))_adaptor.h") } signonui_dbus_adaptor_source.commands = $$QMAKE_QDBUSXML2CPP $$QDBUS_EXTRA_OPTIONS -i ${QMAKE_FILE_OUT_BASE}.h -a :${QMAKE_FILE_OUT} ${QMAKE_FILE_IN} signonui_dbus_adaptor_source.output_function = signonui_dbus_adaptor_source_output signonui_dbus_adaptor_source.name = DBUSXML2CPP ADAPTOR SOURCE ${QMAKE_FILE_IN} signonui_dbus_adaptor_source.variable_out = SOURCES signonui_dbus_adaptor_source.input = SIGNONUI_DBUS_ADAPTOR_LIST load(moc) signonui_dbus_adaptor_moc.commands = $$moc_header.commands signonui_dbus_adaptor_moc.output = $$moc_header.output signonui_dbus_adaptor_moc.depends = $$signonui_dbus_adaptor_header.output signonui_dbus_adaptor_moc.input = SIGNONUI_DBUS_ADAPTOR_HEADERS signonui_dbus_adaptor_moc.variable_out = GENERATED_SOURCES signonui_dbus_adaptor_moc.name = $$moc_header.name defineReplace(signonui_dbus_adaptor_source_output) { return("$$lower($$section($$list($$basename(1)),.,-2,-2))_adaptor.cpp") } QMAKE_EXTRA_COMPILERS += signonui_dbus_adaptor_header signonui_dbus_adaptor_source signonui_dbus_adaptor_moc signon-ui/src/spinner-26.gif0000664000175000017500000002112314615655426016056 0ustar coucoufcoucoufGIF89a õÿÿÿªªª„„„```LLL>>>HHHVVVpppŽŽŽ   fff444222888BBBttt¦¦¦®®®jjj000°°°***\\\”””&&&"""ˆˆˆ˜˜˜~~~RRRzzz œœœººº´´´¾¾¾ÎÎÎÒÒÒØØØÈÈÈÄÄÄâââìììæææðððöööüüüÜÜÜ !ÿ NETSCAPE2.0!þCreated with ajaxload.info!ù , ÿ@€pHœ ŽKÉAl:Ÿ€"t:•JV¨–( lF×ð ²Ý. ¡t:|-C3—z>¸ ÇF.Z? wE"Š„P’‡ŽP ‘–P ™š•ŸN ª¦O« ®M³ v¶MÀ ½MÆÄDÇËC͵ÑÙƒÑÙÙÜ ßâ ê ÜñÃÜóÛËóú¸»CcË ú0H@ÂÍŒ‚Z,0H¸„P`ÈxXF "€ð `…*V°`ñ"Œ@ÄCa¡È2t`ÁD D,5¤AT‹!A „I.€¶„ñr† n ê°@Š?Yº„á+N<ªòÙO&,pº`‚ ”,Ê!ù , ÿ@€pHœ 0J©Ôx @Ĩ”¸@hB¡¥¶tM¿BC#°¡‘Ö¦OÍfƒÆª—7‰;Úyhäevw%{Tr"  ‡BŠ‹—` ›¤¡` ¤  ©` µ®P²S¼¼¹_ÃÀS Ä¿ÈRÒ¨ÎQ××mÕDØÇÛCÝàáÝÚèèBò öúX`O€> =ôƒç¶IÈ€B‚zÐq`ð0ˆ·Yq1€ ¤ø2ƒÆ%bžTa*X¼ˆcFËBPd¢ì°`‚ œ:aÈøÊ” ˆEº³'ÓK(HH"*EŠ+jð\ÚÒe( ¸Z8šS¬ÒÎL @ÁvEÒ=A!ù , ÿ@€pHœp0FHôx ¢t:\`.Ñ&4•¾§bA¥ (•‹F“冸ßÒéD(‡´z-½ßq'7$vB‰{m%^_6… ˜‹ ‘”Išše ”M ”º µ¾ ºº ¾µ¹Á…ÊuÇ… ÒÒÏ… ÓÎÖeÜvß­äTïdëSï„òRõêùCô#ÀÀ! d`ì € DàÀ $~ª@ÄH¨8A〠LT RA†*Z8ÉAA‡L¨‰Òæ‚D &\¨¨ÆŒ4hX³!‰‚ª`ñ† ¤äL,xU(U«XÉ¥° ¡ëÔªW•ÊsaB* ¢F‘ª•§b*Ü´sË!ù , ÿ@€pHœ(Ãf“$ &Ĩt¸ 4.Xf…4ˆÅt*H<*Gv+ ¹G¥A0J>t¾rÑnDmnq%bc yj}Km^ƒ%" SIIŒ #pq87R›c ƒ'S ¾±uC '7˜¾Ë—ÃCcʾÎØÜÜÙØÜaàÎ ååßçà NíÃööµôc÷ úûú1Hð ”D0d„@äk8DBšQ²@¡‡Œ&6 ±#‡ 7fÀAA!EZhùrÁ„",PÐaG &Tˆ4A‚„M)Z°ˆ±Ñ„O .T°xCÆ 4š˜U*U«Y º0a"êÔªW)ªpaökÚ,Vœ‹5gŒ0fè­‹-!ù , ÿ@€pHœ(Èå18¢t:”0 Ge{ÑxEÄ‚JD †Ç£‘­t½‘hC«˜&:Ý^~E!!#cd$I{k ~q€!%%Tˆ‰M  “…Cšd"##“%vC°ÂwC "»“UÏ–Å¿º“66BÍÓR %'7¬ÜÜáSRóó«íBÙR  ì÷¦E`@AiïDHÀ0‚½„SDˆDˆd$‚0à"Æ)9BùH…G |‘$Òƒ‚ ò­¬‚² .f1óæU:«X … A˜X Á‚ *j$E1E ¨,buaêŠ1`ÌÐÙâ© /`ȘAƒÆL-Φ]ëV'‹»ag°M àÅܽ|ÃÒ­Ë€^Àƒ!ù , ÿ@€pHœ(‡ƒ£‘d(&Ĩt(I@ ؇£Â½\*˜Åt:’Wl£ápx5š A0¦çCÚð`»/p"bc ‰IY}mo""!SŠI €‚“#…Cš c’!!#%PC¯±±uCº!%%vеÆÀ#»Ì…ÑÐ ÕQ ¼Ì%  àRäÌ$ ööïQä''Dˆb€>)JظaƒÀ <€ q0 ‚ òˆ8 #Šu:à È:$„2qrŒ:,`ÙRJL $ЬI„ÞVvò‚BP)X âBBÐ.T,biT/¦Paâj0´ªP±+ 3¦²P5Ú4h,eaV\¹S_¸W«³|ñúx0Á†—!ù , ÿ@€pHdˆ‚ÁP(P“¢t*I|XÈÒðp8„Åt:$›ØÃ¶[iW(‚ñPBA >…´zùhx+bc vvxi|}^S ˆ  Ž„C –—˜ ©E¦¦QC –– rCµ"!ÇC½Ì°ÂD""##„ ÚÚÏEÆ!Õ( ç ÁÞEÇ#%# õõì²%Ç%% 8(P0)_‘ýú˜¡aƒD$,Ñ ƒE L@$âa¢%Hp±qWÂ%DN°`¡EI! N–X‰ÂD /§˜°éÂÅŠEœRzºP¡‚Ð"*ZeQ#ÆÑ!,ŠÖxÆS¨,^À€!cÆU1¨v1ƒÆ×­di¨5{5-Û¯ÒÂ%¢v®Ý»xóÊ !ù , ÿ@€pHt@Ìá€A$“¢t*5?…ìò`è2Ó©el" Û¤kh<‚ðpb’ˆ)B(À‚C(\,Â@aˆLhtáBÅD"J(,±!Ç*X|”VbĈ%PªXÁâÅJ! `êLɢƋI7„Ô)‚EÍ0`% ³Äƒ/’˜ôŽ6N|@:uÆ AL` !€®4Ò†-âUíZ¶_ßN‰+W غxóêÝË·ïÛ !ù , ÿ@€pHt< ¢@ D2“¢t*P„vY8x)’éÔ¢HP®Mí§ë… xh$±öÜ s wIY~’S( ‡‰Š $ “ „E¢™ aSQC ìs ºC. $¡¢ÇD »¬&á Ö×DÜÜ*(ðåæDø-&ýý-ôŠdÈ·aƒ-\(tPŠ " "PA‘⊆ElÑ‹k`$2 Dˆ!.¼XãEŒ‘Cœ1BŒ›8a ‘I³¦ŒT3dÈ€¡Y š%4]:£(PK< A•jS¢–(@c«#œ€zâ"Tuj(1v,­¢C@à¸QÜ) nà0v·H‚¾€ L¸°á€A!ù , ÿ@€pH,8‘Cax2Ũ`Q$MÁ-|’iÔD€"W†–‹( @,4e83(ÕboaS& ‹g|j”R) $ x ‚•‡DœŸS$–­­¸C)¦Àt½ C*)&&(²&tD Í B*-..Ó.ØEÜ 5+*óäèQìì /5,ÿ*XØ+’]… ÄXØOàÀ"^¸@†Å…1aPAƒÇ3fȰC#‘6¤¬²¥ “Cl±¡&›4B¢@„Ï]šCrÎØ `@ˆ£".¡Aƒ#F„0дȃ£QTYjT[…<(µ„XMœ(Áö„Ö­ J¬e[ÜV7æž VÈ€¼'.Ìé ïˆL„ý*H̸±c˜A!ù , ÿ@€pHL:O" :Ũ`Zdƒ(²d¾ É4ê²,:WNÔýbÏd,l¡’)­åz obS*&&zil ^p$R,-..ˆ‹ { €p…D+*±.)ˆ.S ¼sC/,ð-*tB•½C01/ÒÃ,ÈC¼Û B0ßß11ÖDÛÛB2332ßäEèíøíñDÛÌ Aà¾":¨@À ‰$hà âˆ¥ ¨¸ðAÆ)*T¸@ò£$/h¸`2Ê•48hY„AÌ  Ð$b`ƒÏU v É ¢è„8BDÓ ®Z&A•jÐF8 1BC7š J”Áuš4ˆ][¢€p° E¨b5(PºÔFÛ¯|7`xËWHÔÂc‚!ù , ÿ@€pH˜$gÀT,ŠÐ( u\t2 ÅÀIx)”EEY$Vì¶› ƒ‰XXSµ\&3:¹ub/,+**x&$Y~ €‚OP01/5ˆ‹&¡¡(H”©…E0®œ,Š*R ¨rC3322›//sB © ½¾¾Á0ÅC¸Ë¬4Û4ÏÓD Ëã B4CÝßE ãaDÛêDãôÅùù øÍ‰ðÏÀb8<0ð`!B)>pÐàa” 8¨PÑb‘BVxà±H‘”$ràÂ… ¬’Aƒ† 7÷Í< aƒÍT ¬JF!¢§™+l *Âg& D„`*©EJ„غõA<„”Ëu„œ[bÄØ J2°Áv샧m¬]‹ákI½!>à]™Áƒ_(A!ù , ÿ@€pH´LÉ"ÃìHŠÐ(àµr¹LeFÁx@ 4«­TW”`ÑQ(¼‘DBaa±kÕºfI[ q bR332xzhXZoƒr R44‹x,**}~ “ ¨OQ›3/R¦¨™œvB§µ¹2»C$ÀÀªE›ÅD ÀÏÏ ÓÛˆ×c$Ô Þ»é æv éíc ðôRýýúQ2øû°‡ Ið áƒ ‰hà "ˆ¼TÐè@Æ+ThЭ`„ (E2À8à‚ )1)L°¡æË  "„MC%Ÿ¹I@ B‰ž=kV AïA‰§GCŒáóB}%N@•:5„™ô h…ZbÄAÍXË6° œ¸PáÃ\c‚!ù , ÿ@€pH¼X*W eL,ŨTƒWI“E²È(ÐitF†ÅŽÙmWÁtÂbm>“YY+— 5YtØ qC4e15+-)&~  …r‡U‰Hz’ ˜‡3S&¡£pRs˜ ”£ ˜» ·¿—»…¿˜ ¿¦Êb Î Òq×ÚbàS äèRìïQóùöE ùóûD"€0À! (4@á €ààÁƒˆ£íá cƒ rhб‚ƒ F¨p¡‚K öe8 ¡fË 4B@ ‚M<±¡¦† P*{P¢iÓ!DˆÐPTà Òn8µë†¢R*[`ckˆh‰j` s—'œ>¡Xm>¸,q¢Âƒâ!ù , ÿ@€pHÐf3X¬ÆRµ\Ũ´xT¾š.“Å’šz‡UØU•HÓWJ«ÆÆeI'ÓA­‰m¤²¶r¥P  „wCH2VMg ‡_. ’•_  Ÿ_£¤ †¨S ¬ °^­ ”·Q ¼¿RÄÄ ÇQ ÊÍEÖÓD$×ÖÚCÕßB åæ ëÙæö æü§ß00ß«i *̧M ,ÐáEˆ"¬p`” Tpà Áƒ§ØÀq¢S "00 áÂ…‘#%®Qp¢„ÏC#F„ºACÍ H t¸sã„S A…†(Zóæ‰k:8} U¨ˆ Eo2HùeÁ‡\ƒNýzVTª” 1Â"‚I_‚!ù , ÿ@€pH$Òf3ìU+:ŸOÚQùb©®Ð¬ó([Z]¦”K«•&cUØ2I‘£Çsm¥J™&‹êýœuc_&( &|Z,k… {‰Y.„ $’Z&$—˜›Y  £Y¨  ¬O° š´N± ¼N ¹ ÃE$ Î ÊD ÕÑC ÖרáÝØçÐÞ çÞ$óó«Øùåÿÿà=¹•H HxâD‰o<˜xB2b6p”(ñ ”L¤ø¡_‘6ll\i€ª pÐàȉ<‘°ae‰O@EÕ áB… hŠ<Ð!Ë‚KŒ4Ñ¢G+Ð, S‹ +§ŽØ bQ£G$0ùfÁ‡ !¨n˜{öÂ]7M0g3Ä‘8ˆÊ!ù , ÿ@€pH,i´™qÉd"g0X¬I]>¥¯Zu xBcµ•jÅu&¡°KårµÊÌ™LZ[»L(œ™¶§P{M,m& ‚ƒK*x‰&ŒK.‘ ”K   (›E& £E¨ «D  ²C·¾ºB¾ ÄÀÄÉÆ$ Î Æ ÔÆ ÔÔFŒ EŒ ëëC7'%Ðp÷ÛB!'òò¹¸d8P ` ª„`(!¯D‰ô¨ 8@‘à}B&\h8"Äå–t@¡"E ‹†tá0„Ë P‘!ˆ0`²€&U# D8ÑQÄ .8Xú@çN h²àAÇŽ0&­ÀtçN › "„Ñ G/TàZ¡AS Üqù¦&Ò j¹:0À ,œ 0ìÄ[’‚”K‚!ù , ÿ@€pH,Èd’¦l6i3§´•Á¦R‹a—Ú™5V{}á öb±ÎH5»¶R©àÇ9KåJÝñEm|.&&€F|)&.‡D+ІC‹ —˜›žB&$ ¤&© ¬(°¶¬¶»C€$  ¶'6% €Ï ''%Ö p ÛÛ$Öàp  Õà _ òòB à!#õRóò: !`-„Á Àšp@Àü„pPb„Á"¬:ÒA 0˜P„Ä…ClÐpá@28ûp æX$ÃOŒ"6¬¼àÀAƒ °ù$‰$ ]ɲèQ¥ Ô,p`g4ˆ½p¡‚Q¤X·‚ )e† d+ÈuT)„<±Là@ fÑ›°E!ù , ÿ@€pH,ȤrÉl:ŸÐ(6‹2§U+rJÁ´G¬ghìÅ6eêWÅrcr–ªµ² c,+{.-~Bƒ.&)†*‰&((Œ*f.— %''%%`. ¬"§§`(®·±%` ¿ ¦§`¦!!¨VÊÊ #%##!V ââÜÝ"³O ï B ÜÐN  þ †€vïÂ:% (dàOÞ6HÜ áÂHH$@€A!Ê!qA¢†Šˆ0ÀÕÈä¸P‘ N^¸PÁAHMœ-ðáÃL ’,€°³BÏŸœ j›J0pêÔÁ&N†(€`@À&  * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "webcredentials_interface.h" #include "indicator-service.h" /* * We don't use the code generated by qdbusxml2cpp, because the * IndicatorService is provided by the signon-ui process itself, and it would * be silly to send requests to it via D-Bus. * So, this class wraps the real IndicatorService methods, so that they can be * called directly, while still leaving the external API as if it were * generated by qdbusxml2cpp (in case we later decide to move this service * somewhere else). */ using namespace SignOnUi; ComCanonicalIndicatorsWebcredentialsInterface:: ComCanonicalIndicatorsWebcredentialsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) : QObject(parent) { Q_UNUSED(service); Q_UNUSED(path); Q_UNUSED(connection); } ComCanonicalIndicatorsWebcredentialsInterface::~ComCanonicalIndicatorsWebcredentialsInterface() { } QDBusPendingReply<> ComCanonicalIndicatorsWebcredentialsInterface::ReportFailure(uint account_id, const QVariantMap ¬ification) { Q_ASSERT(IndicatorService::instance() != 0); IndicatorService::instance()->reportFailure(account_id, notification); return QDBusPendingReply<>(); } signon-ui/src/webcredentials_interface.h0000664000175000017500000000407614615655426020660 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_WEBCREDENTIALS_INTERFACE_H #define SIGNON_UI_WEBCREDENTIALS_INTERFACE_H #include #include #include #include #include #include #include #include namespace SignOnUi { class IndicatorService; }; /* * Proxy class for interface com.canonical.indicators.webcredentials */ class ComCanonicalIndicatorsWebcredentialsInterface: public QObject { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.canonical.indicators.webcredentials"; } public: ComCanonicalIndicatorsWebcredentialsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~ComCanonicalIndicatorsWebcredentialsInterface(); QDBusPendingReply<> ReportFailure(uint account_id, const QVariantMap ¬ification); Q_SIGNALS: // SIGNALS }; namespace com { namespace canonical { namespace indicators { typedef ::ComCanonicalIndicatorsWebcredentialsInterface webcredentials; } } } #endif // SIGNON_UI_WEBCREDENTIALS_INTERFACE_H signon-ui/tests/0000775000175000017500000000000014615655426014040 5ustar coucoufcoucoufsignon-ui/tests/.config/0000775000175000017500000000000014615655426015363 5ustar coucoufcoucoufsignon-ui/tests/.config/signon-ui/0000775000175000017500000000000014615655426017273 5ustar coucoufcoucoufsignon-ui/tests/.config/signon-ui/webkit-options.d/0000775000175000017500000000000014615655426022473 5ustar coucoufcoucoufsignon-ui/tests/.config/signon-ui/webkit-options.d/localhost.conf0000664000175000017500000000016214615655426025331 0ustar coucoufcoucoufUsernameField = input[name="username"] PasswordField = input[name="password"] LoginButton = input[type="submit"] signon-ui/tests/functional/0000775000175000017500000000000014615655426016202 5ustar coucoufcoucoufsignon-ui/tests/functional/functional.pro0000664000175000017500000000044114615655426021065 0ustar coucoufcoucoufinclude(../../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) include($${TOP_SRC_DIR}/common-installs-config.pri) TEMPLATE = subdirs check.commands = "BUILDDIR=$$TOP_BUILD_DIR SRCDIR=$$TOP_SRC_DIR $$TOP_SRC_DIR/tests/functional/tests.sh" QMAKE_EXTRA_TARGETS += check signon-ui/tests/functional/reauthenticator.py0000775000175000017500000002135214615655426021763 0ustar coucoufcoucouf#! /usr/bin/python3 import unittest import logging import sys import dbus, dbus.service from dbus.mainloop.glib import DBusGMainLoop from gi.repository import Accounts from gi.repository import GLib from gi.repository import GObject SIGNOND_BUS_NAME = 'com.google.code.AccountsSSO.SingleSignOn' AUTH_SERVICE_IFACE = SIGNOND_BUS_NAME + '.AuthService' AUTH_SESSION_IFACE = SIGNOND_BUS_NAME + '.AuthSession' class MockAuthSession(dbus.service.Object): last_session = 0 def __init__(self, connection, identity, method): self.identity = identity self.method = method MockAuthSession.last_session += 1 path = '/session/{}'.format(MockAuthSession.last_session) super().__init__(connection, path) @dbus.service.method(dbus_interface=AUTH_SESSION_IFACE, in_signature='a{sv}s', out_signature='a{sv}') def process(self, session_data, mechanism): # Store the session data and mechanism, so that later they can be # verified by the test functions self.session_data = session_data self.mechanism = mechanism # signon-ui does not care what dictionary is returned, as long as it's # not an error; so let's just return the same dictionary return session_data class MockSignond(dbus.service.Object): def __init__(self, bus_name): super().__init__(bus_name, '/com/google/code/AccountsSSO/SingleSignOn') self.sessions = {} @dbus.service.method(dbus_interface=AUTH_SERVICE_IFACE, in_signature='u', out_signature='oa{sv}') def getIdentity(self, identity): return ('/identity/{}'.format(identity), {}) @dbus.service.method(dbus_interface=AUTH_SERVICE_IFACE, in_signature='us', out_signature='s') def getAuthSessionObjectPath(self, identity, method): session = MockAuthSession(self.connection, identity, method) self.sessions[session._object_path] = session return session._object_path class AuthenticatorTests(unittest.TestCase): credentials_id = 45000 @classmethod def setUpClass(cls): manager = Accounts.Manager() account = manager.create_account("any provider") account.set_enabled(True) v_credentials_id = GObject.Value() v_credentials_id.init(GObject.TYPE_UINT) v_credentials_id.set_uint(AuthenticatorTests.credentials_id) account.set_value('CredentialsId', v_credentials_id) account.store_blocking() AuthenticatorTests.account_id = account.id # Get a proxy for signon-ui bus = dbus.SessionBus() signon_ui_proxy = bus.get_object('com.nokia.singlesignonui', '/SignonUi') signon_ui = dbus.Interface(signon_ui_proxy, 'com.nokia.singlesignonui') webcredentials_proxy = bus.get_object('com.canonical.indicators.webcredentials', '/com/canonical/indicators/webcredentials') webcredentials = dbus.Interface(webcredentials_proxy, 'com.canonical.indicators.webcredentials') AuthenticatorTests.signon_ui = signon_ui AuthenticatorTests.webcredentials = webcredentials signond_bus_name = dbus.service.BusName(SIGNOND_BUS_NAME, bus=dbus.SessionBus()) AuthenticatorTests.signond_bus_name = signond_bus_name def setUp(self): self.test_failed = False self.signond = MockSignond(AuthenticatorTests.signond_bus_name) self.loop = GLib.MainLoop() def tearDown(self): self.signond.remove_from_connection() self.signond = None self.loop = None def failed_test(self, e): print(e) self.test_failed = True self.loop.quit() def test01_single_failure(self): log = logging.getLogger('AuthenticatorTests') self.method = 'TheMethod' self.mechanism = 'TheMechanism' client_data = dbus.Dictionary({ 'OneKey': 'OneValue', 'AnotherKey': 'AnotherValue' }, signature='sv') params = { 'OpenUrl': 'https://localhost/dontopen', 'Identity': self.credentials_id, 'Method': self.method, 'Mechanism': self.mechanism, 'ClientData': client_data, } reply = AuthenticatorTests.signon_ui.queryDialog(params) log.debug('Got reply: %s' % (reply,)) self.assertIn('QueryErrorCode', reply) self.assertEqual(reply['QueryErrorCode'], 10) def reauthenticate_cb(success): try: self.assertTrue(success) except: self.test_failed = True self.loop.quit() extra_data = dbus.Dictionary({ 'ExtraKey': 'ExtraValue', }, signature='sv') log.debug('Account id: ', self.account_id) AuthenticatorTests.webcredentials.ReauthenticateAccount(self.account_id, extra_data, reply_handler=reauthenticate_cb, error_handler=self.failed_test) self.loop.run() self.assertFalse(self.test_failed) # Now verify that the authentication data is consistent self.assertEqual(len(self.signond.sessions), 1) session = list(self.signond.sessions.values())[0] self.assertEqual(session.method, self.method) self.assertEqual(session.mechanism, self.mechanism) full_data = client_data.copy() full_data.update(extra_data) self.assertEqual(session.session_data, full_data) AuthenticatorTests.webcredentials.ReauthenticateAccount(self.account_id, extra_data, reply_handler=reauthenticate_cb, error_handler=self.failed_test) self.loop.run() def test02_many_failures(self): log = logging.getLogger('AuthenticatorTests') num_sessions = 8 sessions = {} def query_dialog_cb(reply): log.debug('Got reply: %s (count = %s)' % (reply, query_dialog_cb.call_count)) try: self.assertIn('QueryErrorCode', reply) self.assertEqual(reply['QueryErrorCode'], 10) except: self.test_failed = True query_dialog_cb.call_count += 1 if query_dialog_cb.call_count == num_sessions: self.loop.quit() query_dialog_cb.call_count = 0 for i in range(num_sessions): client_data = dbus.Dictionary({ 'OneKey': 'OneValue', 'AnotherKey': i }, signature='sv') params = { 'OpenUrl': 'https://localhost/dontopen', 'Identity': self.credentials_id, 'Method': 'method{}'.format(int(i / 2)), 'Mechanism': 'mechanism{}'.format(int(i / 3)), 'ClientData': client_data, } reply = AuthenticatorTests.signon_ui.queryDialog(params, reply_handler=query_dialog_cb, error_handler=self.failed_test) sessions[i] = params self.loop.run() self.assertFalse(self.test_failed) def reauthenticate_cb(success): log.debug('reauthenticate_cb: {}'.format(success)) try: self.assertTrue(success) except: self.test_failed = True self.loop.quit() extra_data = dbus.Dictionary({ 'ExtraKey': 'ExtraValue', }, signature='sv') AuthenticatorTests.webcredentials.ReauthenticateAccount(self.account_id, extra_data, reply_handler=reauthenticate_cb, error_handler=self.failed_test) self.loop.run() self.assertFalse(self.test_failed) # Now verify that the authentication data is consistent self.assertEqual(len(self.signond.sessions), num_sessions) actual_sessions = [] for session in self.signond.sessions.values(): s = { 'Method': session.method, 'Mechanism': session.mechanism, 'SessionData': session.session_data } actual_sessions.append(s) for session in sessions.values(): full_data = session['ClientData'].copy() full_data.update(extra_data) s = { 'Method': session['Method'], 'Mechanism': session['Mechanism'], 'SessionData': full_data } found = False for actual in actual_sessions: if s == actual: found = True break self.assertTrue(found) if __name__ == '__main__': DBusGMainLoop(set_as_default=True) logging.basicConfig(stream=sys.stderr) logging.getLogger('AuthenticatorTests').setLevel(logging.DEBUG) unittest.main(failfast=True, buffer=False, verbosity=2) signon-ui/tests/functional/run-with-signon-ui.sh0000775000175000017500000000026314615655426022225 0ustar coucoufcoucouf#! /bin/sh set -e export ACCOUNTS="/tmp" # start a local signon-ui dbus-test-runner -m 180 \ -t ${SRCDIR}/tests/functional/signon-ui.sh \ -t "$@" -f com.nokia.singlesignonui signon-ui/tests/functional/signon-ui.sh0000775000175000017500000000013414615655426020447 0ustar coucoufcoucouf#! /bin/sh set -e export SSOUI_LOGGING_LEVEL=2 ${SSOUI_WRAPPER} ${BUILDDIR}/src/signon-ui signon-ui/tests/functional/tests.sh0000775000175000017500000000040714615655426017704 0ustar coucoufcoucouf#! /bin/sh if test -z "$DISPLAY" ; then echo "No X11 display; skipping functional tests" exit 0 fi export LC_ALL=C export HOME="$SRCDIR/tests/functional" export SSOUI_DAEMON_TIMEOUT=10 "$SRCDIR/tests/functional/run-with-signon-ui.sh" \ ./reauthenticator.py signon-ui/tests/tests.pro0000664000175000017500000000015614615655426015726 0ustar coucoufcoucoufTEMPLATE = subdirs CONFIG += ordered SUBDIRS = \ unit CONFIG(medium-tests) { SUBDIRS += functional } signon-ui/tests/unit/0000775000175000017500000000000014615655426015017 5ustar coucoufcoucoufsignon-ui/tests/unit/fake-libnotify.cpp0000664000175000017500000000335314615655426020432 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "fake-libnotify.h" #undef signals #include #include static int m_notificationCount = 0; static NotifyNotification *fake_notification = 0; int FakeLibNotify::notificationCount() { return m_notificationCount; } void FakeLibNotify::clearNotificationCount() { m_notificationCount = 0; } gboolean notify_init(const char *app_name) { g_return_val_if_fail(app_name != NULL, FALSE); return TRUE; } NotifyNotification *notify_notification_new(const char *, const char *, const char *) { fake_notification = (NotifyNotification *)g_object_new (G_TYPE_OBJECT, NULL); return fake_notification; } gboolean notify_notification_show(NotifyNotification *notification, GError **error) { g_return_val_if_fail(notification == fake_notification, FALSE); *error = NULL; m_notificationCount++; return TRUE; } signon-ui/tests/unit/fake-libnotify.h0000664000175000017500000000166314615655426020101 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_FAKE_LIBNOTIFY #define SIGNON_UI_FAKE_LIBNOTIFY namespace FakeLibNotify { int notificationCount(); void clearNotificationCount(); }; #endif // SIGNON_UI_FAKE_LIBNOTIFY signon-ui/tests/unit/fake-libsignon.cpp0000664000175000017500000000534614615655426020423 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include #include #include #include using namespace SignOn; namespace SignOn { class IdentityImpl { AuthSessionP createSession(const QString &method); friend class Identity; Identity *q; quint32 id; }; class AuthSessionImpl: public QObject { Q_OBJECT private Q_SLOTS: void emitResponse(); private: friend class AuthSession; AuthSession *q; quint32 id; QString method; SessionData sessionData; }; } // namespace AuthSessionP IdentityImpl::createSession(const QString &method) { /* pretend to fail creating a few authsessions */ if (id % 5 == 0) return 0; return new AuthSession(id, method, q); } Identity::Identity(quint32 id, QObject *parent): QObject(parent), impl(new IdentityImpl) { impl->id = id; impl->q = this; } Identity::~Identity() { delete impl; } Identity *Identity::existingIdentity(quint32 id, QObject *parent) { /* Pretend not to find a few identities */ if (id % 3 == 0) return 0; return new Identity(id, parent); } AuthSessionP Identity::createSession(const QString &method) { return impl->createSession(method); } void AuthSessionImpl::emitResponse() { Q_EMIT q->response(sessionData); } AuthSession::AuthSession(quint32 id, const QString &method, QObject *parent): QObject(parent), impl(new AuthSessionImpl) { qDebug() << "Created fake Authsession" << id << method; impl->q = this; impl->id = id; impl->method = method; } AuthSession::~AuthSession() { delete impl; } void AuthSession::process(const SessionData &sessionData, const QString &mechanism) { QVariantMap map = sessionData.toMap(); map["TheMechanism"] = mechanism; impl->sessionData = SessionData(map); /* delay the response with some pseudo-random wait */ int msec = 100 + (impl->id % 4) * 5; QTimer::singleShot(msec, impl, SLOT(emitResponse())); } #include "fake-libsignon.moc" signon-ui/tests/unit/fake-webcredentials-interface.cpp0000664000175000017500000000347714615655426023373 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "fake-webcredentials-interface.h" #include static ComCanonicalIndicatorsWebcredentialsInterface *m_instance = 0; ComCanonicalIndicatorsWebcredentialsInterface:: ComCanonicalIndicatorsWebcredentialsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent): QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent), m_reportFailureCalled(false), m_account_id(0) { qDebug() << "ComCanonicalIndicatorsWebcredentialsInterface instantiated"; m_instance = this; QDBusMessage message; setReply(QDBusPendingCall::fromCompletedCall(message.createReply())); } ComCanonicalIndicatorsWebcredentialsInterface:: ~ComCanonicalIndicatorsWebcredentialsInterface() { m_instance = 0; } ComCanonicalIndicatorsWebcredentialsInterface * ComCanonicalIndicatorsWebcredentialsInterface::instance() { return m_instance; } signon-ui/tests/unit/fake-webcredentials-interface.h0000664000175000017500000000526014615655426023030 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_WEBCREDENTIALS_INTERFACE_H #define SIGNON_UI_WEBCREDENTIALS_INTERFACE_H #include #include #include #include #include #include #include #include /* * Fake proxy class for interface com.canonical.indicators.webcredentials, * for unit testing. */ class ComCanonicalIndicatorsWebcredentialsInterface: public QDBusAbstractInterface { Q_OBJECT public: static inline const char *staticInterfaceName() { return "com.canonical.indicators.webcredentials"; } public: ComCanonicalIndicatorsWebcredentialsInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); ~ComCanonicalIndicatorsWebcredentialsInterface(); public Q_SLOTS: // METHODS QDBusPendingReply<> RemoveFailures() { return m_reply; } QDBusPendingReply<> ReportFailure(uint account_id, const QVariantMap ¬ification) { qDebug() << "Report failure called"; m_reportFailureCalled = true; m_account_id = account_id; m_notification = notification; return m_reply; } private: void setReply(const QDBusPendingCall &reply) { m_reply = static_cast >(reply); } static ComCanonicalIndicatorsWebcredentialsInterface *instance(); friend class SignOnUiTest; QDBusPendingReply<> m_reply; bool m_reportFailureCalled; uint m_account_id; QVariantMap m_notification; }; namespace com { namespace canonical { namespace indicators { typedef ::ComCanonicalIndicatorsWebcredentialsInterface webcredentials; } } } #endif // SIGNON_UI_WEBCREDENTIALS_INTERFACE_H signon-ui/tests/unit/test.cpp0000664000175000017500000002111714615655426016504 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" #include "fake-libnotify.h" #include "indicator-service.h" #include "test.h" #include "reauthenticator.h" #include "request.h" #include "fake-webcredentials-interface.h" #include #include #include #include #include #include using namespace SignOnUi; SignOnUiTest::SignOnUiTest(): m_dbusConnection("test") { setLoggingLevel(2); } void SignOnUiTest::initTestCase() { /* Use a temporary DB for accounts */ setenv("ACCOUNTS", "/tmp/", false); QDir dbroot("/tmp"); dbroot.remove("accounts.db"); } void SignOnUiTest::testRequestObjects() { const WId windowId = 23141; const QString requestId = QLatin1String("request id 12342"); const QString title = QLatin1String("Title for the signon-ui window"); QVariantMap clientData; clientData[SSOUI_KEY_WINDOWID] = (uint)windowId; clientData[SSOUI_KEY_EMBEDDED] = true; QVariantMap parameters; parameters[SSOUI_KEY_REQUESTID] = requestId; parameters[SSOUI_KEY_TITLE] = title; parameters[SSOUI_KEY_QUERYPASSWORD] = true; parameters[SSOUI_KEY_CLIENT_DATA] = clientData; Request *request = Request::newRequest(m_dbusConnection, m_dbusMessage, parameters, this); QVERIFY(request != 0); QCOMPARE(request->parent(), this); QCOMPARE(request->id(), requestId); QCOMPARE(request->windowId(), windowId); QCOMPARE(request->embeddedUi(), true); QCOMPARE(request->parameters(), parameters); QCOMPARE(request->clientData(), clientData); QCOMPARE(request->isInProgress(), false); /* make sure that the request is of type DialogRequest */ QCOMPARE(request->metaObject()->className(), "SignOnUi::DialogRequest"); delete request; /* Now slightly modify the request parameters, so that a BrowserRequest * will be created instead */ parameters[SSOUI_KEY_OPENURL] = "http://localhost:9999/page404.html"; request = Request::newRequest(m_dbusConnection, m_dbusMessage, parameters, this); QVERIFY(request != 0); QCOMPARE(request->metaObject()->className(), "SignOnUi::BrowserRequest"); delete request; } void SignOnUiTest::testRequestWithIndicator() { const uint signonId = 1234; const QString displayName = QLatin1String("Beautiful account"); /* create an account claiming to use our fake signon-id */ Accounts::Manager *manager = new Accounts::Manager(this); /* first, create a couple of dummy accounts */ Accounts::Account *account = manager->createAccount(0); account->setEnabled(true); account->syncAndBlock(); account = manager->createAccount(0); account->setValue("CredentialsId", 0xdeadbeef); account->setEnabled(true); account->syncAndBlock(); /* now create the "good" account */ account = manager->createAccount(0); account->setValue("CredentialsId", signonId); account->setEnabled(true); account->setDisplayName(displayName); account->syncAndBlock(); /* now create a request */ QVariantMap parameters; parameters[SSOUI_KEY_QUERYPASSWORD] = true; parameters[SSOUI_KEY_IDENTITY] = signonId; Request *request = Request::newRequest(m_dbusConnection, m_dbusMessage, parameters, this); QVERIFY(request != 0); QCOMPARE(request->isInProgress(), false); QSignalSpy requestCompleted(request, SIGNAL(completed())); request->start(); QCOMPARE(requestCompleted.count(), 1); ComCanonicalIndicatorsWebcredentialsInterface *indicator = ComCanonicalIndicatorsWebcredentialsInterface::instance(); QVERIFY(indicator != 0); QCOMPARE(indicator->m_reportFailureCalled, true); QCOMPARE(indicator->m_account_id, account->id()); QCOMPARE(indicator->m_notification["DisplayName"].toString(), displayName); delete request; delete manager; } static void prepareAuthData(AuthData &authData, int identity) { QVariantMap sessionData; sessionData["Int"] = identity; authData.identity = identity; authData.sessionData = sessionData; authData.method = QString::fromLatin1("method%1").arg(identity); authData.mechanism = QString::fromLatin1("mechanism%1").arg(identity); } void SignOnUiTest::testReauthenticator() { QList failuresData; for (int i = 1; i < 8; i++) { AuthData authData; prepareAuthData(authData, i); failuresData.append(authData); } QVariantMap extraParameters; extraParameters["Greeting"] = QString::fromLatin1("Hello!"); Reauthenticator *reauthenticator = new Reauthenticator(failuresData, extraParameters); QSignalSpy finished(reauthenticator, SIGNAL(finished(bool))); reauthenticator->start(); QTest::qWait(200); QCOMPARE(finished.count(), 1); QList arguments = finished.takeFirst(); // first signal /* The reauthentication failed because of some invalid identities * created by the fake libsignon.*/ QCOMPARE(arguments.at(0).toBool(), false); delete reauthenticator; /* Now create the AuthData for the identities which are known to work */ failuresData.clear(); AuthData authData; prepareAuthData(authData, 1); failuresData.append(authData); prepareAuthData(authData, 2); failuresData.append(authData); prepareAuthData(authData, 4); failuresData.append(authData); reauthenticator = new Reauthenticator(failuresData, extraParameters); QSignalSpy finished2(reauthenticator, SIGNAL(finished(bool))); reauthenticator->start(); QTest::qWait(200); QCOMPARE(finished2.count(), 1); arguments = finished2.takeFirst(); // first signal QCOMPARE(arguments.at(0).toBool(), true); delete reauthenticator; } void SignOnUiTest::testIndicatorService() { const uint firstFailure = 413; QVERIFY(IndicatorService::instance() == 0); IndicatorService *service = new IndicatorService(); QVERIFY(service != 0); QCOMPARE(IndicatorService::instance(), service); QVERIFY(service->serviceObject() != 0); // Check initial status QVERIFY(service->failures().isEmpty()); QCOMPARE(service->errorStatus(), false); // Report the first failure service->reportFailure(firstFailure, QVariantMap()); QCOMPARE(FakeLibNotify::notificationCount(), 1); QCOMPARE(service->errorStatus(), true); QCOMPARE(service->failures().count(), 1); QVERIFY(service->failures().contains(firstFailure)); // Report more failures QList moreFailures; moreFailures << 89 << 412 << 1 << 4 << 144; foreach (uint id, moreFailures) { service->reportFailure(id, QVariantMap()); } QCOMPARE(FakeLibNotify::notificationCount(), 1); QCOMPARE(service->errorStatus(), true); QCOMPARE(service->failures().count(), 1 + moreFailures.count()); // Remove some failures QSet removedFailures; removedFailures << 4 << firstFailure << 89; service->removeFailures(removedFailures); QSet remainingFailures; remainingFailures << 412 << 1 << 144; QCOMPARE(FakeLibNotify::notificationCount(), 1); QCOMPARE(service->errorStatus(), true); QCOMPARE(service->failures(), remainingFailures); // Clear the error status service->clearErrorStatus(); QCOMPARE(service->errorStatus(), false); QCOMPARE(service->failures(), remainingFailures); // Send one more failure service->reportFailure(3, QVariantMap()); QCOMPARE(FakeLibNotify::notificationCount(), 2); QCOMPARE(service->errorStatus(), true); delete service; QVERIFY(IndicatorService::instance() == 0); } QTEST_MAIN(SignOnUiTest); signon-ui/tests/unit/test.h0000664000175000017500000000233414615655426016151 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2012 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef SIGNON_UI_TEST_H #define SIGNON_UI_TEST_H #include #include #include class SignOnUiTest: public QObject { Q_OBJECT public: SignOnUiTest(); private Q_SLOTS: void initTestCase(); void testRequestObjects(); void testRequestWithIndicator(); void testReauthenticator(); void testIndicatorService(); private: QDBusConnection m_dbusConnection; QDBusMessage m_dbusMessage; }; #endif // SIGNON_UI_TEST_H signon-ui/tests/unit/tst_inactivity_timer.cpp0000664000175000017500000000632714615655426022010 0ustar coucoufcoucouf/* * This file is part of signon-ui * * Copyright (C) 2013 Canonical Ltd. * * Contact: Alberto Mardegan * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #include "debug.h" #include "inactivity-timer.h" #include #include #include #include using namespace SignOnUi; class InactivityTest: public QObject { Q_OBJECT public: InactivityTest() {}; private Q_SLOTS: void testAlwaysIdle(); void testIdleThenBusy(); void testStartBusy(); }; class TestObject: public QObject { Q_OBJECT Q_PROPERTY(bool isIdle READ isIdle NOTIFY isIdleChanged) public: TestObject(): QObject(0), m_isIdle(false) {} ~TestObject() {} bool isIdle() const { return m_isIdle; } void setIdle(bool idle) { if (idle == m_isIdle) return; m_isIdle = idle; Q_EMIT isIdleChanged(); } Q_SIGNALS: void isIdleChanged(); private: bool m_isIdle; }; void InactivityTest::testAlwaysIdle() { InactivityTimer inactivityTimer(100); QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout())); TestObject object1; object1.setIdle(true); inactivityTimer.watchObject(&object1); TestObject object2; object2.setIdle(true); inactivityTimer.watchObject(&object2); QCOMPARE(timeout.count(), 0); QTest::qWait(150); QCOMPARE(timeout.count(), 1); } void InactivityTest::testIdleThenBusy() { InactivityTimer inactivityTimer(100); QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout())); TestObject object1; object1.setIdle(true); inactivityTimer.watchObject(&object1); TestObject object2; object2.setIdle(true); inactivityTimer.watchObject(&object2); QCOMPARE(timeout.count(), 0); QTest::qWait(30); QCOMPARE(timeout.count(), 0); object2.setIdle(false); QTest::qWait(100); QCOMPARE(timeout.count(), 0); object2.setIdle(true); QTest::qWait(30); QCOMPARE(timeout.count(), 0); QTest::qWait(100); QCOMPARE(timeout.count(), 1); } void InactivityTest::testStartBusy() { InactivityTimer inactivityTimer(100); QSignalSpy timeout(&inactivityTimer, SIGNAL(timeout())); TestObject object1; inactivityTimer.watchObject(&object1); TestObject object2; inactivityTimer.watchObject(&object2); QCOMPARE(timeout.count(), 0); QTest::qWait(130); QCOMPARE(timeout.count(), 0); object2.setIdle(true); QTest::qWait(130); QCOMPARE(timeout.count(), 0); object1.setIdle(true); QTest::qWait(30); QCOMPARE(timeout.count(), 0); QTest::qWait(100); QCOMPARE(timeout.count(), 1); } QTEST_MAIN(InactivityTest); #include "tst_inactivity_timer.moc" signon-ui/tests/unit/tst_inactivity_timer.pro0000664000175000017500000000120414615655426022013 0ustar coucoufcoucoufinclude(../../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) TARGET = tst_inactivity_timer CONFIG += \ build_all \ debug \ qtestlib QT += \ core SOURCES += \ tst_inactivity_timer.cpp \ $$TOP_SRC_DIR/src/debug.cpp \ $$TOP_SRC_DIR/src/inactivity-timer.cpp HEADERS += \ $$TOP_SRC_DIR/src/debug.h \ $$TOP_SRC_DIR/src/inactivity-timer.h INCLUDEPATH += \ . \ $$TOP_SRC_DIR/src QMAKE_CXXFLAGS += \ -fno-exceptions \ -fno-rtti DEFINES += \ DEBUG_ENABLED \ UNIT_TESTS check.commands = "xvfb-run -a ./$$TARGET" check.depends = $$TARGET QMAKE_EXTRA_TARGETS += check signon-ui/tests/unit/tst_signon_ui.pro0000664000175000017500000000422214615655426020425 0ustar coucoufcoucoufinclude(../../common-project-config.pri) include($${TOP_SRC_DIR}/common-vars.pri) TARGET = signon-ui-unittest CONFIG += \ build_all \ debug \ link_pkgconfig \ qtestlib QT += \ core \ dbus \ gui \ network \ quick lessThan(QT_MAJOR_VERSION, 6) { QT += webengine } else { QT += webenginequick } PKGCONFIG += \ signon-plugins-common \ libnotify QT += \ widgets PKGCONFIG += \ accounts-qt$$QT_MAJOR_VERSION \ libsignon-qt$$QT_MAJOR_VERSION SOURCES += \ fake-libnotify.cpp \ fake-libsignon.cpp \ fake-webcredentials-interface.cpp \ test.cpp \ $$TOP_SRC_DIR/src/animation-label.cpp \ $$TOP_SRC_DIR/src/browser-request.cpp \ $$TOP_SRC_DIR/src/cookie-jar-manager.cpp \ $$TOP_SRC_DIR/src/debug.cpp \ $$TOP_SRC_DIR/src/dialog-request.cpp \ $$TOP_SRC_DIR/src/dialog.cpp \ $$TOP_SRC_DIR/src/http-warning.cpp \ $$TOP_SRC_DIR/src/i18n.cpp \ $$TOP_SRC_DIR/src/indicator-service.cpp \ $$TOP_SRC_DIR/src/network-access-manager.cpp \ $$TOP_SRC_DIR/src/qquick-dialog.cpp \ $$TOP_SRC_DIR/src/reauthenticator.cpp \ $$TOP_SRC_DIR/src/request.cpp \ $$OUT_PWD/../../src/webcredentials_adaptor.cpp HEADERS += \ fake-libnotify.h \ fake-webcredentials-interface.h \ test.h \ $$TOP_SRC_DIR/src/animation-label.h \ $$TOP_SRC_DIR/src/browser-request.h \ $$TOP_SRC_DIR/src/debug.h \ $$TOP_SRC_DIR/src/cookie-jar-manager.h \ $$TOP_SRC_DIR/src/dialog-request.h \ $$TOP_SRC_DIR/src/dialog.h \ $$TOP_SRC_DIR/src/http-warning.h \ $$TOP_SRC_DIR/src/indicator-service.h \ $$TOP_SRC_DIR/src/network-access-manager.h \ $$TOP_SRC_DIR/src/qquick-dialog.h \ $$TOP_SRC_DIR/src/reauthenticator.h \ $$TOP_SRC_DIR/src/request.h \ $$OUT_PWD/../../src/webcredentials_adaptor.h INCLUDEPATH += \ . \ $$TOP_SRC_DIR/src \ $$OUT_PWD/../../src QMAKE_CXXFLAGS += \ -fno-exceptions \ -fno-rtti DEFINES += \ DEBUG_ENABLED \ UNIT_TESTS RESOURCES += $$TOP_SRC_DIR/src/animationlabel.qrc check.depends = $${TARGET} check.commands = "xvfb-run -a dbus-test-runner -t ./signon-ui-unittest" QMAKE_EXTRA_TARGETS += check signon-ui/tests/unit/unit.pro0000664000175000017500000000012414615655426016515 0ustar coucoufcoucoufTEMPLATE = subdirs SUBDIRS = \ tst_inactivity_timer.pro \ tst_signon_ui.pro