From 857030249a99cbb734ab624ef4fb67215ae3d246 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 8 Dec 2010 13:14:04 -0800 Subject: [PATCH 01/73] More renaming --- protocols/vnc/AUTHORS | 1 + protocols/vnc/COPYING | 661 +++++++++++++++++++++++++++++++++ protocols/vnc/ChangeLog | 0 protocols/vnc/INSTALL | 0 protocols/vnc/Makefile.am | 11 + protocols/vnc/NEWS | 0 protocols/vnc/README | 0 protocols/vnc/configure.in | 24 ++ protocols/vnc/src/vnc_client.c | 363 ++++++++++++++++++ 9 files changed, 1060 insertions(+) create mode 100644 protocols/vnc/AUTHORS create mode 100644 protocols/vnc/COPYING create mode 100644 protocols/vnc/ChangeLog create mode 100644 protocols/vnc/INSTALL create mode 100644 protocols/vnc/Makefile.am create mode 100644 protocols/vnc/NEWS create mode 100644 protocols/vnc/README create mode 100644 protocols/vnc/configure.in create mode 100644 protocols/vnc/src/vnc_client.c diff --git a/protocols/vnc/AUTHORS b/protocols/vnc/AUTHORS new file mode 100644 index 00000000..517d7a79 --- /dev/null +++ b/protocols/vnc/AUTHORS @@ -0,0 +1 @@ +Michael Jumper diff --git a/protocols/vnc/COPYING b/protocols/vnc/COPYING new file mode 100644 index 00000000..dba13ed2 --- /dev/null +++ b/protocols/vnc/COPYING @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 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 Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are 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. + + 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. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + 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 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 work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + 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 AGPL, see +. diff --git a/protocols/vnc/ChangeLog b/protocols/vnc/ChangeLog new file mode 100644 index 00000000..e69de29b diff --git a/protocols/vnc/INSTALL b/protocols/vnc/INSTALL new file mode 100644 index 00000000..e69de29b diff --git a/protocols/vnc/Makefile.am b/protocols/vnc/Makefile.am new file mode 100644 index 00000000..e2a94211 --- /dev/null +++ b/protocols/vnc/Makefile.am @@ -0,0 +1,11 @@ +AUTOMAKE_OPTIONS = gnu + +ACLOCAL_AMFLAGS = -I m4 +AM_CFLAGS = -Werror -Wall + +lib_LTLIBRARIES = libguac_client_vnc.la + +libguac_client_vnc_la_SOURCES = src/vnc_client.c + +libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 + diff --git a/protocols/vnc/NEWS b/protocols/vnc/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/protocols/vnc/README b/protocols/vnc/README new file mode 100644 index 00000000..e69de29b diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in new file mode 100644 index 00000000..ac1015ce --- /dev/null +++ b/protocols/vnc/configure.in @@ -0,0 +1,24 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_INIT(src/vnc_client.c) +AM_INIT_AUTOMAKE([libguac_client_vnc], 0.0.1) +AC_CONFIG_MACRO_DIR([m4]) + +# Checks for programs. +AC_PROG_CC +AC_PROG_LIBTOOL + +# Checks for libraries. +AC_CHECK_LIB([guac], [guac_get_client]) +AC_CHECK_LIB([png], [png_write_png]) +AC_CHECK_LIB([vncclient], [rfbInitClient]) + +# Checks for header files. +AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio.h guacamole/protocol.h]) + +# Checks for library functions. +AC_FUNC_MALLOC + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c new file mode 100644 index 00000000..1faf25c3 --- /dev/null +++ b/protocols/vnc/src/vnc_client.c @@ -0,0 +1,363 @@ + +/* + * Guacamole - Clientless Remote Desktop + * Copyright (C) 2010 Michael Jumper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +static char* __GUAC_CLIENT = "GUAC_CLIENT"; + +typedef struct vnc_guac_client_data { + + rfbClient* rfb_client; + png_byte** png_buffer; + png_byte** png_buffer_alpha; + int copy_rect_used; + char* password; + +} vnc_guac_client_data; + +void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { + + int dx, dy; + + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + GUACIO* io = gc->io; + png_byte** png_buffer = ((vnc_guac_client_data*) gc->data)->png_buffer_alpha; + png_byte* row; + + png_byte** png_row_current = png_buffer; + + unsigned int bytesPerRow = bpp * w; + unsigned char* fb_row_current = client->rcSource; + unsigned char* fb_mask = client->rcMask; + unsigned char* fb_row; + unsigned int v; + + /* Copy image data from VNC client to PNG */ + for (dy = 0; dy> client->format.redShift) * 256 / (client->format.redMax+1); + *(row++) = (v >> client->format.greenShift) * 256 / (client->format.greenMax+1); + *(row++) = (v >> client->format.blueShift) * 256 / (client->format.blueMax+1); + + /* Handle mask */ + if (*(fb_mask++)) + *(row++) = 255; + else + *(row++) = 0; + + fb_row += bpp; + + } + } + + /* SEND CURSOR */ + guac_send_cursor(io, x, y, png_buffer, w, h); + +} + + +void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { + + int dx, dy; + + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + GUACIO* io = gc->io; + png_byte** png_buffer = ((vnc_guac_client_data*) gc->data)->png_buffer; + png_byte* row; + + png_byte** png_row_current = png_buffer; + + unsigned int bpp = client->format.bitsPerPixel/8; + unsigned int bytesPerRow = bpp * client->width; + unsigned char* fb_row_current = client->frameBuffer + (y * bytesPerRow) + (x * bpp); + unsigned char* fb_row; + unsigned int v; + + /* Ignore extra update if already handled by copyrect */ + if (((vnc_guac_client_data*) gc->data)->copy_rect_used) { + ((vnc_guac_client_data*) gc->data)->copy_rect_used = 0; + return; + } + + /* Copy image data from VNC client to PNG */ + for (dy = y; dy> client->format.redShift) * 256 / (client->format.redMax+1); + *(row++) = (v >> client->format.greenShift) * 256 / (client->format.greenMax+1); + *(row++) = (v >> client->format.blueShift) * 256 / (client->format.blueMax+1); + + fb_row += bpp; + + } + } + + guac_send_png(io, x, y, png_buffer, w, h); + +} + +void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) { + + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + GUACIO* io = gc->io; + + guac_send_copy(io, src_x, src_y, w, h, dest_x, dest_y); + ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; + +} + +char* guac_vnc_get_password(rfbClient* client) { + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + return ((vnc_guac_client_data*) gc->data)->password; +} + + +void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { + + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + GUACIO* io = gc->io; + + guac_send_clipboard(io, text); + +} + + +int vnc_guac_client_handle_messages(guac_client* client) { + + int wait_result; + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + + + wait_result = WaitForMessage(rfb_client, 2000); + if (wait_result < 0) { + syslog(LOG_ERR, "Error waiting for VNC server message\n"); + return 1; + } + + if (wait_result > 0) { + + struct timespec sleep_period; + + if (!HandleRFBServerMessage(rfb_client)) { + syslog(LOG_ERR, "Error handling VNC server message\n"); + return 1; + } + + /* Wait before returning ... don't want to handle + * too many server messages. */ + + sleep_period.tv_sec = 0; + sleep_period.tv_nsec = 50000000L /* 50 ms */; + + nanosleep(&sleep_period, NULL); + + } + + return 0; + +} + + +int vnc_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { + + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + + SendPointerEvent(rfb_client, x, y, mask); + + return 0; +} + +int vnc_guac_client_key_handler(guac_client* client, int keysym, int pressed) { + + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + + SendKeyEvent(rfb_client, keysym, pressed); + + return 0; +} + +int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { + + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + + SendClientCutText(rfb_client, data, strlen(data)); + + return 0; +} + +int vnc_guac_client_free_handler(guac_client* client) { + + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + png_byte** png_buffer = ((vnc_guac_client_data*) client->data)->png_buffer; + png_byte** png_buffer_alpha = ((vnc_guac_client_data*) client->data)->png_buffer_alpha; + + /* Free PNG data */ + guac_free_png_buffer(png_buffer, rfb_client->height); + guac_free_png_buffer(png_buffer_alpha, rfb_client->height); + + /* Clean up VNC client*/ + rfbClientCleanup(rfb_client); + + return 0; +} + + +int guac_client_init(guac_client* client, int argc, char** argv) { + + rfbClient* rfb_client; + + png_byte** png_buffer; + png_byte** png_buffer_alpha; + + vnc_guac_client_data* guac_client_data; + + /*** INIT ***/ + rfb_client = rfbGetClient(8, 3, 4); /* 32-bpp client */ + + /* Framebuffer update handler */ + rfb_client->GotFrameBufferUpdate = guac_vnc_update; + rfb_client->GotCopyRect = guac_vnc_copyrect; + + /* Enable client-side cursor */ + rfb_client->GotCursorShape = guac_vnc_cursor; + rfb_client->appData.useRemoteCursor = TRUE; + + /* Clipboard */ + rfb_client->GotXCutText = guac_vnc_cut_text; + + /* Password */ + rfb_client->GetPassword = guac_vnc_get_password; + + if (argc < 3) { + guac_send_error(client->io, "VNC client requires hostname and port arguments"); + guac_flush(client->io); + return 1; + } + + /* Alloc client data */ + guac_client_data = malloc(sizeof(vnc_guac_client_data)); + client->data = guac_client_data; + + /* Store Guac client in rfb client */ + rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client); + + /* Parse password from args if provided */ + if (argc >= 4) { + + /* Freed after use by libvncclient */ + guac_client_data->password = malloc(64); + strncpy(guac_client_data->password, argv[3], 63); + + } + else { + + /* Freed after use by libvncclient */ + guac_client_data->password = malloc(64); + guac_client_data->password[0] = '\0'; + + } + + /* Set hostname and port */ + rfb_client->serverHost = strdup(argv[1]); + rfb_client->serverPort = atoi(argv[2]); + + /* Connect */ + if (!rfbInitClient(rfb_client, NULL, NULL)) { + guac_send_error(client->io, "Error initializing VNC client"); + guac_flush(client->io); + return 1; + } + + /* Allocate buffers */ + png_buffer = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 3); /* No-alpha */ + png_buffer_alpha = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 4); /* With alpha */ + + /* Set remaining client data */ + guac_client_data->rfb_client = rfb_client; + guac_client_data->png_buffer = png_buffer; + guac_client_data->png_buffer_alpha = png_buffer_alpha; + guac_client_data->copy_rect_used = 0; + + /* Set handlers */ + client->handle_messages = vnc_guac_client_handle_messages; + client->mouse_handler = vnc_guac_client_mouse_handler; + client->key_handler = vnc_guac_client_key_handler; + client->clipboard_handler = vnc_guac_client_clipboard_handler; + + /* Send name */ + guac_send_name(client->io, rfb_client->desktopName); + + /* Send size */ + guac_send_size(client->io, rfb_client->width, rfb_client->height); + + return 0; + +} + From c1e6b2c7f389d1b75bcab084cc1fea2ce0b72252 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 13 Dec 2010 23:09:10 -0800 Subject: [PATCH 02/73] Renamed package --- protocols/vnc/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index ac1015ce..05ffff6c 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT(src/vnc_client.c) -AM_INIT_AUTOMAKE([libguac_client_vnc], 0.0.1) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.0.1) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. From d1f20b04d2a594cad6e9ffb42a64d4c95eb9f20d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 14 Dec 2010 01:34:54 -0800 Subject: [PATCH 03/73] Adding .gitignore --- protocols/vnc/.gitignore | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 protocols/vnc/.gitignore diff --git a/protocols/vnc/.gitignore b/protocols/vnc/.gitignore new file mode 100644 index 00000000..e37f9166 --- /dev/null +++ b/protocols/vnc/.gitignore @@ -0,0 +1,35 @@ + +# Object code +*.o +*.so +*.lo +*.la + +# Backup files +*~ + +# Release files +*.tar.gz + +# Files currently being edited by vim or vi +*.swp + +# automake/autoconf +.deps/ +.libs/ +Makefile +Makefile.in +aclocal.m4 +autom4te.cache/ +m4/ +config.guess +config.log +config.status +config.sub +configure +depcomp +install-sh +libtool +ltmain.sh +missing + From e55280d3080e7e579481f1e4c32d61981027466c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 15 Dec 2010 11:41:21 -0800 Subject: [PATCH 04/73] configure.in should specify errors for missing libs --- protocols/vnc/configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 05ffff6c..35d8c3fa 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -10,9 +10,9 @@ AC_PROG_CC AC_PROG_LIBTOOL # Checks for libraries. -AC_CHECK_LIB([guac], [guac_get_client]) -AC_CHECK_LIB([png], [png_write_png]) -AC_CHECK_LIB([vncclient], [rfbInitClient]) +AC_CHECK_LIB([guac], [guac_get_client],, AC_MSG_ERROR("libguac is required for communication via the guacamole protocol")) +AC_CHECK_LIB([png], [png_write_png],, AC_MSG_ERROR("libpng is required for writing png messages")) +AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is required")) # Checks for header files. AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio.h guacamole/protocol.h]) From c3e4df73f116e7d58aa19bc4f6f6790ed4bdbc8a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 17 Dec 2010 15:16:34 -0800 Subject: [PATCH 05/73] Adding package descriptor for build system --- protocols/vnc/.package.dsc | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 protocols/vnc/.package.dsc diff --git a/protocols/vnc/.package.dsc b/protocols/vnc/.package.dsc new file mode 100644 index 00000000..c22c1f7c --- /dev/null +++ b/protocols/vnc/.package.dsc @@ -0,0 +1,2 @@ +PKGNAME=libguac-client-vnc +VERSION=0.0.1 From fbba21feac7dd66c41d1a48ea02d23775de73ef0 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 22 Dec 2010 02:00:13 -0800 Subject: [PATCH 06/73] Fixing memory leak of client data struct --- protocols/vnc/src/vnc_client.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 1faf25c3..9cc91f4f 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -262,6 +262,9 @@ int vnc_guac_client_free_handler(guac_client* client) { guac_free_png_buffer(png_buffer, rfb_client->height); guac_free_png_buffer(png_buffer_alpha, rfb_client->height); + /* Free generic data struct */ + free(client->data); + /* Clean up VNC client*/ rfbClientCleanup(rfb_client); From 081df9339b876c4c6e7ce3b02c20ea251ef072d4 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 1 Jan 2011 13:23:53 -0800 Subject: [PATCH 07/73] Added args, shifted left one now that protocol isn't passed as args to connect --- protocols/vnc/src/vnc_client.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 9cc91f4f..5c0e11e2 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -31,6 +31,14 @@ #include #include +/* Client plugin arguments */ +const char* GUAC_CLIENT_ARGS[] = { + "hostname", + "port", + "password", + NULL +}; + static char* __GUAC_CLIENT = "GUAC_CLIENT"; typedef struct vnc_guac_client_data { @@ -298,7 +306,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Password */ rfb_client->GetPassword = guac_vnc_get_password; - if (argc < 3) { + if (argc < 2) { guac_send_error(client->io, "VNC client requires hostname and port arguments"); guac_flush(client->io); return 1; @@ -312,11 +320,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) { rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client); /* Parse password from args if provided */ - if (argc >= 4) { + if (argc >= 3) { /* Freed after use by libvncclient */ guac_client_data->password = malloc(64); - strncpy(guac_client_data->password, argv[3], 63); + strncpy(guac_client_data->password, argv[2], 63); } else { @@ -328,8 +336,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) { } /* Set hostname and port */ - rfb_client->serverHost = strdup(argv[1]); - rfb_client->serverPort = atoi(argv[2]); + rfb_client->serverHost = strdup(argv[0]); + rfb_client->serverPort = atoi(argv[1]); /* Connect */ if (!rfbInitClient(rfb_client, NULL, NULL)) { From 320b1e7f54c63016078d797223e94522a4870a2c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 8 Feb 2011 19:42:40 -0800 Subject: [PATCH 08/73] Added cross-platform sleep --- protocols/vnc/src/vnc_client.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 5c0e11e2..b25ce082 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include @@ -196,6 +196,22 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { } +void vnc_guac_client_sleep(int millis) { + +#ifdef nanosleep + struct timespec sleep_period; + + sleep_period.tv_sec = 0; + sleep_period.tv_nsec = millis * 1000000L; + + nanosleep(&sleep_period, NULL); +#else +#ifdef Sleep + Sleep(millis) +#endif +#endif + +} int vnc_guac_client_handle_messages(guac_client* client) { @@ -205,26 +221,21 @@ int vnc_guac_client_handle_messages(guac_client* client) { wait_result = WaitForMessage(rfb_client, 2000); if (wait_result < 0) { - syslog(LOG_ERR, "Error waiting for VNC server message\n"); + GUAC_LOG_ERROR("Error waiting for VNC server message\n"); return 1; } if (wait_result > 0) { - struct timespec sleep_period; - if (!HandleRFBServerMessage(rfb_client)) { - syslog(LOG_ERR, "Error handling VNC server message\n"); + GUAC_LOG_ERROR("Error handling VNC server message\n"); return 1; } /* Wait before returning ... don't want to handle * too many server messages. */ - sleep_period.tv_sec = 0; - sleep_period.tv_nsec = 50000000L /* 50 ms */; - - nanosleep(&sleep_period, NULL); + vnc_guac_client_sleep(50); } From 935d18ba019d65cc295538b3e5949e3c6cabbec9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 9 Feb 2011 01:40:46 -0800 Subject: [PATCH 09/73] Using new header --- protocols/vnc/src/vnc_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index b25ce082..140f85a3 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -23,7 +23,7 @@ #include #include -#include +#include #include From 6355be0f36dc000c972b77f84fb8ff0afddb98f1 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 10 Feb 2011 22:56:47 -0800 Subject: [PATCH 10/73] Read-only mode --- protocols/vnc/src/vnc_client.c | 62 ++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 140f85a3..6c374433 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -35,6 +35,7 @@ const char* GUAC_CLIENT_ARGS[] = { "hostname", "port", + "read-only", "password", NULL }; @@ -300,22 +301,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) { vnc_guac_client_data* guac_client_data; - /*** INIT ***/ - rfb_client = rfbGetClient(8, 3, 4); /* 32-bpp client */ + int read_only = 0; - /* Framebuffer update handler */ - rfb_client->GotFrameBufferUpdate = guac_vnc_update; - rfb_client->GotCopyRect = guac_vnc_copyrect; - - /* Enable client-side cursor */ - rfb_client->GotCursorShape = guac_vnc_cursor; - rfb_client->appData.useRemoteCursor = TRUE; - - /* Clipboard */ - rfb_client->GotXCutText = guac_vnc_cut_text; - - /* Password */ - rfb_client->GetPassword = guac_vnc_get_password; + /*** PARSE ARGUMENTS ***/ if (argc < 2) { guac_send_error(client->io, "VNC client requires hostname and port arguments"); @@ -327,15 +315,18 @@ int guac_client_init(guac_client* client, int argc, char** argv) { guac_client_data = malloc(sizeof(vnc_guac_client_data)); client->data = guac_client_data; - /* Store Guac client in rfb client */ - rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client); + /* If read-only specified, set flag */ + if (argc >= 3) { + if (strcmp(argv[2], "true") == 0) + read_only = 1; + } /* Parse password from args if provided */ - if (argc >= 3) { + if (argc >= 4) { /* Freed after use by libvncclient */ guac_client_data->password = malloc(64); - strncpy(guac_client_data->password, argv[2], 63); + strncpy(guac_client_data->password, argv[3], 63); } else { @@ -346,6 +337,30 @@ int guac_client_init(guac_client* client, int argc, char** argv) { } + /*** INIT RFB CLIENT ***/ + + rfb_client = rfbGetClient(8, 3, 4); /* 32-bpp client */ + + /* Framebuffer update handler */ + rfb_client->GotFrameBufferUpdate = guac_vnc_update; + rfb_client->GotCopyRect = guac_vnc_copyrect; + + /* Do not handle clipboard and local cursor if read-only */ + if (read_only == 0) { + /* Enable client-side cursor */ + rfb_client->GotCursorShape = guac_vnc_cursor; + rfb_client->appData.useRemoteCursor = TRUE; + + /* Clipboard */ + rfb_client->GotXCutText = guac_vnc_cut_text; + } + + /* Password */ + rfb_client->GetPassword = guac_vnc_get_password; + + /* Store Guac client in rfb client */ + rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client); + /* Set hostname and port */ rfb_client->serverHost = strdup(argv[0]); rfb_client->serverPort = atoi(argv[1]); @@ -369,9 +384,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Set handlers */ client->handle_messages = vnc_guac_client_handle_messages; - client->mouse_handler = vnc_guac_client_mouse_handler; - client->key_handler = vnc_guac_client_key_handler; - client->clipboard_handler = vnc_guac_client_clipboard_handler; + if (read_only == 0) { + /* Do not handle mouse/keyboard/clipboard if read-only */ + client->mouse_handler = vnc_guac_client_mouse_handler; + client->key_handler = vnc_guac_client_key_handler; + client->clipboard_handler = vnc_guac_client_clipboard_handler; + } /* Send name */ guac_send_name(client->io, rfb_client->desktopName); From d9682409f759d18faf71ab4491030f2b29af79f1 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 11 Feb 2011 00:21:54 -0800 Subject: [PATCH 11/73] Fixed detection of nanosleep. --- protocols/vnc/configure.in | 1 + protocols/vnc/src/vnc_client.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 35d8c3fa..2080594c 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -18,6 +18,7 @@ AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is requir AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio.h guacamole/protocol.h]) # Checks for library functions. +AC_CHECK_FUNCS([nanosleep]) AC_FUNC_MALLOC AC_CONFIG_FILES([Makefile]) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 6c374433..f66997cd 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -199,17 +199,17 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { void vnc_guac_client_sleep(int millis) { -#ifdef nanosleep +#ifdef HAVE_NANOSLEEP struct timespec sleep_period; sleep_period.tv_sec = 0; sleep_period.tv_nsec = millis * 1000000L; nanosleep(&sleep_period, NULL); -#else -#ifdef Sleep +#elif defined(__MINGW32__) Sleep(millis) -#endif +#else +#warning No sleep/nanosleep function available. VNC client may not perform as expected. Consider editing the vnc_client.c to add support for your platform. #endif } From 5a3eb36e2c7fd1698e9f2b04101aa89ae079a415 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 11 Feb 2011 23:19:35 -0800 Subject: [PATCH 12/73] Migrated to newer libguac (layer support) --- protocols/vnc/src/vnc_client.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 6c374433..169f2d94 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -168,7 +168,8 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { } } - guac_send_png(io, x, y, png_buffer, w, h); + /* For now, only use layer 0 */ + guac_send_png(io, 0, x, y, png_buffer, w, h); } @@ -177,7 +178,8 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, in guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); GUACIO* io = gc->io; - guac_send_copy(io, src_x, src_y, w, h, dest_x, dest_y); + /* For now, only use layer 0 */ + guac_send_copy(io, 0, src_x, src_y, w, h, 0, dest_x, dest_y); ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; } From 8d0c3ac46b4f7f1d3661e49e7eb3eca14a975e18 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 15 Feb 2011 18:47:51 -0800 Subject: [PATCH 13/73] Changing to MPL/GPL/LGPL tri-license --- protocols/vnc/COPYING | 1131 +++++++++++++------------------- protocols/vnc/src/vnc_client.c | 46 +- 2 files changed, 502 insertions(+), 675 deletions(-) diff --git a/protocols/vnc/COPYING b/protocols/vnc/COPYING index dba13ed2..7714141d 100644 --- a/protocols/vnc/COPYING +++ b/protocols/vnc/COPYING @@ -1,661 +1,470 @@ - GNU AFFERO GENERAL PUBLIC LICENSE - Version 3, 19 November 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 Affero General Public License is a free, copyleft license for -software and other kinds of works, specifically designed to ensure -cooperation with the community in the case of network server software. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -our General Public Licenses are 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. - - 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. - - Developers that use our General Public Licenses protect your rights -with two steps: (1) assert copyright on the software, and (2) offer -you this License which gives you legal permission to copy, distribute -and/or modify the software. - - A secondary benefit of defending all users' freedom is that -improvements made in alternate versions of the program, if they -receive widespread use, become available for other developers to -incorporate. Many developers of free software are heartened and -encouraged by the resulting cooperation. However, in the case of -software used on network servers, this result may fail to come about. -The GNU General Public License permits making a modified version and -letting the public access it on a server without ever releasing its -source code to the public. - - The GNU Affero General Public License is designed specifically to -ensure that, in such cases, the modified source code becomes available -to the community. It requires the operator of a network server to -provide the source code of the modified version running there to the -users of that server. Therefore, public use of a modified version, on -a publicly accessible server, gives the public access to the source -code of the modified version. - - An older license, called the Affero General Public License and -published by Affero, was designed to accomplish similar goals. This is -a different license, not a version of the Affero GPL, but Affero has -released a new version of the Affero GPL which permits relicensing under -this license. - - 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. - - Notwithstanding any other provision of this License, if you modify the -Program, your modified version must prominently offer all users -interacting with it remotely through a computer network (if your version -supports such interaction) an opportunity to receive the Corresponding -Source of your version by providing access to the Corresponding Source -from a network server at no charge, through some standard or customary -means of facilitating copying of software. This Corresponding Source -shall include the Corresponding Source for any work covered by version 3 -of the GNU General Public License that is incorporated pursuant to the -following paragraph. - - 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 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 work with which it is combined will remain governed by version -3 of the GNU General Public License. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If your software can interact with users remotely through a computer -network, you should also make sure that it provides a way for users to -get its source. For example, if your program is a web application, its -interface could display a "Source" link that leads users to an archive -of the code. There are many ways you could offer source, and different -solutions will be better for different programs; see section 13 for the -specific requirements. - - 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 AGPL, see -. + MOZILLA PUBLIC LICENSE + Version 1.1 + + --------------- + +1. Definitions. + + 1.0.1. "Commercial Use" means distribution or otherwise making the + Covered Code available to a third party. + + 1.1. "Contributor" means each entity that creates or contributes to + the creation of Modifications. + + 1.2. "Contributor Version" means the combination of the Original + Code, prior Modifications used by a Contributor, and the Modifications + made by that particular Contributor. + + 1.3. "Covered Code" means the Original Code or Modifications or the + combination of the Original Code and Modifications, in each case + including portions thereof. + + 1.4. "Electronic Distribution Mechanism" means a mechanism generally + accepted in the software development community for the electronic + transfer of data. + + 1.5. "Executable" means Covered Code in any form other than Source + Code. + + 1.6. "Initial Developer" means the individual or entity identified + as the Initial Developer in the Source Code notice required by Exhibit + A. + + 1.7. "Larger Work" means a work which combines Covered Code or + portions thereof with code not governed by the terms of this License. + + 1.8. "License" means this document. + + 1.8.1. "Licensable" means having the right to grant, to the maximum + extent possible, whether at the time of the initial grant or + subsequently acquired, any and all of the rights conveyed herein. + + 1.9. "Modifications" means any addition to or deletion from the + substance or structure of either the Original Code or any previous + Modifications. When Covered Code is released as a series of files, a + Modification is: + A. Any addition to or deletion from the contents of a file + containing Original Code or previous Modifications. + + B. Any new file that contains any part of the Original Code or + previous Modifications. + + 1.10. "Original Code" means Source Code of computer software code + which is described in the Source Code notice required by Exhibit A as + Original Code, and which, at the time of its release under this + License is not already Covered Code governed by this License. + + 1.10.1. "Patent Claims" means any patent claim(s), now owned or + hereafter acquired, including without limitation, method, process, + and apparatus claims, in any patent Licensable by grantor. + + 1.11. "Source Code" means the preferred form of the Covered Code for + making modifications to it, including all modules it contains, plus + any associated interface definition files, scripts used to control + compilation and installation of an Executable, or source code + differential comparisons against either the Original Code or another + well known, available Covered Code of the Contributor's choice. The + Source Code can be in a compressed or archival form, provided the + appropriate decompression or de-archiving software is widely available + for no charge. + + 1.12. "You" (or "Your") means an individual or a legal entity + exercising rights under, and complying with all of the terms of, this + License or a future version of this License issued under Section 6.1. + For legal entities, "You" includes any entity which controls, is + controlled by, or is under common control with You. For purposes of + this definition, "control" means (a) the power, direct or indirect, + to cause the direction or management of such entity, whether by + contract or otherwise, or (b) ownership of more than fifty percent + (50%) of the outstanding shares or beneficial ownership of such + entity. + +2. Source Code License. + + 2.1. The Initial Developer Grant. + The Initial Developer hereby grants You a world-wide, royalty-free, + non-exclusive license, subject to third party intellectual property + claims: + (a) under intellectual property rights (other than patent or + trademark) Licensable by Initial Developer to use, reproduce, + modify, display, perform, sublicense and distribute the Original + Code (or portions thereof) with or without Modifications, and/or + as part of a Larger Work; and + + (b) under Patents Claims infringed by the making, using or + selling of Original Code, to make, have made, use, practice, + sell, and offer for sale, and/or otherwise dispose of the + Original Code (or portions thereof). + + (c) the licenses granted in this Section 2.1(a) and (b) are + effective on the date Initial Developer first distributes + Original Code under the terms of this License. + + (d) Notwithstanding Section 2.1(b) above, no patent license is + granted: 1) for code that You delete from the Original Code; 2) + separate from the Original Code; or 3) for infringements caused + by: i) the modification of the Original Code or ii) the + combination of the Original Code with other software or devices. + + 2.2. Contributor Grant. + Subject to third party intellectual property claims, each Contributor + hereby grants You a world-wide, royalty-free, non-exclusive license + + (a) under intellectual property rights (other than patent or + trademark) Licensable by Contributor, to use, reproduce, modify, + display, perform, sublicense and distribute the Modifications + created by such Contributor (or portions thereof) either on an + unmodified basis, with other Modifications, as Covered Code + and/or as part of a Larger Work; and + + (b) under Patent Claims infringed by the making, using, or + selling of Modifications made by that Contributor either alone + and/or in combination with its Contributor Version (or portions + of such combination), to make, use, sell, offer for sale, have + made, and/or otherwise dispose of: 1) Modifications made by that + Contributor (or portions thereof); and 2) the combination of + Modifications made by that Contributor with its Contributor + Version (or portions of such combination). + + (c) the licenses granted in Sections 2.2(a) and 2.2(b) are + effective on the date Contributor first makes Commercial Use of + the Covered Code. + + (d) Notwithstanding Section 2.2(b) above, no patent license is + granted: 1) for any code that Contributor has deleted from the + Contributor Version; 2) separate from the Contributor Version; + 3) for infringements caused by: i) third party modifications of + Contributor Version or ii) the combination of Modifications made + by that Contributor with other software (except as part of the + Contributor Version) or other devices; or 4) under Patent Claims + infringed by Covered Code in the absence of Modifications made by + that Contributor. + +3. Distribution Obligations. + + 3.1. Application of License. + The Modifications which You create or to which You contribute are + governed by the terms of this License, including without limitation + Section 2.2. The Source Code version of Covered Code may be + distributed only under the terms of this License or a future version + of this License released under Section 6.1, and You must include a + copy of this License with every copy of the Source Code You + distribute. You may not offer or impose any terms on any Source Code + version that alters or restricts the applicable version of this + License or the recipients' rights hereunder. However, You may include + an additional document offering the additional rights described in + Section 3.5. + + 3.2. Availability of Source Code. + Any Modification which You create or to which You contribute must be + made available in Source Code form under the terms of this License + either on the same media as an Executable version or via an accepted + Electronic Distribution Mechanism to anyone to whom you made an + Executable version available; and if made available via Electronic + Distribution Mechanism, must remain available for at least twelve (12) + months after the date it initially became available, or at least six + (6) months after a subsequent version of that particular Modification + has been made available to such recipients. You are responsible for + ensuring that the Source Code version remains available even if the + Electronic Distribution Mechanism is maintained by a third party. + + 3.3. Description of Modifications. + You must cause all Covered Code to which You contribute to contain a + file documenting the changes You made to create that Covered Code and + the date of any change. You must include a prominent statement that + the Modification is derived, directly or indirectly, from Original + Code provided by the Initial Developer and including the name of the + Initial Developer in (a) the Source Code, and (b) in any notice in an + Executable version or related documentation in which You describe the + origin or ownership of the Covered Code. + + 3.4. Intellectual Property Matters + (a) Third Party Claims. + If Contributor has knowledge that a license under a third party's + intellectual property rights is required to exercise the rights + granted by such Contributor under Sections 2.1 or 2.2, + Contributor must include a text file with the Source Code + distribution titled "LEGAL" which describes the claim and the + party making the claim in sufficient detail that a recipient will + know whom to contact. If Contributor obtains such knowledge after + the Modification is made available as described in Section 3.2, + Contributor shall promptly modify the LEGAL file in all copies + Contributor makes available thereafter and shall take other steps + (such as notifying appropriate mailing lists or newsgroups) + reasonably calculated to inform those who received the Covered + Code that new knowledge has been obtained. + + (b) Contributor APIs. + If Contributor's Modifications include an application programming + interface and Contributor has knowledge of patent licenses which + are reasonably necessary to implement that API, Contributor must + also include this information in the LEGAL file. + + (c) Representations. + Contributor represents that, except as disclosed pursuant to + Section 3.4(a) above, Contributor believes that Contributor's + Modifications are Contributor's original creation(s) and/or + Contributor has sufficient rights to grant the rights conveyed by + this License. + + 3.5. Required Notices. + You must duplicate the notice in Exhibit A in each file of the Source + Code. If it is not possible to put such notice in a particular Source + Code file due to its structure, then You must include such notice in a + location (such as a relevant directory) where a user would be likely + to look for such a notice. If You created one or more Modification(s) + You may add your name as a Contributor to the notice described in + Exhibit A. You must also duplicate this License in any documentation + for the Source Code where You describe recipients' rights or ownership + rights relating to Covered Code. You may choose to offer, and to + charge a fee for, warranty, support, indemnity or liability + obligations to one or more recipients of Covered Code. However, You + may do so only on Your own behalf, and not on behalf of the Initial + Developer or any Contributor. You must make it absolutely clear than + any such warranty, support, indemnity or liability obligation is + offered by You alone, and You hereby agree to indemnify the Initial + Developer and every Contributor for any liability incurred by the + Initial Developer or such Contributor as a result of warranty, + support, indemnity or liability terms You offer. + + 3.6. Distribution of Executable Versions. + You may distribute Covered Code in Executable form only if the + requirements of Section 3.1-3.5 have been met for that Covered Code, + and if You include a notice stating that the Source Code version of + the Covered Code is available under the terms of this License, + including a description of how and where You have fulfilled the + obligations of Section 3.2. The notice must be conspicuously included + in any notice in an Executable version, related documentation or + collateral in which You describe recipients' rights relating to the + Covered Code. You may distribute the Executable version of Covered + Code or ownership rights under a license of Your choice, which may + contain terms different from this License, provided that You are in + compliance with the terms of this License and that the license for the + Executable version does not attempt to limit or alter the recipient's + rights in the Source Code version from the rights set forth in this + License. If You distribute the Executable version under a different + license You must make it absolutely clear that any terms which differ + from this License are offered by You alone, not by the Initial + Developer or any Contributor. You hereby agree to indemnify the + Initial Developer and every Contributor for any liability incurred by + the Initial Developer or such Contributor as a result of any such + terms You offer. + + 3.7. Larger Works. + You may create a Larger Work by combining Covered Code with other code + not governed by the terms of this License and distribute the Larger + Work as a single product. In such a case, You must make sure the + requirements of this License are fulfilled for the Covered Code. + +4. Inability to Comply Due to Statute or Regulation. + + If it is impossible for You to comply with any of the terms of this + License with respect to some or all of the Covered Code due to + statute, judicial order, or regulation then You must: (a) comply with + the terms of this License to the maximum extent possible; and (b) + describe the limitations and the code they affect. Such description + must be included in the LEGAL file described in Section 3.4 and must + be included with all distributions of the Source Code. Except to the + extent prohibited by statute or regulation, such description must be + sufficiently detailed for a recipient of ordinary skill to be able to + understand it. + +5. Application of this License. + + This License applies to code to which the Initial Developer has + attached the notice in Exhibit A and to related Covered Code. + +6. Versions of the License. + + 6.1. New Versions. + Netscape Communications Corporation ("Netscape") may publish revised + and/or new versions of the License from time to time. Each version + will be given a distinguishing version number. + + 6.2. Effect of New Versions. + Once Covered Code has been published under a particular version of the + License, You may always continue to use it under the terms of that + version. You may also choose to use such Covered Code under the terms + of any subsequent version of the License published by Netscape. No one + other than Netscape has the right to modify the terms applicable to + Covered Code created under this License. + + 6.3. Derivative Works. + If You create or use a modified version of this License (which you may + only do in order to apply it to code which is not already Covered Code + governed by this License), You must (a) rename Your license so that + the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", + "MPL", "NPL" or any confusingly similar phrase do not appear in your + license (except to note that your license differs from this License) + and (b) otherwise make it clear that Your version of the license + contains terms which differ from the Mozilla Public License and + Netscape Public License. (Filling in the name of the Initial + Developer, Original Code or Contributor in the notice described in + Exhibit A shall not of themselves be deemed to be modifications of + this License.) + +7. DISCLAIMER OF WARRANTY. + + COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF + DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. + THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE + IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, + YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE + COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER + OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF + ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. + +8. TERMINATION. + + 8.1. This License and the rights granted hereunder will terminate + automatically if You fail to comply with terms herein and fail to cure + such breach within 30 days of becoming aware of the breach. All + sublicenses to the Covered Code which are properly granted shall + survive any termination of this License. Provisions which, by their + nature, must remain in effect beyond the termination of this License + shall survive. + + 8.2. If You initiate litigation by asserting a patent infringement + claim (excluding declatory judgment actions) against Initial Developer + or a Contributor (the Initial Developer or Contributor against whom + You file such action is referred to as "Participant") alleging that: + + (a) such Participant's Contributor Version directly or indirectly + infringes any patent, then any and all rights granted by such + Participant to You under Sections 2.1 and/or 2.2 of this License + shall, upon 60 days notice from Participant terminate prospectively, + unless if within 60 days after receipt of notice You either: (i) + agree in writing to pay Participant a mutually agreeable reasonable + royalty for Your past and future use of Modifications made by such + Participant, or (ii) withdraw Your litigation claim with respect to + the Contributor Version against such Participant. If within 60 days + of notice, a reasonable royalty and payment arrangement are not + mutually agreed upon in writing by the parties or the litigation claim + is not withdrawn, the rights granted by Participant to You under + Sections 2.1 and/or 2.2 automatically terminate at the expiration of + the 60 day notice period specified above. + + (b) any software, hardware, or device, other than such Participant's + Contributor Version, directly or indirectly infringes any patent, then + any rights granted to You by such Participant under Sections 2.1(b) + and 2.2(b) are revoked effective as of the date You first made, used, + sold, distributed, or had made, Modifications made by that + Participant. + + 8.3. If You assert a patent infringement claim against Participant + alleging that such Participant's Contributor Version directly or + indirectly infringes any patent where such claim is resolved (such as + by license or settlement) prior to the initiation of patent + infringement litigation, then the reasonable value of the licenses + granted by such Participant under Sections 2.1 or 2.2 shall be taken + into account in determining the amount or value of any payment or + license. + + 8.4. In the event of termination under Sections 8.1 or 8.2 above, + all end user license agreements (excluding distributors and resellers) + which have been validly granted by You or any distributor hereunder + prior to termination shall survive termination. + +9. LIMITATION OF LIABILITY. + + UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT + (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL + DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, + OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR + ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY + CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, + WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER + COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN + INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF + LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY + RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW + PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE + EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO + THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. + +10. U.S. GOVERNMENT END USERS. + + The Covered Code is a "commercial item," as that term is defined in + 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer + software" and "commercial computer software documentation," as such + terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 + C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), + all U.S. Government End Users acquire Covered Code with only those + rights set forth herein. + +11. MISCELLANEOUS. + + This License represents the complete agreement concerning subject + matter hereof. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. This License shall be governed by + California law provisions (except to the extent applicable law, if + any, provides otherwise), excluding its conflict-of-law provisions. + With respect to disputes in which at least one party is a citizen of, + or an entity chartered or registered to do business in the United + States of America, any litigation relating to this License shall be + subject to the jurisdiction of the Federal Courts of the Northern + District of California, with venue lying in Santa Clara County, + California, with the losing party responsible for costs, including + without limitation, court costs and reasonable attorneys' fees and + expenses. The application of the United Nations Convention on + Contracts for the International Sale of Goods is expressly excluded. + Any law or regulation which provides that the language of a contract + shall be construed against the drafter shall not apply to this + License. + +12. RESPONSIBILITY FOR CLAIMS. + + As between Initial Developer and the Contributors, each party is + responsible for claims and damages arising, directly or indirectly, + out of its utilization of rights under this License and You agree to + work with Initial Developer and Contributors to distribute such + responsibility on an equitable basis. Nothing herein is intended or + shall be deemed to constitute any admission of liability. + +13. MULTIPLE-LICENSED CODE. + + Initial Developer may designate portions of the Covered Code as + "Multiple-Licensed". "Multiple-Licensed" means that the Initial + Developer permits you to utilize portions of the Covered Code under + Your choice of the NPL or the alternative licenses, if any, specified + by the Initial Developer in the file described in Exhibit A. + +EXHIBIT A -Mozilla Public License. + + ``The contents of this file are subject to the Mozilla Public License + Version 1.1 (the "License"); you may not use this file except in + compliance with the License. You may obtain a copy of the License at + http://www.mozilla.org/MPL/ + + Software distributed under the License is distributed on an "AS IS" + basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the + License for the specific language governing rights and limitations + under the License. + + The Original Code is ______________________________________. + + The Initial Developer of the Original Code is ________________________. + Portions created by ______________________ are Copyright (C) ______ + _______________________. All Rights Reserved. + + Contributor(s): ______________________________________. + + Alternatively, the contents of this file may be used under the terms + of the _____ license (the "[___] License"), in which case the + provisions of [______] License are applicable instead of those + above. If you wish to allow use of your version of this file only + under the terms of the [____] License and not to allow others to use + your version of this file under the MPL, indicate your decision by + deleting the provisions above and replace them with the notice and + other provisions required by the [___] License. If you do not delete + the provisions above, a recipient may use your version of this file + under either the MPL or the [___] License." + + [NOTE: The text of this Exhibit A may differ slightly from the text of + the notices in the Source Code files of the Original Code. You should + use the text of this Exhibit A rather than the text found in the + Original Code Source Code for Your Modifications.] + diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 169f2d94..2a7af194 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -1,21 +1,39 @@ -/* - * Guacamole - Clientless Remote Desktop - * Copyright (C) 2010 Michael Jumper +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ * - * 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 Affero General Public License for more details. + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ + * The Original Code is libguac-client-vnc. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ #include #include From 48bc7a6596b3266b782a268b355d2a711642758b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 16 Feb 2011 18:37:28 -0800 Subject: [PATCH 14/73] Fixed performance issues with too many updates (nanosleep detection was broken) --- protocols/vnc/configure.in | 1 + protocols/vnc/src/vnc_client.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 35d8c3fa..45a766e4 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -19,6 +19,7 @@ AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio # Checks for library functions. AC_FUNC_MALLOC +AC_CHECK_FUNCS([nanosleep]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 2a7af194..397a42c8 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -219,7 +219,7 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { void vnc_guac_client_sleep(int millis) { -#ifdef nanosleep +#ifdef HAVE_NANOSLEEP struct timespec sleep_period; sleep_period.tv_sec = 0; From 78fa8ebbd766e158e45f1eddd921f376ffad1fca Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 17 Feb 2011 02:18:44 -0800 Subject: [PATCH 15/73] Removed one nanosleep() check - same change made twice --- protocols/vnc/configure.in | 1 - 1 file changed, 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index dd5572d5..45a766e4 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -18,7 +18,6 @@ AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is requir AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio.h guacamole/protocol.h]) # Checks for library functions. -AC_CHECK_FUNCS([nanosleep]) AC_FUNC_MALLOC AC_CHECK_FUNCS([nanosleep]) From f6b137d1b5dd0fc97a3d2eca5098f4cd7c8628d5 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 21 Feb 2011 22:35:18 -0800 Subject: [PATCH 16/73] Migrating to new version number system --- protocols/vnc/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 45a766e4..3b5246d0 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT(src/vnc_client.c) -AM_INIT_AUTOMAKE([libguac-client-vnc], 0.0.1) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.3.0) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. From 2f594d3de71deee5f05747ca7b1a96f2818d10f6 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 28 Feb 2011 14:49:16 -0800 Subject: [PATCH 17/73] Renamed libguac_client_vnc to libguac-client-vnc --- protocols/vnc/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/Makefile.am b/protocols/vnc/Makefile.am index e2a94211..1be36333 100644 --- a/protocols/vnc/Makefile.am +++ b/protocols/vnc/Makefile.am @@ -3,7 +3,7 @@ AUTOMAKE_OPTIONS = gnu ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS = -Werror -Wall -lib_LTLIBRARIES = libguac_client_vnc.la +lib_LTLIBRARIES = libguac-client-vnc.la libguac_client_vnc_la_SOURCES = src/vnc_client.c From 90168a9877f958a71834ff90538af3cd6aef3cf3 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 1 Mar 2011 01:05:09 -0800 Subject: [PATCH 18/73] Added ChangeLog, removed unused files, switched to foreign over GNU --- protocols/vnc/ChangeLog | 4 ++++ protocols/vnc/INSTALL | 0 protocols/vnc/{COPYING => LICENSE} | 0 protocols/vnc/Makefile.am | 2 +- protocols/vnc/NEWS | 0 5 files changed, 5 insertions(+), 1 deletion(-) delete mode 100644 protocols/vnc/INSTALL rename protocols/vnc/{COPYING => LICENSE} (100%) delete mode 100644 protocols/vnc/NEWS diff --git a/protocols/vnc/ChangeLog b/protocols/vnc/ChangeLog index e69de29b..f5e0feca 100644 --- a/protocols/vnc/ChangeLog +++ b/protocols/vnc/ChangeLog @@ -0,0 +1,4 @@ +2011-02-28 Michael Jumper + + * Initial release + diff --git a/protocols/vnc/INSTALL b/protocols/vnc/INSTALL deleted file mode 100644 index e69de29b..00000000 diff --git a/protocols/vnc/COPYING b/protocols/vnc/LICENSE similarity index 100% rename from protocols/vnc/COPYING rename to protocols/vnc/LICENSE diff --git a/protocols/vnc/Makefile.am b/protocols/vnc/Makefile.am index 1be36333..36dd9499 100644 --- a/protocols/vnc/Makefile.am +++ b/protocols/vnc/Makefile.am @@ -1,4 +1,4 @@ -AUTOMAKE_OPTIONS = gnu +AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 AM_CFLAGS = -Werror -Wall diff --git a/protocols/vnc/NEWS b/protocols/vnc/NEWS deleted file mode 100644 index e69de29b..00000000 From 436c4295dcfb639595e1da39e099dc584c5507b9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 2 Mar 2011 01:22:32 -0800 Subject: [PATCH 19/73] Added license block to Makefile.am and configure.in --- protocols/vnc/Makefile.am | 36 ++++++++++++++++++++++++++++++++++++ protocols/vnc/configure.in | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/protocols/vnc/Makefile.am b/protocols/vnc/Makefile.am index 36dd9499..2631c8b2 100644 --- a/protocols/vnc/Makefile.am +++ b/protocols/vnc/Makefile.am @@ -1,3 +1,39 @@ +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is libguac-client-vnc. +# +# The Initial Developer of the Original Code is +# Michael Jumper. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** + AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 3b5246d0..1020406e 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -1,5 +1,38 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. +# ***** BEGIN LICENSE BLOCK ***** +# Version: MPL 1.1/GPL 2.0/LGPL 2.1 +# +# The contents of this file are subject to the Mozilla Public License Version +# 1.1 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS IS" basis, +# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License +# for the specific language governing rights and limitations under the +# License. +# +# The Original Code is libguac-client-vnc. +# +# The Initial Developer of the Original Code is +# Michael Jumper. +# Portions created by the Initial Developer are Copyright (C) 2010 +# the Initial Developer. All Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the terms of +# either the GNU General Public License Version 2 or later (the "GPL"), or +# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), +# in which case the provisions of the GPL or the LGPL are applicable instead +# of those above. If you wish to allow use of your version of this file only +# under the terms of either the GPL or the LGPL, and not to allow others to +# use your version of this file under the terms of the MPL, indicate your +# decision by deleting the provisions above and replace them with the notice +# and other provisions required by the GPL or the LGPL. If you do not delete +# the provisions above, a recipient may use your version of this file under +# the terms of any one of the MPL, the GPL or the LGPL. +# +# ***** END LICENSE BLOCK ***** AC_INIT(src/vnc_client.c) AM_INIT_AUTOMAKE([libguac-client-vnc], 0.3.0) From 34188366a91c0748a22d55ada87fb8c0a030e7ee Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 2 Mar 2011 01:42:18 -0800 Subject: [PATCH 20/73] Added README for libguac-client-vnc --- protocols/vnc/README | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/protocols/vnc/README b/protocols/vnc/README index e69de29b..b716305b 100644 --- a/protocols/vnc/README +++ b/protocols/vnc/README @@ -0,0 +1,75 @@ + +------------------------------------------------------------ + About this README +------------------------------------------------------------ + +This README is intended to provide quick and to-the-point documentation for +technical users intending to compile parts of Guacamole themselves. + +Distribution-specific packages are available from the files section of the main +project page: + + http://sourceforge.net/projects/guacamole/files/ + +Distribution-specific documentation is provided on the Guacamole wiki: + + http://guac-dev.org/ + + +------------------------------------------------------------ + What is libguac-client-vnc? +------------------------------------------------------------ + +libguac-client-vnc is a protocol support plugin for the Guacamole proxy (guacd) +which provides support for VNC via the libvncclient library (part of +libvncserver). + + +------------------------------------------------------------ + Compiling and installing libguac-client-vnc +------------------------------------------------------------ + +Please note that distribution-specific pre-compiled packages are available from +the files section of the main project site: + + http://sourceforge.net/projects/guacamole/files/ + +libguac-client-vnc is built using the popular GNU Automake, and thus provides +the standard configure script. + +1) Run configure + + $ ./configure + + Assuming all dependencies have been installed, this should succeed without + errors. + +2) Run make + + $ make + + libguac-client-vnc will now compile. + +3) Install (as root) + + # make install + + libguac-client-vnc will install to your /usr/local/lib directory by default. + You can change the install location by using the --prefix option for + configure. + + You will need to run ldconfig (as root) so that guacd can find the library + when needed: + + # ldconfig + + +------------------------------------------------------------ + Reporting problems +------------------------------------------------------------ + +Please report any bugs encountered by opening a new ticket at the Trac system +hosted at: + + http://sourceforge.net/apps/trac/guacamole/ + From b46c5187beccb3c23fdb3465863ef8029c2eb6ca Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 5 Mar 2011 14:47:24 -0800 Subject: [PATCH 21/73] Removed delay and check for nanosleep (replaced by ready message in libguac) --- protocols/vnc/configure.in | 1 - protocols/vnc/src/vnc_client.c | 22 ---------------------- 2 files changed, 23 deletions(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 1020406e..dd02b564 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -52,7 +52,6 @@ AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio # Checks for library functions. AC_FUNC_MALLOC -AC_CHECK_FUNCS([nanosleep]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 3ad50459..67229685 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -217,23 +217,6 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { } -void vnc_guac_client_sleep(int millis) { - -#ifdef HAVE_NANOSLEEP - struct timespec sleep_period; - - sleep_period.tv_sec = 0; - sleep_period.tv_nsec = millis * 1000000L; - - nanosleep(&sleep_period, NULL); -#elif defined(__MINGW32__) - Sleep(millis) -#else -#warning No sleep/nanosleep function available. VNC client may not perform as expected. Consider editing the vnc_client.c to add support for your platform. -#endif - -} - int vnc_guac_client_handle_messages(guac_client* client) { int wait_result; @@ -253,11 +236,6 @@ int vnc_guac_client_handle_messages(guac_client* client) { return 1; } - /* Wait before returning ... don't want to handle - * too many server messages. */ - - vnc_guac_client_sleep(50); - } return 0; From 4044b61f56d23e63e2d7f988ba473e5a4cb44c6f Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 6 Mar 2011 17:01:00 -0800 Subject: [PATCH 22/73] Revert "Removed delay and check for nanosleep (replaced by ready message in libguac)" This reverts commit a9ea3ac383de3f92e5b0d29449f1daa618b60624. --- protocols/vnc/configure.in | 1 + protocols/vnc/src/vnc_client.c | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index dd02b564..1020406e 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -52,6 +52,7 @@ AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio # Checks for library functions. AC_FUNC_MALLOC +AC_CHECK_FUNCS([nanosleep]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 67229685..3ad50459 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -217,6 +217,23 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { } +void vnc_guac_client_sleep(int millis) { + +#ifdef HAVE_NANOSLEEP + struct timespec sleep_period; + + sleep_period.tv_sec = 0; + sleep_period.tv_nsec = millis * 1000000L; + + nanosleep(&sleep_period, NULL); +#elif defined(__MINGW32__) + Sleep(millis) +#else +#warning No sleep/nanosleep function available. VNC client may not perform as expected. Consider editing the vnc_client.c to add support for your platform. +#endif + +} + int vnc_guac_client_handle_messages(guac_client* client) { int wait_result; @@ -236,6 +253,11 @@ int vnc_guac_client_handle_messages(guac_client* client) { return 1; } + /* Wait before returning ... don't want to handle + * too many server messages. */ + + vnc_guac_client_sleep(50); + } return 0; From 74150f373edbd650fd81c919c727950995c45cbd Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 13 Mar 2011 14:52:06 -0700 Subject: [PATCH 23/73] Removed sleep - libguac now handles sleeping automatically --- protocols/vnc/configure.in | 1 - protocols/vnc/src/vnc_client.c | 22 ---------------------- 2 files changed, 23 deletions(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 1020406e..dd02b564 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -52,7 +52,6 @@ AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio # Checks for library functions. AC_FUNC_MALLOC -AC_CHECK_FUNCS([nanosleep]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 3ad50459..67229685 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -217,23 +217,6 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { } -void vnc_guac_client_sleep(int millis) { - -#ifdef HAVE_NANOSLEEP - struct timespec sleep_period; - - sleep_period.tv_sec = 0; - sleep_period.tv_nsec = millis * 1000000L; - - nanosleep(&sleep_period, NULL); -#elif defined(__MINGW32__) - Sleep(millis) -#else -#warning No sleep/nanosleep function available. VNC client may not perform as expected. Consider editing the vnc_client.c to add support for your platform. -#endif - -} - int vnc_guac_client_handle_messages(guac_client* client) { int wait_result; @@ -253,11 +236,6 @@ int vnc_guac_client_handle_messages(guac_client* client) { return 1; } - /* Wait before returning ... don't want to handle - * too many server messages. */ - - vnc_guac_client_sleep(50); - } return 0; From 555c7b9a97d04aefec5cf3710b0d89accb52cd37 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 13 Mar 2011 18:34:58 -0700 Subject: [PATCH 24/73] Experimental support for resized framebuffer. --- protocols/vnc/src/vnc_client.c | 43 ++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 67229685..16b40b5f 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -63,8 +63,12 @@ static char* __GUAC_CLIENT = "GUAC_CLIENT"; typedef struct vnc_guac_client_data { rfbClient* rfb_client; + MallocFrameBufferProc rfb_MallocFrameBuffer; + png_byte** png_buffer; png_byte** png_buffer_alpha; + int buffer_height; + int copy_rect_used; char* password; @@ -207,6 +211,27 @@ char* guac_vnc_get_password(rfbClient* client) { return ((vnc_guac_client_data*) gc->data)->password; } +rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { + + guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT); + vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; + + /* Free old buffers */ + guac_free_png_buffer(guac_client_data->png_buffer, guac_client_data->buffer_height); + guac_free_png_buffer(guac_client_data->png_buffer_alpha, guac_client_data->buffer_height); + + /* Allocate new buffers */ + guac_client_data->png_buffer = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 3); /* No-alpha */ + guac_client_data->png_buffer_alpha = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 4); /* With alpha */ + guac_client_data->buffer_height = rfb_client->height; + + /* Send new size */ + guac_send_size(gc->io, rfb_client->width, rfb_client->height); + + /* Use original, wrapped proc */ + return guac_client_data->rfb_MallocFrameBuffer(rfb_client); +} + void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { @@ -272,13 +297,15 @@ int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { int vnc_guac_client_free_handler(guac_client* client) { - rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; - png_byte** png_buffer = ((vnc_guac_client_data*) client->data)->png_buffer; - png_byte** png_buffer_alpha = ((vnc_guac_client_data*) client->data)->png_buffer_alpha; + vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) client->data; + + rfbClient* rfb_client = guac_client_data->rfb_client; + png_byte** png_buffer = guac_client_data->png_buffer; + png_byte** png_buffer_alpha = guac_client_data->png_buffer_alpha; /* Free PNG data */ - guac_free_png_buffer(png_buffer, rfb_client->height); - guac_free_png_buffer(png_buffer_alpha, rfb_client->height); + guac_free_png_buffer(png_buffer, guac_client_data->buffer_height); + guac_free_png_buffer(png_buffer_alpha, guac_client_data->buffer_height); /* Free generic data struct */ free(client->data); @@ -355,6 +382,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Password */ rfb_client->GetPassword = guac_vnc_get_password; + + /* Hook into allocation so we can handle resize. */ + guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer; + rfb_client->MallocFrameBuffer = guac_vnc_malloc_framebuffer; + rfb_client->canHandleNewFBSize = 1; /* Store Guac client in rfb client */ rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client); @@ -378,6 +410,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { guac_client_data->rfb_client = rfb_client; guac_client_data->png_buffer = png_buffer; guac_client_data->png_buffer_alpha = png_buffer_alpha; + guac_client_data->buffer_height = rfb_client->height; guac_client_data->copy_rect_used = 0; /* Set handlers */ From 82fcbe98e5e86a55ec2f0ae18da90da653202dfe Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 13 Mar 2011 18:58:31 -0700 Subject: [PATCH 25/73] Support for encodings as an option. --- protocols/vnc/src/vnc_client.c | 40 ++++++++++++++++------------------ 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 16b40b5f..912e11d3 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -54,6 +54,7 @@ const char* GUAC_CLIENT_ARGS[] = { "hostname", "port", "read-only", + "encodings", "password", NULL }; @@ -71,6 +72,7 @@ typedef struct vnc_guac_client_data { int copy_rect_used; char* password; + char* encodings; } vnc_guac_client_data; @@ -307,6 +309,10 @@ int vnc_guac_client_free_handler(guac_client* client) { guac_free_png_buffer(png_buffer, guac_client_data->buffer_height); guac_free_png_buffer(png_buffer_alpha, guac_client_data->buffer_height); + /* Free encodings string, if used */ + if (guac_client_data->encodings != NULL) + free(guac_client_data->encodings); + /* Free generic data struct */ free(client->data); @@ -330,8 +336,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /*** PARSE ARGUMENTS ***/ - if (argc < 2) { - guac_send_error(client->io, "VNC client requires hostname and port arguments"); + if (argc < 5) { + guac_send_error(client->io, "Wrong argument count received."); guac_flush(client->io); return 1; } @@ -341,26 +347,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) { client->data = guac_client_data; /* If read-only specified, set flag */ - if (argc >= 3) { - if (strcmp(argv[2], "true") == 0) - read_only = 1; - } + if (strcmp(argv[2], "true") == 0) + read_only = 1; - /* Parse password from args if provided */ - if (argc >= 4) { - - /* Freed after use by libvncclient */ - guac_client_data->password = malloc(64); - strncpy(guac_client_data->password, argv[3], 63); - - } - else { - - /* Freed after use by libvncclient */ - guac_client_data->password = malloc(64); - guac_client_data->password[0] = '\0'; - - } + /* Freed after use by libvncclient */ + guac_client_data->password = malloc(64); + strncpy(guac_client_data->password, argv[3], 63); /*** INIT RFB CLIENT ***/ @@ -395,6 +387,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) { rfb_client->serverHost = strdup(argv[0]); rfb_client->serverPort = atoi(argv[1]); + /* Set encodings if specified */ + if (argv[3][0] != '\0') + rfb_client->appData.encodingsString = guac_client_data->encodings = strdup(argv[3]); + else + guac_client_data->encodings = NULL; + /* Connect */ if (!rfbInitClient(rfb_client, NULL, NULL)) { guac_send_error(client->io, "Error initializing VNC client"); From bbc373c1b94227f497cafbd3a54a86386f098e26 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 14 Mar 2011 10:59:47 -0700 Subject: [PATCH 26/73] Fixed lack of initialization of now-used pointers. --- protocols/vnc/src/vnc_client.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 912e11d3..92cb7238 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -219,8 +219,10 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; /* Free old buffers */ - guac_free_png_buffer(guac_client_data->png_buffer, guac_client_data->buffer_height); - guac_free_png_buffer(guac_client_data->png_buffer_alpha, guac_client_data->buffer_height); + if (guac_client_data->png_buffer != NULL) + guac_free_png_buffer(guac_client_data->png_buffer, guac_client_data->buffer_height); + if (guac_client_data->png_buffer_alpha != NULL) + guac_free_png_buffer(guac_client_data->png_buffer_alpha, guac_client_data->buffer_height); /* Allocate new buffers */ guac_client_data->png_buffer = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 3); /* No-alpha */ @@ -351,13 +353,15 @@ int guac_client_init(guac_client* client, int argc, char** argv) { read_only = 1; /* Freed after use by libvncclient */ - guac_client_data->password = malloc(64); - strncpy(guac_client_data->password, argv[3], 63); + guac_client_data->password = strdup(argv[4]); /*** INIT RFB CLIENT ***/ rfb_client = rfbGetClient(8, 3, 4); /* 32-bpp client */ + /* Store Guac client in rfb client */ + rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client); + /* Framebuffer update handler */ rfb_client->GotFrameBufferUpdate = guac_vnc_update; rfb_client->GotCopyRect = guac_vnc_copyrect; @@ -376,13 +380,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) { rfb_client->GetPassword = guac_vnc_get_password; /* Hook into allocation so we can handle resize. */ + guac_client_data->png_buffer = NULL; + guac_client_data->png_buffer_alpha = NULL; guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer; rfb_client->MallocFrameBuffer = guac_vnc_malloc_framebuffer; rfb_client->canHandleNewFBSize = 1; - /* Store Guac client in rfb client */ - rfbClientSetClientData(rfb_client, __GUAC_CLIENT, client); - /* Set hostname and port */ rfb_client->serverHost = strdup(argv[0]); rfb_client->serverPort = atoi(argv[1]); From 7f106c663c9829da7e03c678852e9482b1a7518d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 15 Mar 2011 22:23:21 -0700 Subject: [PATCH 27/73] Updated changelog --- protocols/vnc/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/protocols/vnc/ChangeLog b/protocols/vnc/ChangeLog index f5e0feca..c46a0294 100644 --- a/protocols/vnc/ChangeLog +++ b/protocols/vnc/ChangeLog @@ -1,3 +1,8 @@ +2011-03-13 Michael Jumper + + * Support for framebuffer resizing + * "encodings" argument + 2011-02-28 Michael Jumper * Initial release From df7fa4c88dd12ca692be76dd12c8108bfb1e695d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 17 Mar 2011 14:05:24 -0700 Subject: [PATCH 28/73] Increased wait time for messages (as libguac now uses I/O threads) --- protocols/vnc/src/vnc_client.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 92cb7238..b20c0d67 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -251,8 +251,7 @@ int vnc_guac_client_handle_messages(guac_client* client) { int wait_result; rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; - - wait_result = WaitForMessage(rfb_client, 2000); + wait_result = WaitForMessage(rfb_client, 1000000); if (wait_result < 0) { GUAC_LOG_ERROR("Error waiting for VNC server message\n"); return 1; From adfd2d3089e28f02e87dfcb97decc6902c0808aa Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 19 Mar 2011 01:02:29 -0700 Subject: [PATCH 29/73] Fix memory leak due to extra alloc of png buffers, add workarounds for leaks in libvncclient. --- protocols/vnc/src/vnc_client.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index b20c0d67..fd78cf06 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -134,6 +134,8 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { /* SEND CURSOR */ guac_send_cursor(io, x, y, png_buffer, w, h); + /* libvncclient does not free rcMask as it does rcSource */ + free(client->rcMask); } @@ -317,6 +319,18 @@ int vnc_guac_client_free_handler(guac_client* client) { /* Free generic data struct */ free(client->data); + /* Free memory not free'd by libvncclient's rfbClientCleanup() */ + if (rfb_client->frameBuffer != NULL) free(rfb_client->frameBuffer); + if (rfb_client->raw_buffer != NULL) free(rfb_client->raw_buffer); + if (rfb_client->rcSource != NULL) free(rfb_client->rcSource); + + /* Free VNC rfbClientData linked list (not free'd by rfbClientCleanup()) */ + while (rfb_client->clientData != NULL) { + rfbClientData* next = rfb_client->clientData->next; + free(rfb_client->clientData); + rfb_client->clientData = next; + } + /* Clean up VNC client*/ rfbClientCleanup(rfb_client); @@ -328,9 +342,6 @@ int guac_client_init(guac_client* client, int argc, char** argv) { rfbClient* rfb_client; - png_byte** png_buffer; - png_byte** png_buffer_alpha; - vnc_guac_client_data* guac_client_data; int read_only = 0; @@ -402,19 +413,13 @@ int guac_client_init(guac_client* client, int argc, char** argv) { return 1; } - /* Allocate buffers */ - png_buffer = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 3); /* No-alpha */ - png_buffer_alpha = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 4); /* With alpha */ - /* Set remaining client data */ guac_client_data->rfb_client = rfb_client; - guac_client_data->png_buffer = png_buffer; - guac_client_data->png_buffer_alpha = png_buffer_alpha; - guac_client_data->buffer_height = rfb_client->height; guac_client_data->copy_rect_used = 0; /* Set handlers */ client->handle_messages = vnc_guac_client_handle_messages; + client->free_handler = vnc_guac_client_free_handler; if (read_only == 0) { /* Do not handle mouse/keyboard/clipboard if read-only */ client->mouse_handler = vnc_guac_client_mouse_handler; From 149185f49ea721e239ed9e250de0080c015878be Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 19 Mar 2011 17:13:24 -0700 Subject: [PATCH 30/73] Using new log functions --- protocols/vnc/src/vnc_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index fd78cf06..49de218d 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -255,14 +255,14 @@ int vnc_guac_client_handle_messages(guac_client* client) { wait_result = WaitForMessage(rfb_client, 1000000); if (wait_result < 0) { - GUAC_LOG_ERROR("Error waiting for VNC server message\n"); + guac_log_error("Error waiting for VNC server message\n"); return 1; } if (wait_result > 0) { if (!HandleRFBServerMessage(rfb_client)) { - GUAC_LOG_ERROR("Error handling VNC server message\n"); + guac_log_error("Error handling VNC server message\n"); return 1; } From 8c3fa0c54eda5ced1957b3add5ea4e46907406cd Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 20 Mar 2011 00:22:22 -0700 Subject: [PATCH 31/73] Use guac log functions for VNC log. --- protocols/vnc/src/vnc_client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 49de218d..c5f22fa4 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -346,6 +346,10 @@ int guac_client_init(guac_client* client, int argc, char** argv) { int read_only = 0; + /* Set up libvncclient logging */ + rfbClientLog = guac_log_info; + rfbClientErr = guac_log_error; + /*** PARSE ARGUMENTS ***/ if (argc < 5) { From 56c3b04e9ecd0013287dfa98feb9f34ea76e64d8 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 24 Mar 2011 23:12:43 -0700 Subject: [PATCH 32/73] Added -pedantic --- protocols/vnc/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/Makefile.am b/protocols/vnc/Makefile.am index 2631c8b2..8bdef3e1 100644 --- a/protocols/vnc/Makefile.am +++ b/protocols/vnc/Makefile.am @@ -37,7 +37,7 @@ AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 -AM_CFLAGS = -Werror -Wall +AM_CFLAGS = -Werror -Wall -pedantic lib_LTLIBRARIES = libguac-client-vnc.la From e49798364b9a58447d351971e80a1e96884dc119 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 27 Mar 2011 18:28:10 -0700 Subject: [PATCH 33/73] Switching to cairo, partial translation. --- protocols/vnc/configure.in | 2 +- protocols/vnc/src/vnc_client.c | 86 ++++++++++++++-------------------- 2 files changed, 36 insertions(+), 52 deletions(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index dd02b564..4c99cda6 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -44,7 +44,7 @@ AC_PROG_LIBTOOL # Checks for libraries. AC_CHECK_LIB([guac], [guac_get_client],, AC_MSG_ERROR("libguac is required for communication via the guacamole protocol")) -AC_CHECK_LIB([png], [png_write_png],, AC_MSG_ERROR("libpng is required for writing png messages")) +AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawing instructions")) AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is required")) # Checks for header files. diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index c5f22fa4..5e237bf2 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -38,13 +38,13 @@ #include #include #include -#include #include -#include +#include #include +#include #include #include #include @@ -66,10 +66,6 @@ typedef struct vnc_guac_client_data { rfbClient* rfb_client; MallocFrameBufferProc rfb_MallocFrameBuffer; - png_byte** png_buffer; - png_byte** png_buffer_alpha; - int buffer_height; - int copy_rect_used; char* password; char* encodings; @@ -78,61 +74,69 @@ typedef struct vnc_guac_client_data { void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { - int dx, dy; - guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); GUACIO* io = gc->io; - png_byte** png_buffer = ((vnc_guac_client_data*) gc->data)->png_buffer_alpha; - png_byte* row; - png_byte** png_row_current = png_buffer; + /* Cairo image buffer */ + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); + unsigned char* buffer = malloc(h*stride); + unsigned char* buffer_row_current = buffer; + cairo_surface_t* surface; - unsigned int bytesPerRow = bpp * w; + /* VNC image buffer */ + unsigned int fb_stride = bpp * w; unsigned char* fb_row_current = client->rcSource; unsigned char* fb_mask = client->rcMask; - unsigned char* fb_row; - unsigned int v; - /* Copy image data from VNC client to PNG */ + int dx, dy; + + /* Copy image data from VNC client to RGBA buffer */ for (dy = 0; dy> client->format.redShift) * 256 / (client->format.redMax+1); - *(row++) = (v >> client->format.greenShift) * 256 / (client->format.greenMax+1); - *(row++) = (v >> client->format.blueShift) * 256 / (client->format.blueMax+1); + /* Translate mask to alpha */ + if (*(fb_mask++)) alpha = 0xFF; + else alpha = 0x00; - /* Handle mask */ - if (*(fb_mask++)) - *(row++) = 255; - else - *(row++) = 0; + /* Output ARGB */ + *(buffer_current++) = alpha; + *(buffer_current++) = (v >> client->format.redShift) * 0x100 / (client->format.redMax + 1); + *(buffer_current++) = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); + *(buffer_current++) = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); - fb_row += bpp; + /* Next VNC pixel */ + fb_current += bpp; } } /* SEND CURSOR */ - guac_send_cursor(io, x, y, png_buffer, w, h); + surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, w, h, stride); + guac_send_cursor(io, x, y, surface); /* libvncclient does not free rcMask as it does rcSource */ free(client->rcMask); @@ -220,17 +224,6 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT); vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; - /* Free old buffers */ - if (guac_client_data->png_buffer != NULL) - guac_free_png_buffer(guac_client_data->png_buffer, guac_client_data->buffer_height); - if (guac_client_data->png_buffer_alpha != NULL) - guac_free_png_buffer(guac_client_data->png_buffer_alpha, guac_client_data->buffer_height); - - /* Allocate new buffers */ - guac_client_data->png_buffer = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 3); /* No-alpha */ - guac_client_data->png_buffer_alpha = guac_alloc_png_buffer(rfb_client->width, rfb_client->height, 4); /* With alpha */ - guac_client_data->buffer_height = rfb_client->height; - /* Send new size */ guac_send_size(gc->io, rfb_client->width, rfb_client->height); @@ -303,14 +296,7 @@ int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { int vnc_guac_client_free_handler(guac_client* client) { vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) client->data; - rfbClient* rfb_client = guac_client_data->rfb_client; - png_byte** png_buffer = guac_client_data->png_buffer; - png_byte** png_buffer_alpha = guac_client_data->png_buffer_alpha; - - /* Free PNG data */ - guac_free_png_buffer(png_buffer, guac_client_data->buffer_height); - guac_free_png_buffer(png_buffer_alpha, guac_client_data->buffer_height); /* Free encodings string, if used */ if (guac_client_data->encodings != NULL) @@ -394,8 +380,6 @@ int guac_client_init(guac_client* client, int argc, char** argv) { rfb_client->GetPassword = guac_vnc_get_password; /* Hook into allocation so we can handle resize. */ - guac_client_data->png_buffer = NULL; - guac_client_data->png_buffer_alpha = NULL; guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer; rfb_client->MallocFrameBuffer = guac_vnc_malloc_framebuffer; rfb_client->canHandleNewFBSize = 1; From be731b5900387f545feb198498628a85c17b5780 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 27 Mar 2011 18:40:38 -0700 Subject: [PATCH 34/73] Full conversion of old libpng-based methods. --- protocols/vnc/src/vnc_client.c | 62 +++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 5e237bf2..7be32aa6 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -93,10 +93,15 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { /* Copy image data from VNC client to RGBA buffer */ for (dy = 0; dyrcMask); } @@ -149,15 +158,16 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); GUACIO* io = gc->io; - png_byte** png_buffer = ((vnc_guac_client_data*) gc->data)->png_buffer; - png_byte* row; - png_byte** png_row_current = png_buffer; + /* Cairo image buffer */ + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, w); + unsigned char* buffer = malloc(h*stride); + unsigned char* buffer_row_current = buffer; + cairo_surface_t* surface; unsigned int bpp = client->format.bitsPerPixel/8; - unsigned int bytesPerRow = bpp * client->width; - unsigned char* fb_row_current = client->frameBuffer + (y * bytesPerRow) + (x * bpp); - unsigned char* fb_row; + unsigned int fb_stride = bpp * client->width; + unsigned char* fb_row_current = client->frameBuffer + (y * fb_stride) + (x * bpp); unsigned int v; /* Ignore extra update if already handled by copyrect */ @@ -169,37 +179,51 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* Copy image data from VNC client to PNG */ for (dy = y; dy> client->format.redShift) * 256 / (client->format.redMax+1); - *(row++) = (v >> client->format.greenShift) * 256 / (client->format.greenMax+1); - *(row++) = (v >> client->format.blueShift) * 256 / (client->format.blueMax+1); + /* Output RGB */ - fb_row += bpp; + buffer_current++; /* High 8 bits unused in Cairo's RGB24 */ + *(buffer_current++) = (v >> client->format.redShift) * 0x100 / (client->format.redMax + 1); + *(buffer_current++) = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax + 1); + *(buffer_current++) = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); + + fb_current += bpp; } } /* For now, only use layer 0 */ - guac_send_png(io, 0, x, y, png_buffer, w, h); + surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); + guac_send_png(io, 0, x, y, surface); + + /* Free surface */ + cairo_surface_destroy(surface); + free(buffer); } From 846c42c1cbb5d3608062ce1f4aa065ce09f8ad9c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 27 Mar 2011 18:58:51 -0700 Subject: [PATCH 35/73] Working cairo VNC client. --- protocols/vnc/src/vnc_client.c | 35 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 7be32aa6..404241d2 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -93,11 +93,11 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { /* Copy image data from VNC client to RGBA buffer */ for (dy = 0; dy> client->format.redShift) * 0x100 / (client->format.redMax + 1); + green = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); + blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); + /* Output ARGB */ - *(buffer_current++) = alpha; - *(buffer_current++) = (v >> client->format.redShift) * 0x100 / (client->format.redMax + 1); - *(buffer_current++) = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); - *(buffer_current++) = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); + *(buffer_current++) = (alpha << 24) | (red << 16) | (green << 8) | blue; /* Next VNC pixel */ fb_current += bpp; @@ -168,7 +170,6 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { unsigned int bpp = client->format.bitsPerPixel/8; unsigned int fb_stride = bpp * client->width; unsigned char* fb_row_current = client->frameBuffer + (y * fb_stride) + (x * bpp); - unsigned int v; /* Ignore extra update if already handled by copyrect */ if (((vnc_guac_client_data*) gc->data)->copy_rect_used) { @@ -179,11 +180,11 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* Copy image data from VNC client to PNG */ for (dy = y; dy> client->format.redShift) * 0x100 / (client->format.redMax + 1); + green = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); + blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); - buffer_current++; /* High 8 bits unused in Cairo's RGB24 */ - *(buffer_current++) = (v >> client->format.redShift) * 0x100 / (client->format.redMax + 1); - *(buffer_current++) = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax + 1); - *(buffer_current++) = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); + /* Output RGB */ + *(buffer_current++) = (red << 16) | (green << 8) | blue; fb_current += bpp; From e0e6a5e50ef8c342f5ce759ceb6c63b90745dd5c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 27 Mar 2011 22:48:15 -0700 Subject: [PATCH 36/73] Fixed leak in update handler. --- protocols/vnc/src/vnc_client.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 404241d2..280206ea 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -156,20 +156,21 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { - int dx, dy; - guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); GUACIO* io = gc->io; + int dx, dy; + /* Cairo image buffer */ - int stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, w); - unsigned char* buffer = malloc(h*stride); - unsigned char* buffer_row_current = buffer; + int stride; + unsigned char* buffer; + unsigned char* buffer_row_current; cairo_surface_t* surface; - unsigned int bpp = client->format.bitsPerPixel/8; - unsigned int fb_stride = bpp * client->width; - unsigned char* fb_row_current = client->frameBuffer + (y * fb_stride) + (x * bpp); + /* VNC framebuffer */ + unsigned int bpp; + unsigned int fb_stride; + unsigned char* fb_row_current; /* Ignore extra update if already handled by copyrect */ if (((vnc_guac_client_data*) gc->data)->copy_rect_used) { @@ -177,6 +178,15 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { return; } + /* Init Cairo buffer */ + stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, w); + buffer = malloc(h*stride); + buffer_row_current = buffer; + + bpp = client->format.bitsPerPixel/8; + fb_stride = bpp * client->width; + fb_row_current = client->frameBuffer + (y * fb_stride) + (x * bpp); + /* Copy image data from VNC client to PNG */ for (dy = y; dy Date: Wed, 30 Mar 2011 00:05:28 -0700 Subject: [PATCH 37/73] Added composite mode. --- protocols/vnc/src/vnc_client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 280206ea..4c15ec43 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -234,7 +234,7 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* For now, only use layer 0 */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - guac_send_png(io, 0, x, y, surface); + guac_send_png(io, OVER, 0, x, y, surface); /* Free surface */ cairo_surface_destroy(surface); @@ -248,7 +248,10 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, in GUACIO* io = gc->io; /* For now, only use layer 0 */ - guac_send_copy(io, 0, src_x, src_y, w, h, 0, dest_x, dest_y); + guac_send_copy(io, + 0, src_x, src_y, w, h, + OVER, 0, dest_x, dest_y); + ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; } From e98ee250bd8f83751904598b558fc1b2a8ff0b11 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 21 Apr 2011 16:30:59 -0700 Subject: [PATCH 38/73] Converted to new composite enums --- protocols/vnc/src/vnc_client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 4c15ec43..a96bcf6d 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -234,7 +234,7 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* For now, only use layer 0 */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - guac_send_png(io, OVER, 0, x, y, surface); + guac_send_png(io, GUAC_COMP_OVER, 0, x, y, surface); /* Free surface */ cairo_surface_destroy(surface); @@ -250,7 +250,7 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, in /* For now, only use layer 0 */ guac_send_copy(io, 0, src_x, src_y, w, h, - OVER, 0, dest_x, dest_y); + GUAC_COMP_OVER, 0, dest_x, dest_y); ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; From c4c84a1e44c7fa1321b37bbe1342448bf9ca5c1e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 27 May 2011 13:47:09 -0700 Subject: [PATCH 39/73] Updated version numbers to 0.4.0 --- protocols/vnc/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 4c99cda6..7f1805cb 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -35,7 +35,7 @@ # ***** END LICENSE BLOCK ***** AC_INIT(src/vnc_client.c) -AM_INIT_AUTOMAKE([libguac-client-vnc], 0.3.0) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.4.0) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. From 4dc9e81f93f04a3f6c3503dcc8d2b6095bf81d9e Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 20 Jul 2011 12:37:35 -0700 Subject: [PATCH 40/73] Using new guac_layer instead of integer index. --- protocols/vnc/src/vnc_client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index a96bcf6d..63a5988f 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -232,9 +232,9 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { } } - /* For now, only use layer 0 */ + /* For now, only use default layer */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - guac_send_png(io, GUAC_COMP_OVER, 0, x, y, surface); + guac_send_png(io, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); /* Free surface */ cairo_surface_destroy(surface); @@ -247,10 +247,10 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, in guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); GUACIO* io = gc->io; - /* For now, only use layer 0 */ + /* For now, only use default layer */ guac_send_copy(io, - 0, src_x, src_y, w, h, - GUAC_COMP_OVER, 0, dest_x, dest_y); + GUAC_DEFAULT_LAYER, src_x, src_y, w, h, + GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; From 485616045e843221e8169afdee98a9488d2b46ba Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 10 Aug 2011 15:13:22 -0700 Subject: [PATCH 41/73] Removed unused file. --- protocols/vnc/.package.dsc | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 protocols/vnc/.package.dsc diff --git a/protocols/vnc/.package.dsc b/protocols/vnc/.package.dsc deleted file mode 100644 index c22c1f7c..00000000 --- a/protocols/vnc/.package.dsc +++ /dev/null @@ -1,2 +0,0 @@ -PKGNAME=libguac-client-vnc -VERSION=0.0.1 From 7183b43d1d9322907eb7b459c62c76b98e90f727 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 23 Oct 2011 23:12:00 -0700 Subject: [PATCH 42/73] Migrated to layer instruction queue. --- protocols/vnc/src/vnc_client.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 63a5988f..89557127 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -153,11 +153,15 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { free(client->rcMask); } +const cairo_user_data_key_t __GUAC_VNC_BUFFER; + +void guac_vnc_cairo_free(void* data) { + free(data); +} void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - GUACIO* io = gc->io; int dx, dy; @@ -234,23 +238,21 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* For now, only use default layer */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - guac_send_png(io, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); + guac_layer_png(gc->default_layer, GUAC_COMP_OVER, x, y, surface); - /* Free surface */ - cairo_surface_destroy(surface); - free(buffer); + /* Free buffer when surface is destroyed */ + cairo_surface_set_user_data(surface, &__GUAC_VNC_BUFFER, buffer, guac_vnc_cairo_free); } void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - GUACIO* io = gc->io; /* For now, only use default layer */ - guac_send_copy(io, - GUAC_DEFAULT_LAYER, src_x, src_y, w, h, - GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); + guac_layer_copy(gc->default_layer, GUAC_COMP_OVER, + gc->default_layer, src_x, src_y, w, h, + dest_x, dest_y); ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; @@ -303,6 +305,7 @@ int vnc_guac_client_handle_messages(guac_client* client) { } + guac_layer_flush(client->default_layer, client->io); return 0; } From c07170e05d25c7cad7f569ee1a5a71c056afffc3 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 25 Oct 2011 22:10:48 -0700 Subject: [PATCH 43/73] Migrated to new client-level queue. --- protocols/vnc/src/vnc_client.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 89557127..24401558 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -238,7 +238,7 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* For now, only use default layer */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - guac_layer_png(gc->default_layer, GUAC_COMP_OVER, x, y, surface); + guac_client_queue_png(gc, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); /* Free buffer when surface is destroyed */ cairo_surface_set_user_data(surface, &__GUAC_VNC_BUFFER, buffer, guac_vnc_cairo_free); @@ -250,9 +250,9 @@ void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, in guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); /* For now, only use default layer */ - guac_layer_copy(gc->default_layer, GUAC_COMP_OVER, - gc->default_layer, src_x, src_y, w, h, - dest_x, dest_y); + guac_client_queue_copy(gc, + GUAC_DEFAULT_LAYER, src_x, src_y, w, h, + GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; @@ -305,7 +305,7 @@ int vnc_guac_client_handle_messages(guac_client* client) { } - guac_layer_flush(client->default_layer, client->io); + guac_client_queue_flush(client); return 0; } From b69ab3a27a38cd580bd2e3afb259274fe6e24290 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 4 Nov 2011 11:37:01 -0700 Subject: [PATCH 44/73] Reverted queue migration. --- protocols/vnc/src/vnc_client.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 24401558..63a5988f 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -153,15 +153,11 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { free(client->rcMask); } -const cairo_user_data_key_t __GUAC_VNC_BUFFER; - -void guac_vnc_cairo_free(void* data) { - free(data); -} void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + GUACIO* io = gc->io; int dx, dy; @@ -238,21 +234,23 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* For now, only use default layer */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - guac_client_queue_png(gc, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); + guac_send_png(io, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); - /* Free buffer when surface is destroyed */ - cairo_surface_set_user_data(surface, &__GUAC_VNC_BUFFER, buffer, guac_vnc_cairo_free); + /* Free surface */ + cairo_surface_destroy(surface); + free(buffer); } void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + GUACIO* io = gc->io; /* For now, only use default layer */ - guac_client_queue_copy(gc, - GUAC_DEFAULT_LAYER, src_x, src_y, w, h, - GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); + guac_send_copy(io, + GUAC_DEFAULT_LAYER, src_x, src_y, w, h, + GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; @@ -305,7 +303,6 @@ int vnc_guac_client_handle_messages(guac_client* client) { } - guac_client_queue_flush(client); return 0; } From 9835dde90e74f7f38274108e0e0b6e6dc9f99975 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 25 Nov 2011 16:40:56 -0800 Subject: [PATCH 45/73] Brought up to date with latest libguac changes. --- protocols/vnc/src/vnc_client.c | 43 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/vnc_client.c index 63a5988f..77deb9d3 100644 --- a/protocols/vnc/src/vnc_client.c +++ b/protocols/vnc/src/vnc_client.c @@ -44,8 +44,7 @@ #include -#include -#include +#include #include #include @@ -75,7 +74,7 @@ typedef struct vnc_guac_client_data { void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - GUACIO* io = gc->io; + guac_socket* socket = gc->socket; /* Cairo image buffer */ int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); @@ -143,7 +142,7 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { /* SEND CURSOR */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, w, h, stride); - guac_send_cursor(io, x, y, surface); + guac_protocol_send_cursor(socket, x, y, surface); /* Free surface */ cairo_surface_destroy(surface); @@ -157,7 +156,7 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - GUACIO* io = gc->io; + guac_socket* socket = gc->socket; int dx, dy; @@ -234,7 +233,7 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { /* For now, only use default layer */ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - guac_send_png(io, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); + guac_protocol_send_png(socket, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); /* Free surface */ cairo_surface_destroy(surface); @@ -245,10 +244,10 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - GUACIO* io = gc->io; + guac_socket* socket = gc->socket; /* For now, only use default layer */ - guac_send_copy(io, + guac_protocol_send_copy(socket, GUAC_DEFAULT_LAYER, src_x, src_y, w, h, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); @@ -267,7 +266,7 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; /* Send new size */ - guac_send_size(gc->io, rfb_client->width, rfb_client->height); + guac_protocol_send_size(gc->socket, rfb_client->width, rfb_client->height); /* Use original, wrapped proc */ return guac_client_data->rfb_MallocFrameBuffer(rfb_client); @@ -277,9 +276,9 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - GUACIO* io = gc->io; + guac_socket* socket = gc->socket; - guac_send_clipboard(io, text); + guac_protocol_send_clipboard(socket, text); } @@ -290,14 +289,14 @@ int vnc_guac_client_handle_messages(guac_client* client) { wait_result = WaitForMessage(rfb_client, 1000000); if (wait_result < 0) { - guac_log_error("Error waiting for VNC server message\n"); + guac_client_log_error(client, "Error waiting for VNC server message\n"); return 1; } if (wait_result > 0) { if (!HandleRFBServerMessage(rfb_client)) { - guac_log_error("Error handling VNC server message\n"); + guac_client_log_error(client, "Error handling VNC server message\n"); return 1; } @@ -374,15 +373,15 @@ int guac_client_init(guac_client* client, int argc, char** argv) { int read_only = 0; - /* Set up libvncclient logging */ - rfbClientLog = guac_log_info; - rfbClientErr = guac_log_error; + /* FIXME: Set up libvncclient logging */ + /*rfbClientLog = guac_log_info; + rfbClientErr = guac_log_error;*/ /*** PARSE ARGUMENTS ***/ if (argc < 5) { - guac_send_error(client->io, "Wrong argument count received."); - guac_flush(client->io); + guac_protocol_send_error(client->socket, "Wrong argument count received."); + guac_socket_flush(client->socket); return 1; } @@ -438,8 +437,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Connect */ if (!rfbInitClient(rfb_client, NULL, NULL)) { - guac_send_error(client->io, "Error initializing VNC client"); - guac_flush(client->io); + guac_protocol_send_error(client->socket, "Error initializing VNC client"); + guac_socket_flush(client->socket); return 1; } @@ -458,10 +457,10 @@ int guac_client_init(guac_client* client, int argc, char** argv) { } /* Send name */ - guac_send_name(client->io, rfb_client->desktopName); + guac_protocol_send_name(client->socket, rfb_client->desktopName); /* Send size */ - guac_send_size(client->io, rfb_client->width, rfb_client->height); + guac_protocol_send_size(client->socket, rfb_client->width, rfb_client->height); return 0; From 80df0efa62747ea6f14c6470d042c653ba93e8b3 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 26 Nov 2011 14:57:35 -0800 Subject: [PATCH 46/73] Using new function for libguac check. --- protocols/vnc/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 7f1805cb..0e9f0d48 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -43,7 +43,7 @@ AC_PROG_CC AC_PROG_LIBTOOL # Checks for libraries. -AC_CHECK_LIB([guac], [guac_get_client],, AC_MSG_ERROR("libguac is required for communication via the guacamole protocol")) +AC_CHECK_LIB([guac], [guac_client_plugin_open],, AC_MSG_ERROR("libguac must be installed first")) AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawing instructions")) AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is required")) From 7b9fad668c54f28947395e6f74d97d96299002f1 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 26 Nov 2011 15:00:33 -0800 Subject: [PATCH 47/73] Bumped version to 0.5.0 --- protocols/vnc/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 0e9f0d48..18ac46bd 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -35,7 +35,7 @@ # ***** END LICENSE BLOCK ***** AC_INIT(src/vnc_client.c) -AM_INIT_AUTOMAKE([libguac-client-vnc], 0.4.0) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.5.0) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. From 99103e8eae98b40b476936e0bca4a4ca303203d4 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 11 Dec 2011 14:49:59 -0800 Subject: [PATCH 48/73] Updated README to point to new Trac. --- protocols/vnc/README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/README b/protocols/vnc/README index b716305b..bc664b7d 100644 --- a/protocols/vnc/README +++ b/protocols/vnc/README @@ -71,5 +71,5 @@ the standard configure script. Please report any bugs encountered by opening a new ticket at the Trac system hosted at: - http://sourceforge.net/apps/trac/guacamole/ + http://guac-dev.org/trac/ From 8bf37453de5ff4e01f10d2032b044466ffd118d7 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 11 Dec 2011 15:16:56 -0800 Subject: [PATCH 49/73] Updated changelog. --- protocols/vnc/ChangeLog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/protocols/vnc/ChangeLog b/protocols/vnc/ChangeLog index c46a0294..0066ae93 100644 --- a/protocols/vnc/ChangeLog +++ b/protocols/vnc/ChangeLog @@ -1,3 +1,7 @@ +2011-12-11 Michael Jumper + + * Migrated to 0.5.0 version of libguac API + 2011-03-13 Michael Jumper * Support for framebuffer resizing From bd15a6539819a48b3560626ca305161014636d66 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 21 Dec 2011 18:18:17 -0800 Subject: [PATCH 50/73] Renaming and regrouping. --- protocols/vnc/src/{vnc_client.c => client.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename protocols/vnc/src/{vnc_client.c => client.c} (100%) diff --git a/protocols/vnc/src/vnc_client.c b/protocols/vnc/src/client.c similarity index 100% rename from protocols/vnc/src/vnc_client.c rename to protocols/vnc/src/client.c From a7b00aa79f19c687e404c44214176936c095233b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 21 Dec 2011 18:18:25 -0800 Subject: [PATCH 51/73] Renaming and regrouping. --- protocols/vnc/src/client.c | 245 ++++---------------------- protocols/vnc/src/guac_handlers.c | 152 ++++++++++++++++ protocols/vnc/src/vnc_handlers.c | 283 ++++++++++++++++++++++++++++++ 3 files changed, 466 insertions(+), 214 deletions(-) create mode 100644 protocols/vnc/src/guac_handlers.c create mode 100644 protocols/vnc/src/vnc_handlers.c diff --git a/protocols/vnc/src/client.c b/protocols/vnc/src/client.c index 77deb9d3..bad597b8 100644 --- a/protocols/vnc/src/client.c +++ b/protocols/vnc/src/client.c @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -71,217 +72,6 @@ typedef struct vnc_guac_client_data { } vnc_guac_client_data; -void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { - - guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - guac_socket* socket = gc->socket; - - /* Cairo image buffer */ - int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); - unsigned char* buffer = malloc(h*stride); - unsigned char* buffer_row_current = buffer; - cairo_surface_t* surface; - - /* VNC image buffer */ - unsigned int fb_stride = bpp * w; - unsigned char* fb_row_current = client->rcSource; - unsigned char* fb_mask = client->rcMask; - - int dx, dy; - - /* Copy image data from VNC client to RGBA buffer */ - for (dy = 0; dy> client->format.redShift) * 0x100 / (client->format.redMax + 1); - green = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); - blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); - - /* Output ARGB */ - *(buffer_current++) = (alpha << 24) | (red << 16) | (green << 8) | blue; - - /* Next VNC pixel */ - fb_current += bpp; - - } - } - - /* SEND CURSOR */ - surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, w, h, stride); - guac_protocol_send_cursor(socket, x, y, surface); - - /* Free surface */ - cairo_surface_destroy(surface); - free(buffer); - - /* libvncclient does not free rcMask as it does rcSource */ - free(client->rcMask); -} - - -void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { - - guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - guac_socket* socket = gc->socket; - - int dx, dy; - - /* Cairo image buffer */ - int stride; - unsigned char* buffer; - unsigned char* buffer_row_current; - cairo_surface_t* surface; - - /* VNC framebuffer */ - unsigned int bpp; - unsigned int fb_stride; - unsigned char* fb_row_current; - - /* Ignore extra update if already handled by copyrect */ - if (((vnc_guac_client_data*) gc->data)->copy_rect_used) { - ((vnc_guac_client_data*) gc->data)->copy_rect_used = 0; - return; - } - - /* Init Cairo buffer */ - stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, w); - buffer = malloc(h*stride); - buffer_row_current = buffer; - - bpp = client->format.bitsPerPixel/8; - fb_stride = bpp * client->width; - fb_row_current = client->frameBuffer + (y * fb_stride) + (x * bpp); - - /* Copy image data from VNC client to PNG */ - for (dy = y; dy> client->format.redShift) * 0x100 / (client->format.redMax + 1); - green = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); - blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); - - /* Output RGB */ - *(buffer_current++) = (red << 16) | (green << 8) | blue; - - fb_current += bpp; - - } - } - - /* For now, only use default layer */ - surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); - guac_protocol_send_png(socket, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); - - /* Free surface */ - cairo_surface_destroy(surface); - free(buffer); - -} - -void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) { - - guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - guac_socket* socket = gc->socket; - - /* For now, only use default layer */ - guac_protocol_send_copy(socket, - GUAC_DEFAULT_LAYER, src_x, src_y, w, h, - GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); - - ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; - -} - -char* guac_vnc_get_password(rfbClient* client) { - guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - return ((vnc_guac_client_data*) gc->data)->password; -} - -rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { - - guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT); - vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; - - /* Send new size */ - guac_protocol_send_size(gc->socket, rfb_client->width, rfb_client->height); - - /* Use original, wrapped proc */ - return guac_client_data->rfb_MallocFrameBuffer(rfb_client); -} - - -void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { - - guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); - guac_socket* socket = gc->socket; - - guac_protocol_send_clipboard(socket, text); - -} - int vnc_guac_client_handle_messages(guac_client* client) { int wait_result; @@ -365,6 +155,33 @@ int vnc_guac_client_free_handler(guac_client* client) { } +/* + * Logging, required as libvncclient does not pass the client + * to its logging functions, thus we cannot use guac_client_log*() + */ +void vnc_guac_client_log_info(const char* format, ...) { + + va_list args; + va_start(args, format); + + vsyslog(LOG_INFO, format, args); + + va_end(args); + +} + +void vnc_guac_client_log_error(const char* format, ...) { + + va_list args; + va_start(args, format); + + vsyslog(LOG_ERR, format, args); + + va_end(args); + +} + + int guac_client_init(guac_client* client, int argc, char** argv) { rfbClient* rfb_client; @@ -373,9 +190,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) { int read_only = 0; - /* FIXME: Set up libvncclient logging */ - /*rfbClientLog = guac_log_info; - rfbClientErr = guac_log_error;*/ + /* Set up libvncclient logging */ + rfbClientLog = vnc_guac_client_log_info; + rfbClientErr = vnc_guac_client_log_error; /*** PARSE ARGUMENTS ***/ diff --git a/protocols/vnc/src/guac_handlers.c b/protocols/vnc/src/guac_handlers.c new file mode 100644 index 00000000..7c5f4466 --- /dev/null +++ b/protocols/vnc/src/guac_handlers.c @@ -0,0 +1,152 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-vnc. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +static char* __GUAC_CLIENT = "GUAC_CLIENT"; + +typedef struct vnc_guac_client_data { + + rfbClient* rfb_client; + MallocFrameBufferProc rfb_MallocFrameBuffer; + + int copy_rect_used; + char* password; + char* encodings; + +} vnc_guac_client_data; + +int vnc_guac_client_handle_messages(guac_client* client) { + + int wait_result; + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + + wait_result = WaitForMessage(rfb_client, 1000000); + if (wait_result < 0) { + guac_client_log_error(client, "Error waiting for VNC server message\n"); + return 1; + } + + if (wait_result > 0) { + + if (!HandleRFBServerMessage(rfb_client)) { + guac_client_log_error(client, "Error handling VNC server message\n"); + return 1; + } + + } + + return 0; + +} + + +int vnc_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { + + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + + SendPointerEvent(rfb_client, x, y, mask); + + return 0; +} + +int vnc_guac_client_key_handler(guac_client* client, int keysym, int pressed) { + + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + + SendKeyEvent(rfb_client, keysym, pressed); + + return 0; +} + +int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { + + rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; + + SendClientCutText(rfb_client, data, strlen(data)); + + return 0; +} + +int vnc_guac_client_free_handler(guac_client* client) { + + vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) client->data; + rfbClient* rfb_client = guac_client_data->rfb_client; + + /* Free encodings string, if used */ + if (guac_client_data->encodings != NULL) + free(guac_client_data->encodings); + + /* Free generic data struct */ + free(client->data); + + /* Free memory not free'd by libvncclient's rfbClientCleanup() */ + if (rfb_client->frameBuffer != NULL) free(rfb_client->frameBuffer); + if (rfb_client->raw_buffer != NULL) free(rfb_client->raw_buffer); + if (rfb_client->rcSource != NULL) free(rfb_client->rcSource); + + /* Free VNC rfbClientData linked list (not free'd by rfbClientCleanup()) */ + while (rfb_client->clientData != NULL) { + rfbClientData* next = rfb_client->clientData->next; + free(rfb_client->clientData); + rfb_client->clientData = next; + } + + /* Clean up VNC client*/ + rfbClientCleanup(rfb_client); + + return 0; +} + + +/* + * Logging, required as libvncclient does not pass the client + * to its logging functions, thus we cannot use guac_client_log*() + */ + diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c new file mode 100644 index 00000000..90183603 --- /dev/null +++ b/protocols/vnc/src/vnc_handlers.c @@ -0,0 +1,283 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-vnc. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { + + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + guac_socket* socket = gc->socket; + + /* Cairo image buffer */ + int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); + unsigned char* buffer = malloc(h*stride); + unsigned char* buffer_row_current = buffer; + cairo_surface_t* surface; + + /* VNC image buffer */ + unsigned int fb_stride = bpp * w; + unsigned char* fb_row_current = client->rcSource; + unsigned char* fb_mask = client->rcMask; + + int dx, dy; + + /* Copy image data from VNC client to RGBA buffer */ + for (dy = 0; dy> client->format.redShift) * 0x100 / (client->format.redMax + 1); + green = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); + blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); + + /* Output ARGB */ + *(buffer_current++) = (alpha << 24) | (red << 16) | (green << 8) | blue; + + /* Next VNC pixel */ + fb_current += bpp; + + } + } + + /* SEND CURSOR */ + surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, w, h, stride); + guac_protocol_send_cursor(socket, x, y, surface); + + /* Free surface */ + cairo_surface_destroy(surface); + free(buffer); + + /* libvncclient does not free rcMask as it does rcSource */ + free(client->rcMask); +} + + +void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { + + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + guac_socket* socket = gc->socket; + + int dx, dy; + + /* Cairo image buffer */ + int stride; + unsigned char* buffer; + unsigned char* buffer_row_current; + cairo_surface_t* surface; + + /* VNC framebuffer */ + unsigned int bpp; + unsigned int fb_stride; + unsigned char* fb_row_current; + + /* Ignore extra update if already handled by copyrect */ + if (((vnc_guac_client_data*) gc->data)->copy_rect_used) { + ((vnc_guac_client_data*) gc->data)->copy_rect_used = 0; + return; + } + + /* Init Cairo buffer */ + stride = cairo_format_stride_for_width(CAIRO_FORMAT_RGB24, w); + buffer = malloc(h*stride); + buffer_row_current = buffer; + + bpp = client->format.bitsPerPixel/8; + fb_stride = bpp * client->width; + fb_row_current = client->frameBuffer + (y * fb_stride) + (x * bpp); + + /* Copy image data from VNC client to PNG */ + for (dy = y; dy> client->format.redShift) * 0x100 / (client->format.redMax + 1); + green = (v >> client->format.greenShift) * 0x100 / (client->format.greenMax+ 1); + blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); + + /* Output RGB */ + *(buffer_current++) = (red << 16) | (green << 8) | blue; + + fb_current += bpp; + + } + } + + /* For now, only use default layer */ + surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride); + guac_protocol_send_png(socket, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface); + + /* Free surface */ + cairo_surface_destroy(surface); + free(buffer); + +} + +void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) { + + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + guac_socket* socket = gc->socket; + + /* For now, only use default layer */ + guac_protocol_send_copy(socket, + GUAC_DEFAULT_LAYER, src_x, src_y, w, h, + GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y); + + ((vnc_guac_client_data*) gc->data)->copy_rect_used = 1; + +} + +char* guac_vnc_get_password(rfbClient* client) { + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + return ((vnc_guac_client_data*) gc->data)->password; +} + +rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { + + guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT); + vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; + + /* Send new size */ + guac_protocol_send_size(gc->socket, rfb_client->width, rfb_client->height); + + /* Use original, wrapped proc */ + return guac_client_data->rfb_MallocFrameBuffer(rfb_client); +} + +void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { + + guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + guac_socket* socket = gc->socket; + + guac_protocol_send_clipboard(socket, text); + +} + +void guac_vnc_client_log_info(const char* format, ...) { + + va_list args; + va_start(args, format); + + vsyslog(LOG_INFO, format, args); + + va_end(args); + +} + +void guac_vnc_client_log_error(const char* format, ...) { + + va_list args; + va_start(args, format); + + vsyslog(LOG_ERR, format, args); + + va_end(args); + +} + From cda03dc6db941e873aa04b94d358a04581f133bb Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 21 Dec 2011 18:35:42 -0800 Subject: [PATCH 52/73] Cleaned up hierarchy. --- protocols/vnc/Makefile.am | 6 +- protocols/vnc/configure.in | 2 +- protocols/vnc/include/client.h | 57 +++++++++++ protocols/vnc/include/guac_handlers.h | 60 ++++++++++++ protocols/vnc/include/vnc_handlers.h | 60 ++++++++++++ protocols/vnc/src/client.c | 133 ++------------------------ protocols/vnc/src/guac_handlers.c | 21 +--- protocols/vnc/src/vnc_handlers.c | 2 + 8 files changed, 192 insertions(+), 149 deletions(-) create mode 100644 protocols/vnc/include/client.h create mode 100644 protocols/vnc/include/guac_handlers.h create mode 100644 protocols/vnc/include/vnc_handlers.h diff --git a/protocols/vnc/Makefile.am b/protocols/vnc/Makefile.am index 8bdef3e1..5490eb8c 100644 --- a/protocols/vnc/Makefile.am +++ b/protocols/vnc/Makefile.am @@ -37,11 +37,13 @@ AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 -AM_CFLAGS = -Werror -Wall -pedantic +AM_CFLAGS = -Werror -Wall -pedantic -Iinclude lib_LTLIBRARIES = libguac-client-vnc.la -libguac_client_vnc_la_SOURCES = src/vnc_client.c +libguac_client_vnc_la_SOURCES = src/client.c src/vnc_handlers.c src/guac_handlers.c +noinst_HEADERS = include/client.h include/vnc_handlers.h include/guac_handlers.h + libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 18ac46bd..8cb63fab 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -34,7 +34,7 @@ # # ***** END LICENSE BLOCK ***** -AC_INIT(src/vnc_client.c) +AC_INIT(src/client.c) AM_INIT_AUTOMAKE([libguac-client-vnc], 0.5.0) AC_CONFIG_MACRO_DIR([m4]) diff --git a/protocols/vnc/include/client.h b/protocols/vnc/include/client.h new file mode 100644 index 00000000..1eba8537 --- /dev/null +++ b/protocols/vnc/include/client.h @@ -0,0 +1,57 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-vnc. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __GUAC_VNC_CLIENT_H +#define __GUAC_VNC_CLIENT_H + +#include + +extern char* __GUAC_CLIENT; + +typedef struct vnc_guac_client_data { + + rfbClient* rfb_client; + MallocFrameBufferProc rfb_MallocFrameBuffer; + + int copy_rect_used; + char* password; + char* encodings; + +} vnc_guac_client_data; + +#endif + diff --git a/protocols/vnc/include/guac_handlers.h b/protocols/vnc/include/guac_handlers.h new file mode 100644 index 00000000..90ed4c1c --- /dev/null +++ b/protocols/vnc/include/guac_handlers.h @@ -0,0 +1,60 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-vnc. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __GUAC_VNC_GUAC_HANDLERS_H +#define __GUAC_VNC_GUAC_HANDLERS_H + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +int vnc_guac_client_handle_messages(guac_client* client); +int vnc_guac_client_mouse_handler(guac_client* client, int x, int y, int mask); +int vnc_guac_client_key_handler(guac_client* client, int keysym, int pressed); +int vnc_guac_client_clipboard_handler(guac_client* client, char* data); +int vnc_guac_client_free_handler(guac_client* client); + +#endif + diff --git a/protocols/vnc/include/vnc_handlers.h b/protocols/vnc/include/vnc_handlers.h new file mode 100644 index 00000000..87dd8824 --- /dev/null +++ b/protocols/vnc/include/vnc_handlers.h @@ -0,0 +1,60 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-vnc. + * + * The Initial Developer of the Original Code is + * Michael Jumper. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include +#include + +void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp); +void guac_vnc_update(rfbClient* client, int x, int y, int w, int h); +void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y); +char* guac_vnc_get_password(rfbClient* client); +rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client); +void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen); +void guac_vnc_client_log_info(const char* format, ...); +void guac_vnc_client_log_error(const char* format, ...); + diff --git a/protocols/vnc/src/client.c b/protocols/vnc/src/client.c index bad597b8..9e0755f3 100644 --- a/protocols/vnc/src/client.c +++ b/protocols/vnc/src/client.c @@ -41,14 +41,16 @@ #include #include -#include - #include #include #include #include +#include "client.h" +#include "vnc_handlers.h" +#include "guac_handlers.h" + /* Client plugin arguments */ const char* GUAC_CLIENT_ARGS[] = { "hostname", @@ -59,128 +61,7 @@ const char* GUAC_CLIENT_ARGS[] = { NULL }; -static char* __GUAC_CLIENT = "GUAC_CLIENT"; - -typedef struct vnc_guac_client_data { - - rfbClient* rfb_client; - MallocFrameBufferProc rfb_MallocFrameBuffer; - - int copy_rect_used; - char* password; - char* encodings; - -} vnc_guac_client_data; - -int vnc_guac_client_handle_messages(guac_client* client) { - - int wait_result; - rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; - - wait_result = WaitForMessage(rfb_client, 1000000); - if (wait_result < 0) { - guac_client_log_error(client, "Error waiting for VNC server message\n"); - return 1; - } - - if (wait_result > 0) { - - if (!HandleRFBServerMessage(rfb_client)) { - guac_client_log_error(client, "Error handling VNC server message\n"); - return 1; - } - - } - - return 0; - -} - - -int vnc_guac_client_mouse_handler(guac_client* client, int x, int y, int mask) { - - rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; - - SendPointerEvent(rfb_client, x, y, mask); - - return 0; -} - -int vnc_guac_client_key_handler(guac_client* client, int keysym, int pressed) { - - rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; - - SendKeyEvent(rfb_client, keysym, pressed); - - return 0; -} - -int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { - - rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; - - SendClientCutText(rfb_client, data, strlen(data)); - - return 0; -} - -int vnc_guac_client_free_handler(guac_client* client) { - - vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) client->data; - rfbClient* rfb_client = guac_client_data->rfb_client; - - /* Free encodings string, if used */ - if (guac_client_data->encodings != NULL) - free(guac_client_data->encodings); - - /* Free generic data struct */ - free(client->data); - - /* Free memory not free'd by libvncclient's rfbClientCleanup() */ - if (rfb_client->frameBuffer != NULL) free(rfb_client->frameBuffer); - if (rfb_client->raw_buffer != NULL) free(rfb_client->raw_buffer); - if (rfb_client->rcSource != NULL) free(rfb_client->rcSource); - - /* Free VNC rfbClientData linked list (not free'd by rfbClientCleanup()) */ - while (rfb_client->clientData != NULL) { - rfbClientData* next = rfb_client->clientData->next; - free(rfb_client->clientData); - rfb_client->clientData = next; - } - - /* Clean up VNC client*/ - rfbClientCleanup(rfb_client); - - return 0; -} - - -/* - * Logging, required as libvncclient does not pass the client - * to its logging functions, thus we cannot use guac_client_log*() - */ -void vnc_guac_client_log_info(const char* format, ...) { - - va_list args; - va_start(args, format); - - vsyslog(LOG_INFO, format, args); - - va_end(args); - -} - -void vnc_guac_client_log_error(const char* format, ...) { - - va_list args; - va_start(args, format); - - vsyslog(LOG_ERR, format, args); - - va_end(args); - -} - +char* __GUAC_CLIENT = "GUAC_CLIENT"; int guac_client_init(guac_client* client, int argc, char** argv) { @@ -191,8 +72,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) { int read_only = 0; /* Set up libvncclient logging */ - rfbClientLog = vnc_guac_client_log_info; - rfbClientErr = vnc_guac_client_log_error; + rfbClientLog = guac_vnc_client_log_info; + rfbClientErr = guac_vnc_client_log_error; /*** PARSE ARGUMENTS ***/ diff --git a/protocols/vnc/src/guac_handlers.c b/protocols/vnc/src/guac_handlers.c index 7c5f4466..a7c2704b 100644 --- a/protocols/vnc/src/guac_handlers.c +++ b/protocols/vnc/src/guac_handlers.c @@ -41,26 +41,13 @@ #include #include -#include - #include #include #include #include -static char* __GUAC_CLIENT = "GUAC_CLIENT"; - -typedef struct vnc_guac_client_data { - - rfbClient* rfb_client; - MallocFrameBufferProc rfb_MallocFrameBuffer; - - int copy_rect_used; - char* password; - char* encodings; - -} vnc_guac_client_data; +#include "client.h" int vnc_guac_client_handle_messages(guac_client* client) { @@ -144,9 +131,3 @@ int vnc_guac_client_free_handler(guac_client* client) { return 0; } - -/* - * Logging, required as libvncclient does not pass the client - * to its logging functions, thus we cannot use guac_client_log*() - */ - diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c index 90183603..b40046ed 100644 --- a/protocols/vnc/src/vnc_handlers.c +++ b/protocols/vnc/src/vnc_handlers.c @@ -49,6 +49,8 @@ #include #include +#include "client.h" + void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); From 6741c3c92f4865c8c11a25cafa70e60af5c2fd46 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 21 Dec 2011 18:54:38 -0800 Subject: [PATCH 53/73] Fixed headers, removed unused. --- protocols/vnc/configure.in | 2 +- protocols/vnc/include/guac_handlers.h | 10 ---------- protocols/vnc/include/vnc_handlers.h | 15 ++++----------- protocols/vnc/src/client.c | 3 --- protocols/vnc/src/guac_handlers.c | 4 ---- protocols/vnc/src/vnc_handlers.c | 2 -- 6 files changed, 5 insertions(+), 31 deletions(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 8cb63fab..fbf4509a 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -48,7 +48,7 @@ AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawi AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is required")) # Checks for header files. -AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/guacio.h guacamole/protocol.h]) +AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/socket.h guacamole/protocol.h]) # Checks for library functions. AC_FUNC_MALLOC diff --git a/protocols/vnc/include/guac_handlers.h b/protocols/vnc/include/guac_handlers.h index 90ed4c1c..766d9d64 100644 --- a/protocols/vnc/include/guac_handlers.h +++ b/protocols/vnc/include/guac_handlers.h @@ -38,16 +38,6 @@ #ifndef __GUAC_VNC_GUAC_HANDLERS_H #define __GUAC_VNC_GUAC_HANDLERS_H -#include -#include -#include -#include -#include - -#include - -#include -#include #include int vnc_guac_client_handle_messages(guac_client* client); diff --git a/protocols/vnc/include/vnc_handlers.h b/protocols/vnc/include/vnc_handlers.h index 87dd8824..c325e5ab 100644 --- a/protocols/vnc/include/vnc_handlers.h +++ b/protocols/vnc/include/vnc_handlers.h @@ -35,20 +35,11 @@ * * ***** END LICENSE BLOCK ***** */ -#include -#include -#include -#include -#include - -#include +#ifndef __GUAC_VNC_VNC_HANDLERS_H +#define __GUAC_VNC_VNC_HANDLERS_H #include -#include -#include -#include - void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp); void guac_vnc_update(rfbClient* client, int x, int y, int w, int h); void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y); @@ -58,3 +49,5 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen); void guac_vnc_client_log_info(const char* format, ...); void guac_vnc_client_log_error(const char* format, ...); +#endif + diff --git a/protocols/vnc/src/client.c b/protocols/vnc/src/client.c index 9e0755f3..8ed6a9f0 100644 --- a/protocols/vnc/src/client.c +++ b/protocols/vnc/src/client.c @@ -36,10 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include -#include #include -#include -#include #include diff --git a/protocols/vnc/src/guac_handlers.c b/protocols/vnc/src/guac_handlers.c index a7c2704b..d0b314a7 100644 --- a/protocols/vnc/src/guac_handlers.c +++ b/protocols/vnc/src/guac_handlers.c @@ -36,15 +36,11 @@ * ***** END LICENSE BLOCK ***** */ #include -#include #include #include -#include #include -#include -#include #include #include "client.h" diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c index b40046ed..57ca9c3a 100644 --- a/protocols/vnc/src/vnc_handlers.c +++ b/protocols/vnc/src/vnc_handlers.c @@ -36,8 +36,6 @@ * ***** END LICENSE BLOCK ***** */ #include -#include -#include #include #include From 546e352374e3a1a4526c187126f8a669b1adfc4b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 15 Feb 2012 10:04:51 -0800 Subject: [PATCH 54/73] Refactor supporting buffered cursor instruction. --- protocols/vnc/include/client.h | 2 ++ protocols/vnc/src/client.c | 4 +++- protocols/vnc/src/vnc_handlers.c | 12 +++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/protocols/vnc/include/client.h b/protocols/vnc/include/client.h index 1eba8537..101d4a01 100644 --- a/protocols/vnc/include/client.h +++ b/protocols/vnc/include/client.h @@ -51,6 +51,8 @@ typedef struct vnc_guac_client_data { char* password; char* encodings; + guac_layer* cursor; + } vnc_guac_client_data; #endif diff --git a/protocols/vnc/src/client.c b/protocols/vnc/src/client.c index 8ed6a9f0..e49d1834 100644 --- a/protocols/vnc/src/client.c +++ b/protocols/vnc/src/client.c @@ -140,6 +140,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Set remaining client data */ guac_client_data->rfb_client = rfb_client; guac_client_data->copy_rect_used = 0; + guac_client_data->cursor = guac_client_alloc_buffer(client); /* Set handlers */ client->handle_messages = vnc_guac_client_handle_messages; @@ -155,7 +156,8 @@ int guac_client_init(guac_client* client, int argc, char** argv) { guac_protocol_send_name(client->socket, rfb_client->desktopName); /* Send size */ - guac_protocol_send_size(client->socket, rfb_client->width, rfb_client->height); + guac_protocol_send_size(client->socket, + GUAC_DEFAULT_LAYER, rfb_client->width, rfb_client->height); return 0; diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c index 57ca9c3a..1aba3441 100644 --- a/protocols/vnc/src/vnc_handlers.c +++ b/protocols/vnc/src/vnc_handlers.c @@ -53,6 +53,7 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); guac_socket* socket = gc->socket; + const guac_layer* cursor_layer = ((vnc_guac_client_data*) gc->data)->cursor; /* Cairo image buffer */ int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); @@ -118,9 +119,13 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { } } - /* SEND CURSOR */ + /* Send cursor data*/ surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, w, h, stride); - guac_protocol_send_cursor(socket, x, y, surface); + guac_protocol_send_png(socket, + GUAC_COMP_SRC, cursor_layer, 0, 0, surface); + + /* Update cursor */ + guac_protocol_send_cursor(socket, x, y, cursor_layer, 0, 0, w, h); /* Free surface */ cairo_surface_destroy(surface); @@ -244,7 +249,8 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; /* Send new size */ - guac_protocol_send_size(gc->socket, rfb_client->width, rfb_client->height); + guac_protocol_send_size(gc->socket, + GUAC_DEFAULT_LAYER, rfb_client->width, rfb_client->height); /* Use original, wrapped proc */ return guac_client_data->rfb_MallocFrameBuffer(rfb_client); From 6595c9186463b68078d97692f2a9557a9174538a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 21 Feb 2012 10:15:11 -0800 Subject: [PATCH 55/73] Add arg and flag for swapping red and blue. --- protocols/vnc/include/client.h | 1 + protocols/vnc/src/client.c | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/protocols/vnc/include/client.h b/protocols/vnc/include/client.h index 101d4a01..62c60ee2 100644 --- a/protocols/vnc/include/client.h +++ b/protocols/vnc/include/client.h @@ -50,6 +50,7 @@ typedef struct vnc_guac_client_data { int copy_rect_used; char* password; char* encodings; + int swap_red_blue; guac_layer* cursor; diff --git a/protocols/vnc/src/client.c b/protocols/vnc/src/client.c index e49d1834..8d35e01e 100644 --- a/protocols/vnc/src/client.c +++ b/protocols/vnc/src/client.c @@ -55,6 +55,7 @@ const char* GUAC_CLIENT_ARGS[] = { "read-only", "encodings", "password", + "swap-red-blue", NULL }; @@ -66,7 +67,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { vnc_guac_client_data* guac_client_data; - int read_only = 0; + int read_only; /* Set up libvncclient logging */ rfbClientLog = guac_vnc_client_log_info; @@ -74,7 +75,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /*** PARSE ARGUMENTS ***/ - if (argc < 5) { + if (argc < 6) { guac_protocol_send_error(client->socket, "Wrong argument count received."); guac_socket_flush(client->socket); return 1; @@ -84,9 +85,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) { guac_client_data = malloc(sizeof(vnc_guac_client_data)); client->data = guac_client_data; - /* If read-only specified, set flag */ - if (strcmp(argv[2], "true") == 0) - read_only = 1; + /* Set read-only flag */ + read_only = (strcmp(argv[2], "true") == 0); + + /* Set red/blue swap flag */ + guac_client_data->swap_red_blue = (strcmp(argv[5], "true") == 0); /* Freed after use by libvncclient */ guac_client_data->password = strdup(argv[4]); From 72d7e44420be538f860e4f88d726264a8a1323dc Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 21 Feb 2012 10:22:55 -0800 Subject: [PATCH 56/73] Implement red/blue swap. --- protocols/vnc/src/vnc_handlers.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c index 1aba3441..5cd1d03c 100644 --- a/protocols/vnc/src/vnc_handlers.c +++ b/protocols/vnc/src/vnc_handlers.c @@ -53,7 +53,8 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); guac_socket* socket = gc->socket; - const guac_layer* cursor_layer = ((vnc_guac_client_data*) gc->data)->cursor; + vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; + const guac_layer* cursor_layer = guac_client_data->cursor; /* Cairo image buffer */ int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, w); @@ -111,7 +112,10 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); /* Output ARGB */ - *(buffer_current++) = (alpha << 24) | (red << 16) | (green << 8) | blue; + if (guac_client_data->swap_red_blue) + *(buffer_current++) = (alpha << 24) | (blue << 16) | (green << 8) | red; + else + *(buffer_current++) = (alpha << 24) | (red << 16) | (green << 8) | blue; /* Next VNC pixel */ fb_current += bpp; @@ -139,6 +143,7 @@ void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); + vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data; guac_socket* socket = gc->socket; int dx, dy; @@ -155,8 +160,8 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { unsigned char* fb_row_current; /* Ignore extra update if already handled by copyrect */ - if (((vnc_guac_client_data*) gc->data)->copy_rect_used) { - ((vnc_guac_client_data*) gc->data)->copy_rect_used = 0; + if (guac_client_data->copy_rect_used) { + guac_client_data->copy_rect_used = 0; return; } @@ -207,7 +212,10 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) { blue = (v >> client->format.blueShift) * 0x100 / (client->format.blueMax + 1); /* Output RGB */ - *(buffer_current++) = (red << 16) | (green << 8) | blue; + if (guac_client_data->swap_red_blue) + *(buffer_current++) = (blue << 16) | (green << 8) | red; + else + *(buffer_current++) = (red << 16) | (green << 8) | blue; fb_current += bpp; From 2def99507459c493532109214c7ceddfb3b9da7d Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 23 Feb 2012 14:47:46 -0800 Subject: [PATCH 57/73] LICENSE should be included in source. --- protocols/vnc/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protocols/vnc/Makefile.am b/protocols/vnc/Makefile.am index 5490eb8c..f811c835 100644 --- a/protocols/vnc/Makefile.am +++ b/protocols/vnc/Makefile.am @@ -44,6 +44,7 @@ lib_LTLIBRARIES = libguac-client-vnc.la libguac_client_vnc_la_SOURCES = src/client.c src/vnc_handlers.c src/guac_handlers.c noinst_HEADERS = include/client.h include/vnc_handlers.h include/guac_handlers.h - libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 +EXTRA_DIST = LICENSE + From 80d270ab00808505bfbb8527a616aa9befb0e460 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 23 Feb 2012 14:48:07 -0800 Subject: [PATCH 58/73] Bumped version number to 0.6.0 --- protocols/vnc/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index fbf4509a..cd1df174 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -35,7 +35,7 @@ # ***** END LICENSE BLOCK ***** AC_INIT(src/client.c) -AM_INIT_AUTOMAKE([libguac-client-vnc], 0.5.0) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.6.0) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. From d37484bbfe6eace56e918ac2e929236834fcd710 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 4 May 2012 19:10:14 -0700 Subject: [PATCH 59/73] Updated ChangeLog --- protocols/vnc/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/protocols/vnc/ChangeLog b/protocols/vnc/ChangeLog index 0066ae93..8b7dc59d 100644 --- a/protocols/vnc/ChangeLog +++ b/protocols/vnc/ChangeLog @@ -1,3 +1,9 @@ +2011-05-04 Michael Jumper + + * Migrated to 0.6.0 version of libguac API + * Ensure LICENSE is included in source .tar.gz + * Add swap-red-blue parameter + 2011-12-11 Michael Jumper * Migrated to 0.5.0 version of libguac API From 5ec7f6970d11637106d05f6406bea79d4b30f3e2 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 11 Aug 2012 13:24:06 -0700 Subject: [PATCH 60/73] Ensure m4/ directory exists, while automatically-added files are not included in commits. --- protocols/vnc/.gitignore | 3 ++- protocols/vnc/m4/README | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 protocols/vnc/m4/README diff --git a/protocols/vnc/.gitignore b/protocols/vnc/.gitignore index e37f9166..3f725332 100644 --- a/protocols/vnc/.gitignore +++ b/protocols/vnc/.gitignore @@ -21,7 +21,8 @@ Makefile Makefile.in aclocal.m4 autom4te.cache/ -m4/ +m4/* +!README config.guess config.log config.status diff --git a/protocols/vnc/m4/README b/protocols/vnc/m4/README new file mode 100644 index 00000000..c9c9cbc4 --- /dev/null +++ b/protocols/vnc/m4/README @@ -0,0 +1,12 @@ +This file exists such that the m4/ directory will be created when cloning the +git repository. + +The m4/ directory is not directly used by this project, but libtoolize +populates this directory with files, recommending that the directory be +included in the macro search path for aclocal. + +Because autoreconf runs aclocal before libtoolize, this directory will not +exist when autoreconf is run, triggering an error from aclocal. + +Creating this directory (and keeping this file in it as a placeholder) +prevents this error. From f6764487c898884ccfda708de60616a03dddac51 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 15 Oct 2012 10:29:30 -0700 Subject: [PATCH 61/73] Update ChangeLog, bump version. --- protocols/vnc/ChangeLog | 4 ++++ protocols/vnc/configure.in | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/protocols/vnc/ChangeLog b/protocols/vnc/ChangeLog index 8b7dc59d..66a26d1b 100644 --- a/protocols/vnc/ChangeLog +++ b/protocols/vnc/ChangeLog @@ -1,3 +1,7 @@ +2012-10-15 Michael Jumper + + * Fix m4/ autoreconf error + 2011-05-04 Michael Jumper * Migrated to 0.6.0 version of libguac API diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index cd1df174..69cc9543 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -35,7 +35,7 @@ # ***** END LICENSE BLOCK ***** AC_INIT(src/client.c) -AM_INIT_AUTOMAKE([libguac-client-vnc], 0.6.0) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.6.1) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. From 58a0422008605bb828fb97fdb33d8a49f02fdb0b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 1 Dec 2012 13:04:54 -0800 Subject: [PATCH 62/73] Bump version nuber representing compatibility. --- protocols/vnc/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 69cc9543..6dfd1de4 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -35,7 +35,7 @@ # ***** END LICENSE BLOCK ***** AC_INIT(src/client.c) -AM_INIT_AUTOMAKE([libguac-client-vnc], 0.6.1) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.7.0) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. From 50ed651c1f95b918e23ec900f656ba7475c7b7d4 Mon Sep 17 00:00:00 2001 From: Saul Gio Perez Date: Sat, 9 Feb 2013 16:39:31 -0800 Subject: [PATCH 63/73] Implement #272. --- protocols/vnc/include/vnc_handlers.h | 1 + protocols/vnc/src/client.c | 6 ++++- protocols/vnc/src/vnc_handlers.c | 38 ++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/protocols/vnc/include/vnc_handlers.h b/protocols/vnc/include/vnc_handlers.h index c325e5ab..92730db3 100644 --- a/protocols/vnc/include/vnc_handlers.h +++ b/protocols/vnc/include/vnc_handlers.h @@ -48,6 +48,7 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client); void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen); void guac_vnc_client_log_info(const char* format, ...); void guac_vnc_client_log_error(const char* format, ...); +void guac_vnc_set_pixel_format(rfbClient* client, int color_depth); #endif diff --git a/protocols/vnc/src/client.c b/protocols/vnc/src/client.c index 8d35e01e..eb12ee3d 100644 --- a/protocols/vnc/src/client.c +++ b/protocols/vnc/src/client.c @@ -56,6 +56,7 @@ const char* GUAC_CLIENT_ARGS[] = { "encodings", "password", "swap-red-blue", + "color-depth", NULL }; @@ -75,7 +76,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /*** PARSE ARGUMENTS ***/ - if (argc < 6) { + if (argc < 7) { guac_protocol_send_error(client->socket, "Wrong argument count received."); guac_socket_flush(client->socket); return 1; @@ -117,6 +118,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Password */ rfb_client->GetPassword = guac_vnc_get_password; + + /* Depth */ + guac_vnc_set_pixel_format(rfb_client, atoi(argv[6])); /* Hook into allocation so we can handle resize. */ guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer; diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c index 5cd1d03c..f03e8b0c 100644 --- a/protocols/vnc/src/vnc_handlers.c +++ b/protocols/vnc/src/vnc_handlers.c @@ -251,6 +251,44 @@ char* guac_vnc_get_password(rfbClient* client) { return ((vnc_guac_client_data*) gc->data)->password; } +void guac_vnc_set_pixel_format(rfbClient* client, int color_depth) { + switch(color_depth) { + case 8: + client->format.depth = 8; + client->format.bitsPerPixel = 8; + client->format.blueShift = 6; + client->format.redShift = 0; + client->format.greenShift = 3; + client->format.blueMax = 3; + client->format.redMax = 7; + client->format.greenMax = 7; + break; + + case 16: + client->format.depth = 16; + client->format.bitsPerPixel = 16; + client->format.blueShift = 0; + client->format.redShift = 11; + client->format.greenShift = 5; + client->format.blueMax = 0x1f; + client->format.redMax = 0x1f; + client->format.greenMax = 0x3f; + break; + + case 24: + case 32: + default: + client->format.depth = 24; + client->format.bitsPerPixel = 32; + client->format.blueShift = 0; + client->format.redShift = 16; + client->format.greenShift = 8; + client->format.blueMax = 0xff; + client->format.redMax = 0xff; + client->format.greenMax = 0xff; + } +} + rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT); From 7fbd425610b0f325132470ea842ad8d0bcf2c9a6 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 9 Feb 2013 16:46:29 -0800 Subject: [PATCH 64/73] Fix formatting issues introduced through previous commit (cf630f). --- protocols/vnc/src/client.c | 4 +-- protocols/vnc/src/vnc_handlers.c | 50 ++++++++++++++++---------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/protocols/vnc/src/client.c b/protocols/vnc/src/client.c index eb12ee3d..d2219b9a 100644 --- a/protocols/vnc/src/client.c +++ b/protocols/vnc/src/client.c @@ -119,9 +119,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) { /* Password */ rfb_client->GetPassword = guac_vnc_get_password; - /* Depth */ + /* Depth */ guac_vnc_set_pixel_format(rfb_client, atoi(argv[6])); - + /* Hook into allocation so we can handle resize. */ guac_client_data->rfb_MallocFrameBuffer = rfb_client->MallocFrameBuffer; rfb_client->MallocFrameBuffer = guac_vnc_malloc_framebuffer; diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c index f03e8b0c..11448d41 100644 --- a/protocols/vnc/src/vnc_handlers.c +++ b/protocols/vnc/src/vnc_handlers.c @@ -254,39 +254,39 @@ char* guac_vnc_get_password(rfbClient* client) { void guac_vnc_set_pixel_format(rfbClient* client, int color_depth) { switch(color_depth) { case 8: - client->format.depth = 8; + client->format.depth = 8; client->format.bitsPerPixel = 8; - client->format.blueShift = 6; - client->format.redShift = 0; - client->format.greenShift = 3; - client->format.blueMax = 3; - client->format.redMax = 7; - client->format.greenMax = 7; - break; + client->format.blueShift = 6; + client->format.redShift = 0; + client->format.greenShift = 3; + client->format.blueMax = 3; + client->format.redMax = 7; + client->format.greenMax = 7; + break; case 16: - client->format.depth = 16; + client->format.depth = 16; client->format.bitsPerPixel = 16; - client->format.blueShift = 0; - client->format.redShift = 11; - client->format.greenShift = 5; - client->format.blueMax = 0x1f; - client->format.redMax = 0x1f; - client->format.greenMax = 0x3f; - break; + client->format.blueShift = 0; + client->format.redShift = 11; + client->format.greenShift = 5; + client->format.blueMax = 0x1f; + client->format.redMax = 0x1f; + client->format.greenMax = 0x3f; + break; - case 24: + case 24: case 32: default: - client->format.depth = 24; + client->format.depth = 24; client->format.bitsPerPixel = 32; - client->format.blueShift = 0; - client->format.redShift = 16; - client->format.greenShift = 8; - client->format.blueMax = 0xff; - client->format.redMax = 0xff; - client->format.greenMax = 0xff; - } + client->format.blueShift = 0; + client->format.redShift = 16; + client->format.greenShift = 8; + client->format.blueMax = 0xff; + client->format.redMax = 0xff; + client->format.greenMax = 0xff; + } } rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) { From db4a1ed85e8f96a1259378e3ac1eb4181d745c58 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 9 Feb 2013 17:51:52 -0800 Subject: [PATCH 65/73] Update AUTHORS and ChangeLog. --- protocols/vnc/AUTHORS | 1 + protocols/vnc/ChangeLog | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/protocols/vnc/AUTHORS b/protocols/vnc/AUTHORS index 517d7a79..07486f3f 100644 --- a/protocols/vnc/AUTHORS +++ b/protocols/vnc/AUTHORS @@ -1 +1,2 @@ Michael Jumper +Saul Gio Perez diff --git a/protocols/vnc/ChangeLog b/protocols/vnc/ChangeLog index 66a26d1b..43ad568f 100644 --- a/protocols/vnc/ChangeLog +++ b/protocols/vnc/ChangeLog @@ -1,3 +1,7 @@ +2013-02-07 Saul Gio Perez + + * Implement color-depth parameter (fixes #272) + 2012-10-15 Michael Jumper * Fix m4/ autoreconf error From 808b8ed405fa9c64fb6231c4061349510d3572f9 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 9 Feb 2013 17:55:40 -0800 Subject: [PATCH 66/73] Bump version number. --- protocols/vnc/configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 6dfd1de4..77b12b3b 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -35,7 +35,7 @@ # ***** END LICENSE BLOCK ***** AC_INIT(src/client.c) -AM_INIT_AUTOMAKE([libguac-client-vnc], 0.7.0) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.7.1) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs. From 5a1266abbcbfc77c30956928ac75d690263c52ae Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Fri, 8 Mar 2013 21:47:02 -0800 Subject: [PATCH 67/73] Ticket #255: Now converting ascii->utf8 when recieving clipboard text from vnc, and converting utf8->ascii when sending clipboard text to vnc. This should fix the tunnel disconnecting problem. --- protocols/vnc/Makefile.am | 4 +- protocols/vnc/configure.in | 1 + protocols/vnc/include/convert.h | 46 ++++++++++++ protocols/vnc/src/convert.c | 118 ++++++++++++++++++++++++++++++ protocols/vnc/src/guac_handlers.c | 9 ++- protocols/vnc/src/vnc_handlers.c | 9 ++- 6 files changed, 183 insertions(+), 4 deletions(-) create mode 100644 protocols/vnc/include/convert.h create mode 100644 protocols/vnc/src/convert.c diff --git a/protocols/vnc/Makefile.am b/protocols/vnc/Makefile.am index f811c835..9180cc13 100644 --- a/protocols/vnc/Makefile.am +++ b/protocols/vnc/Makefile.am @@ -41,8 +41,8 @@ AM_CFLAGS = -Werror -Wall -pedantic -Iinclude lib_LTLIBRARIES = libguac-client-vnc.la -libguac_client_vnc_la_SOURCES = src/client.c src/vnc_handlers.c src/guac_handlers.c -noinst_HEADERS = include/client.h include/vnc_handlers.h include/guac_handlers.h +libguac_client_vnc_la_SOURCES = src/client.c src/vnc_handlers.c src/guac_handlers.c src/convert.c +noinst_HEADERS = include/client.h include/vnc_handlers.h include/guac_handlers.h include/convert.h libguac_client_vnc_la_LDFLAGS = -version-info 0:0:0 diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 77b12b3b..c40d5ca4 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -46,6 +46,7 @@ AC_PROG_LIBTOOL AC_CHECK_LIB([guac], [guac_client_plugin_open],, AC_MSG_ERROR("libguac must be installed first")) AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawing instructions")) AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is required")) +#AC_CHECK_LIB([iconv], [iconv],, AC_MSG_ERROR("libiconv is required")) # Checks for header files. AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/socket.h guacamole/protocol.h]) diff --git a/protocols/vnc/include/convert.h b/protocols/vnc/include/convert.h new file mode 100644 index 00000000..5e5b7a71 --- /dev/null +++ b/protocols/vnc/include/convert.h @@ -0,0 +1,46 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-vnc. + * + * The Initial Developer of the Original Code is + * James Muehlner. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef __GUAC_VNC_VNC_CONVERT_H +#define __GUAC_VNC_VNC_CONVERT_H + +#include + +char * convert (const char *from_charset, const char *to_charset, const char *input); + +#endif + diff --git a/protocols/vnc/src/convert.c b/protocols/vnc/src/convert.c new file mode 100644 index 00000000..8220cc3b --- /dev/null +++ b/protocols/vnc/src/convert.c @@ -0,0 +1,118 @@ + +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is libguac-client-vnc. + * + * The Initial Developer of the Original Code is + * James Muehlner. + * Portions created by the Initial Developer are Copyright (C) 2010 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include +#include +#include +#include + +char* convert(const char* from_charset, const char* to_charset, char* input) { + size_t input_remaining; + size_t output_remaining; + size_t bytes_converted = 0; + char* output; + char* output_buffer; + char* new_buffer; + char* input_buffer; + size_t output_length; + iconv_t cd; + + cd = iconv_open(to_charset, from_charset); + + if(cd == (iconv_t) -1) + /* Cannot convert due to invalid character set */ + return NULL; + + input_remaining = strlen(input); + input_buffer = input; + + /* Start the output buffer the same size as the input buffer */ + output_length = input_remaining; + + /* Leave some space at the end for NULL terminator */ + if (!(output = (char*) malloc(output_length + 4))) { + /* Cannot convert due to memory allocation error */ + iconv_close(cd); + return NULL; + } + + do { + output_buffer = output + bytes_converted; + output_remaining = output_length - bytes_converted; + + bytes_converted = iconv(cd, &input_buffer, + &input_remaining, &output_buffer, &output_remaining); + + if(bytes_converted == -1) { + if(errno == E2BIG) { + /* The output buffer is too small, so allocate more space */ + bytes_converted = output_buffer - output; + output_length += input_remaining * 2 + 8; + + if (!(new_buffer = (char*) realloc(output, output_length + 4))) { + /* Cannot convert due to memory allocation error */ + iconv_close(cd); + free(output); + return NULL; + } + + output = new_buffer; + output_buffer = output + bytes_converted; + } + else if (errno == EILSEQ) { + /* Cannot convert because an invalid sequence was discovered */ + iconv_close(cd); + free(output); + return NULL; + } + else if (errno == EINVAL) { + /* Incomplete sequence detected, can be ignored */ + break; + } + } + } while (input_remaining); + + /* Flush the iconv conversion */ + iconv(cd, NULL, NULL, &output_buffer, &output_remaining); + iconv_close(cd); + + /* Add the NULL terminator */ + memset(output_buffer, 0, 4); + + return output; +} + diff --git a/protocols/vnc/src/guac_handlers.c b/protocols/vnc/src/guac_handlers.c index d0b314a7..c456baae 100644 --- a/protocols/vnc/src/guac_handlers.c +++ b/protocols/vnc/src/guac_handlers.c @@ -38,12 +38,14 @@ #include #include #include +#include #include #include #include "client.h" +#include "convert.h" int vnc_guac_client_handle_messages(guac_client* client) { @@ -92,7 +94,12 @@ int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; - SendClientCutText(rfb_client, data, strlen(data)); + /* Convert UTF-8 character data to ISO_8859-1 */ + char* iso_8559_1_data = convert("UTF-8", "ISO_8859-1", data); + + SendClientCutText(rfb_client, iso_8559_1_data, strlen(iso_8559_1_data)); + + free(iso_8559_1_data); return 0; } diff --git a/protocols/vnc/src/vnc_handlers.c b/protocols/vnc/src/vnc_handlers.c index 11448d41..6b593bd1 100644 --- a/protocols/vnc/src/vnc_handlers.c +++ b/protocols/vnc/src/vnc_handlers.c @@ -38,6 +38,7 @@ #include #include #include +#include #include @@ -48,6 +49,7 @@ #include #include "client.h" +#include "convert.h" void guac_vnc_cursor(rfbClient* client, int x, int y, int w, int h, int bpp) { @@ -307,7 +309,12 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) { guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT); guac_socket* socket = gc->socket; - guac_protocol_send_clipboard(socket, text); + /* Convert ASCII character data to UTF-8 */ + char* utf8_text = convert("ISO_8859-1", "UTF-8", text); + + guac_protocol_send_clipboard(socket, utf8_text); + + free(utf8_text); } From 0494fba58fa31994a2a858604086435627e10990 Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Sat, 9 Mar 2013 15:39:15 -0800 Subject: [PATCH 68/73] Ticket #255: Replaced tabs with spaces. --- protocols/vnc/src/convert.c | 82 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/protocols/vnc/src/convert.c b/protocols/vnc/src/convert.c index 8220cc3b..55cd6daa 100644 --- a/protocols/vnc/src/convert.c +++ b/protocols/vnc/src/convert.c @@ -41,78 +41,78 @@ #include char* convert(const char* from_charset, const char* to_charset, char* input) { - size_t input_remaining; + size_t input_remaining; size_t output_remaining; size_t bytes_converted = 0; - char* output; + char* output; char* output_buffer; char* new_buffer; - char* input_buffer; - size_t output_length; - iconv_t cd; + char* input_buffer; + size_t output_length; + iconv_t cd; - cd = iconv_open(to_charset, from_charset); + cd = iconv_open(to_charset, from_charset); if(cd == (iconv_t) -1) /* Cannot convert due to invalid character set */ return NULL; - input_remaining = strlen(input); - input_buffer = input; + input_remaining = strlen(input); + input_buffer = input; - /* Start the output buffer the same size as the input buffer */ - output_length = input_remaining; + /* Start the output buffer the same size as the input buffer */ + output_length = input_remaining; - /* Leave some space at the end for NULL terminator */ - if (!(output = (char*) malloc(output_length + 4))) { + /* Leave some space at the end for NULL terminator */ + if (!(output = (char*) malloc(output_length + 4))) { /* Cannot convert due to memory allocation error */ - iconv_close(cd); - return NULL; - } + iconv_close(cd); + return NULL; + } - do { - output_buffer = output + bytes_converted; - output_remaining = output_length - bytes_converted; + do { + output_buffer = output + bytes_converted; + output_remaining = output_length - bytes_converted; - bytes_converted = iconv(cd, &input_buffer, + bytes_converted = iconv(cd, &input_buffer, &input_remaining, &output_buffer, &output_remaining); if(bytes_converted == -1) { if(errno == E2BIG) { - /* The output buffer is too small, so allocate more space */ - bytes_converted = output_buffer - output; - output_length += input_remaining * 2 + 8; + /* The output buffer is too small, so allocate more space */ + bytes_converted = output_buffer - output; + output_length += input_remaining * 2 + 8; - if (!(new_buffer = (char*) realloc(output, output_length + 4))) { + if (!(new_buffer = (char*) realloc(output, output_length + 4))) { /* Cannot convert due to memory allocation error */ - iconv_close(cd); - free(output); - return NULL; - } + iconv_close(cd); + free(output); + return NULL; + } - output = new_buffer; - output_buffer = output + bytes_converted; + output = new_buffer; + output_buffer = output + bytes_converted; } else if (errno == EILSEQ) { - /* Cannot convert because an invalid sequence was discovered */ - iconv_close(cd); - free(output); - return NULL; - } + /* Cannot convert because an invalid sequence was discovered */ + iconv_close(cd); + free(output); + return NULL; + } else if (errno == EINVAL) { /* Incomplete sequence detected, can be ignored */ break; } } - } while (input_remaining); + } while (input_remaining); - /* Flush the iconv conversion */ - iconv(cd, NULL, NULL, &output_buffer, &output_remaining); - iconv_close(cd); + /* Flush the iconv conversion */ + iconv(cd, NULL, NULL, &output_buffer, &output_remaining); + iconv_close(cd); - /* Add the NULL terminator */ - memset(output_buffer, 0, 4); + /* Add the NULL terminator */ + memset(output_buffer, 0, 4); - return output; + return output; } From b1c13e1fa60092b8154b37def95fa37b160fb99c Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Sat, 9 Mar 2013 15:56:01 -0800 Subject: [PATCH 69/73] Ticket #255: Added comments about the functionality of convert() --- protocols/vnc/include/convert.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/protocols/vnc/include/convert.h b/protocols/vnc/include/convert.h index 5e5b7a71..d6cf1258 100644 --- a/protocols/vnc/include/convert.h +++ b/protocols/vnc/include/convert.h @@ -40,7 +40,14 @@ #include -char * convert (const char *from_charset, const char *to_charset, const char *input); +/** + * Converts a string from one charset to another. Returns a newly allocated string. + * @param from_charset The string representing the character set to convert from. + * @param to_charset The string representing the character set to convert to. + * @return A newly allocated string that is the result of the conversion, or NULL + * if an error has occured. + */ +char* convert (const char* from_charset, const char* to_charset, char* input); #endif From 83d8630f843cf4092d00d2d2d89be8e5c0c04d6c Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Sun, 10 Mar 2013 16:38:56 -0700 Subject: [PATCH 70/73] Ticket #255: Changed input param of convert() to const char*. --- protocols/vnc/include/convert.h | 2 +- protocols/vnc/src/convert.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/protocols/vnc/include/convert.h b/protocols/vnc/include/convert.h index d6cf1258..8b373227 100644 --- a/protocols/vnc/include/convert.h +++ b/protocols/vnc/include/convert.h @@ -47,7 +47,7 @@ * @return A newly allocated string that is the result of the conversion, or NULL * if an error has occured. */ -char* convert (const char* from_charset, const char* to_charset, char* input); +char* convert (const char* from_charset, const char* to_charset, const char* input); #endif diff --git a/protocols/vnc/src/convert.c b/protocols/vnc/src/convert.c index 55cd6daa..7becb34c 100644 --- a/protocols/vnc/src/convert.c +++ b/protocols/vnc/src/convert.c @@ -40,7 +40,7 @@ #include #include -char* convert(const char* from_charset, const char* to_charset, char* input) { +char* convert(const char* from_charset, const char* to_charset, const char* input) { size_t input_remaining; size_t output_remaining; size_t bytes_converted = 0; @@ -58,7 +58,7 @@ char* convert(const char* from_charset, const char* to_charset, char* input) { return NULL; input_remaining = strlen(input); - input_buffer = input; + input_buffer = (char*) input; /* Start the output buffer the same size as the input buffer */ output_length = input_remaining; From fb74c87e2389c8891ff3b2fc6f783f29a09756fa Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Wed, 22 May 2013 21:53:30 -0700 Subject: [PATCH 71/73] Ticket #313: Return whatever is converted so far if EILSEQ detected. Furthermore, if NULL returned from convert(), just send an empty string. Finally, use //TRANSLIT as an option for iconv_open if the library version supports it. --- protocols/vnc/configure.in | 3 +-- protocols/vnc/src/convert.c | 6 ++---- protocols/vnc/src/guac_handlers.c | 14 +++++++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index c40d5ca4..4ec58740 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -46,10 +46,9 @@ AC_PROG_LIBTOOL AC_CHECK_LIB([guac], [guac_client_plugin_open],, AC_MSG_ERROR("libguac must be installed first")) AC_CHECK_LIB([cairo], [cairo_create],, AC_MSG_ERROR("cairo is required for drawing instructions")) AC_CHECK_LIB([vncclient], [rfbInitClient],, AC_MSG_ERROR("libvncclient is required")) -#AC_CHECK_LIB([iconv], [iconv],, AC_MSG_ERROR("libiconv is required")) # Checks for header files. -AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/socket.h guacamole/protocol.h]) +AC_CHECK_HEADERS([stdlib.h string.h syslog.h guacamole/client.h guacamole/socket.h guacamole/protocol.h iconv.h]) # Checks for library functions. AC_FUNC_MALLOC diff --git a/protocols/vnc/src/convert.c b/protocols/vnc/src/convert.c index 7becb34c..8bc9e8d0 100644 --- a/protocols/vnc/src/convert.c +++ b/protocols/vnc/src/convert.c @@ -94,10 +94,8 @@ char* convert(const char* from_charset, const char* to_charset, const char* inpu output_buffer = output + bytes_converted; } else if (errno == EILSEQ) { - /* Cannot convert because an invalid sequence was discovered */ - iconv_close(cd); - free(output); - return NULL; + /* Invalid sequence detected, return what's been converted so far */ + break; } else if (errno == EINVAL) { /* Incomplete sequence detected, can be ignored */ diff --git a/protocols/vnc/src/guac_handlers.c b/protocols/vnc/src/guac_handlers.c index c456baae..67e94b96 100644 --- a/protocols/vnc/src/guac_handlers.c +++ b/protocols/vnc/src/guac_handlers.c @@ -95,11 +95,19 @@ int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client; /* Convert UTF-8 character data to ISO_8859-1 */ + # if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 || _LIBICONV_VERSION >= 0x0105 + char* iso_8559_1_data = convert("UTF-8", "ISO_8859-1//TRANSLIT", data); + #else char* iso_8559_1_data = convert("UTF-8", "ISO_8859-1", data); + #endif - SendClientCutText(rfb_client, iso_8559_1_data, strlen(iso_8559_1_data)); - - free(iso_8559_1_data); + /* If the conversion was successful, send the converted character data. */ + if(iso_8559_1_data) { + SendClientCutText(rfb_client, iso_8559_1_data, strlen(iso_8559_1_data)); + free(iso_8559_1_data); + /* Otherwise, just send an empty string. */ + } else + SendClientCutText(rfb_client, "", 0); return 0; } From 8f1b5ae769847107f8c226f4afdb699a8d240fd1 Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Thu, 23 May 2013 00:02:42 -0700 Subject: [PATCH 72/73] Ticket #313: Fixed styling. --- protocols/vnc/src/guac_handlers.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protocols/vnc/src/guac_handlers.c b/protocols/vnc/src/guac_handlers.c index 67e94b96..f3b2fd49 100644 --- a/protocols/vnc/src/guac_handlers.c +++ b/protocols/vnc/src/guac_handlers.c @@ -106,7 +106,8 @@ int vnc_guac_client_clipboard_handler(guac_client* client, char* data) { SendClientCutText(rfb_client, iso_8559_1_data, strlen(iso_8559_1_data)); free(iso_8559_1_data); /* Otherwise, just send an empty string. */ - } else + } + else SendClientCutText(rfb_client, "", 0); return 0; From fc8eae8d2a283203d7e91ddf64f401a47092253f Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 29 May 2013 11:37:27 -0700 Subject: [PATCH 73/73] Bump version, update ChangeLog and AUTHORS. --- protocols/vnc/AUTHORS | 1 + protocols/vnc/ChangeLog | 4 ++++ protocols/vnc/configure.in | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/protocols/vnc/AUTHORS b/protocols/vnc/AUTHORS index 07486f3f..9a0f2591 100644 --- a/protocols/vnc/AUTHORS +++ b/protocols/vnc/AUTHORS @@ -1,2 +1,3 @@ Michael Jumper +James Muehlner Saul Gio Perez diff --git a/protocols/vnc/ChangeLog b/protocols/vnc/ChangeLog index 43ad568f..920258f1 100644 --- a/protocols/vnc/ChangeLog +++ b/protocols/vnc/ChangeLog @@ -1,3 +1,7 @@ +2013-05-23 James Muehlner + + * convert() should return NULL only on malloc failure (fixes #313) + 2013-02-07 Saul Gio Perez * Implement color-depth parameter (fixes #272) diff --git a/protocols/vnc/configure.in b/protocols/vnc/configure.in index 4ec58740..eb3b005c 100644 --- a/protocols/vnc/configure.in +++ b/protocols/vnc/configure.in @@ -35,7 +35,7 @@ # ***** END LICENSE BLOCK ***** AC_INIT(src/client.c) -AM_INIT_AUTOMAKE([libguac-client-vnc], 0.7.1) +AM_INIT_AUTOMAKE([libguac-client-vnc], 0.7.2) AC_CONFIG_MACRO_DIR([m4]) # Checks for programs.