pax_global_header00006660000000000000000000000064141266450070014517gustar00rootroot0000000000000052 comment=f370b4a2c474c6fe4098d929d8b7c18aeba87b6b purple-xmpp-http-upload-0.2.4/000077500000000000000000000000001412664500700162525ustar00rootroot00000000000000purple-xmpp-http-upload-0.2.4/.gitignore000066400000000000000000000000051412664500700202350ustar00rootroot00000000000000*.so purple-xmpp-http-upload-0.2.4/LICENSE000066400000000000000000001045131412664500700172630ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . purple-xmpp-http-upload-0.2.4/README.md000066400000000000000000000010231412664500700175250ustar00rootroot00000000000000# HTTP File Upload plugin for libpurple (XMPP Protocol) XEP-0363: HTTP File Upload plugin for libpurple (Pidgin, Finch, etc.) ## Installation ### Linux, macOS 1. Install the dependencies (`libxml2-dev`, `libpurple-dev`, `libglib2.0-dev`, `libgio2.0-dev`) 2. `git clone https://github.com/Junker/purple-xmpp-http-upload.git` 3. `cd purple-xmpp-http-upload` 4. `make` 5. A final `make install` should copy the plugin into your libpurple plugin dir. ## Usage click the "Conversation" menu, then "More" and select "HTTP file upload" purple-xmpp-http-upload-0.2.4/headers/000077500000000000000000000000001412664500700176655ustar00rootroot00000000000000purple-xmpp-http-upload-0.2.4/headers/jabber/000077500000000000000000000000001412664500700211125ustar00rootroot00000000000000purple-xmpp-http-upload-0.2.4/headers/jabber/adhoccommands.h000077500000000000000000000032241412664500700240670ustar00rootroot00000000000000/* * purple - Jabber Protocol Plugin * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_ADHOCCOMMANDS_H_ #define PURPLE_JABBER_ADHOCCOMMANDS_H_ #include "jabber.h" /* Implementation of XEP-0050 */ void jabber_adhoc_disco_result_cb(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *packet, gpointer data); void jabber_adhoc_execute(JabberStream *js, JabberAdHocCommands *cmd); void jabber_adhoc_execute_action(PurpleBlistNode *node, gpointer data); void jabber_adhoc_got_list(JabberStream *js, const char *from, xmlnode *query); void jabber_adhoc_server_get_list(JabberStream *js); void jabber_adhoc_init_server_commands(JabberStream *js, GList **m); #endif /* PURPLE_JABBER_ADHOCCOMMANDS_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/auth.h000077500000000000000000000050631412664500700222330ustar00rootroot00000000000000/** * @file auth.h Authentication routines * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_AUTH_H_ #define PURPLE_JABBER_AUTH_H_ typedef struct _JabberSaslMech JabberSaslMech; #include "jabber.h" #include "xmlnode.h" typedef enum { JABBER_SASL_STATE_FAIL = -1, /* Abort, Retry, Fail? */ JABBER_SASL_STATE_OK = 0, /* Hooray! */ JABBER_SASL_STATE_CONTINUE = 1 /* More authentication required */ } JabberSaslState; struct _JabberSaslMech { gint8 priority; /* Higher priority will be tried before lower priority */ const gchar *name; JabberSaslState (*start)(JabberStream *js, xmlnode *mechanisms, xmlnode **reply, char **msg); JabberSaslState (*handle_challenge)(JabberStream *js, xmlnode *packet, xmlnode **reply, char **msg); JabberSaslState (*handle_success)(JabberStream *js, xmlnode *packet, char **msg); JabberSaslState (*handle_failure)(JabberStream *js, xmlnode *packet, xmlnode **reply, char **msg); void (*dispose)(JabberStream *js); }; void jabber_auth_start(JabberStream *js, xmlnode *packet); void jabber_auth_start_old(JabberStream *js); void jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet); void jabber_auth_handle_success(JabberStream *js, xmlnode *packet); void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet); JabberSaslMech *jabber_auth_get_plain_mech(void); JabberSaslMech *jabber_auth_get_digest_md5_mech(void); JabberSaslMech **jabber_auth_get_scram_mechs(gint *count); #ifdef HAVE_CYRUS_SASL JabberSaslMech *jabber_auth_get_cyrus_mech(void); #endif void jabber_auth_add_mech(JabberSaslMech *); void jabber_auth_remove_mech(JabberSaslMech *); void jabber_auth_init(void); void jabber_auth_uninit(void); #endif /* PURPLE_JABBER_AUTH_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/auth_digest_md5.h000077500000000000000000000025631412664500700243410ustar00rootroot00000000000000/** * @file auth_digest_md5.h Implementation of SASL DIGEST-MD5 authentication * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_AUTH_DIGEST_MD5_H_ #define PURPLE_JABBER_AUTH_DIGEST_MD5_H_ #include "internal.h" /* * Every function in this file is ONLY exposed for tests. * DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR. */ /* * Parse a DIGEST-MD5 challenge. */ GHashTable *jabber_auth_digest_md5_parse(const char *challenge); #endif /* PURPLE_JABBER_AUTH_DIGEST_MD5_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/auth_scram.h000077500000000000000000000061001412664500700234110ustar00rootroot00000000000000/** * @file auth_scram.h Implementation of SASL-SCRAM authentication * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_AUTH_SCRAM_H_ #define PURPLE_JABBER_AUTH_SCRAM_H_ /* * Every function in this file is ONLY exposed for tests. * DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR. */ /* Per-connection state stored between messages. * This is stored in js->auth_data_mech. */ typedef struct { const char *mech_substr; const char *name; guint size; } JabberScramHash; typedef struct { const JabberScramHash *hash; char *cnonce; GString *auth_message; GString *client_proof; GString *server_signature; gchar *password; gboolean channel_binding; int step; } JabberScramData; #include "auth.h" /** * Implements the Hi() function as described in the SASL-SCRAM I-D. * * @param hash The struct corresponding to the hash function to be used. * @param str The string to perform the PBKDF2 operation on. * @param salt The salt. * @param iterations The number of iterations to perform. * * @returns A newly allocated string containing the result. The string is * NOT null-terminated and its length is the length of the binary * output of the hash function in-use. */ guchar *jabber_scram_hi(const JabberScramHash *hash, const GString *str, GString *salt, guint iterations); /** * Calculates the proofs as described in Section 3 of the SASL-SCRAM I-D. * * @param data A JabberScramData structure. hash and auth_message must be * set. client_proof and server_signature will be set as a result * of this function. * @param salt The salt (as specified by the server) * @param iterations The number of iterations to perform. * * @returns TRUE if the proofs were successfully calculated. FALSE otherwise. */ gboolean jabber_scram_calc_proofs(JabberScramData *data, GString *salt, guint iterations); /** * Feed the algorithm with the data from the server. */ gboolean jabber_scram_feed_parser(JabberScramData *data, gchar *in, gchar **out); /** * Clean up and destroy the data struct */ void jabber_scram_data_destroy(JabberScramData *data); #endif /* PURPLE_JABBER_AUTH_SCRAM_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/bosh.h000077500000000000000000000033361412664500700222260ustar00rootroot00000000000000/** * @file bosh.h Bidirectional-streams over Synchronous HTTP (BOSH) (XEP-0124 and XEP-0206) * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_BOSH_H_ #define PURPLE_JABBER_BOSH_H_ typedef struct _PurpleBOSHConnection PurpleBOSHConnection; #include "jabber.h" void jabber_bosh_init(void); void jabber_bosh_uninit(void); PurpleBOSHConnection* jabber_bosh_connection_init(JabberStream *js, const char *url); void jabber_bosh_connection_destroy(PurpleBOSHConnection *conn); gboolean jabber_bosh_connection_is_ssl(PurpleBOSHConnection *conn); void jabber_bosh_connection_send_keepalive(PurpleBOSHConnection *conn); void jabber_bosh_connection_connect(PurpleBOSHConnection *conn); void jabber_bosh_connection_close(PurpleBOSHConnection *conn); void jabber_bosh_connection_send_raw(PurpleBOSHConnection *conn, const char *data); #endif /* PURPLE_JABBER_BOSH_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/buddy.h000077500000000000000000000075271412664500700224100ustar00rootroot00000000000000/** * @file buddy.h Buddy handlers * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_BUDDY_H_ #define PURPLE_JABBER_BUDDY_H_ typedef struct _JabberBuddy JabberBuddy; #include "jabber.h" #include "caps.h" #include "jutil.h" struct _JabberBuddy { /** * A sorted list of resources in priority descending order. * This means that the first resource in the list is the * "most available" (see resource_compare_cb in buddy.c for * details). Don't play with this yourself, let * jabber_buddy_track_resource and jabber_buddy_remove_resource do it. */ GList *resources; char *error_msg; enum { JABBER_INVISIBLE_NONE = 0, JABBER_INVISIBLE_SERVER = 1 << 1, JABBER_INVIS_BUDDY = 1 << 2 } invisible; enum { JABBER_SUB_NONE = 0, JABBER_SUB_PENDING = 1 << 1, JABBER_SUB_TO = 1 << 2, JABBER_SUB_FROM = 1 << 3, JABBER_SUB_BOTH = (JABBER_SUB_TO | JABBER_SUB_FROM), JABBER_SUB_REMOVE = 1 << 4 } subscription; }; typedef struct _JabberAdHocCommands { char *jid; char *node; char *name; } JabberAdHocCommands; typedef struct _JabberBuddyResource { JabberBuddy *jb; char *name; int priority; JabberBuddyState state; char *status; time_t idle; JabberCapabilities capabilities; char *thread_id; enum { JABBER_CHAT_STATES_UNKNOWN, JABBER_CHAT_STATES_UNSUPPORTED, JABBER_CHAT_STATES_SUPPORTED } chat_states; struct { char *version; char *name; char *os; } client; /* tz_off == PURPLE_NO_TZ_OFF when unset */ long tz_off; struct { JabberCapsClientInfo *info; GList *exts; } caps; GList *commands; gboolean commands_fetched; } JabberBuddyResource; void jabber_buddy_free(JabberBuddy *jb); JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name, gboolean create); JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb, const char *resource); JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource, int priority, JabberBuddyState state, const char *status); void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource); void jabber_buddy_get_info(PurpleConnection *gc, const char *who); GList *jabber_blist_node_menu(PurpleBlistNode *node); void jabber_set_info(PurpleConnection *gc, const char *info); void jabber_setup_set_info(PurplePluginAction *action); void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img); void jabber_user_search(JabberStream *js, const char *directory); void jabber_user_search_begin(PurplePluginAction *); void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js); void jabber_vcard_fetch_mine(JabberStream *js); gboolean jabber_resource_know_capabilities(const JabberBuddyResource *jbr); gboolean jabber_resource_has_capability(const JabberBuddyResource *jbr, const gchar *cap); gboolean jabber_buddy_has_capability(const JabberBuddy *jb, const gchar *cap); const gchar * jabber_resource_get_identity_category_type(const JabberBuddyResource *jbr, const gchar *category); #endif /* PURPLE_JABBER_BUDDY_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/caps.h000077500000000000000000000102561412664500700222200ustar00rootroot00000000000000/* * purple - Jabber Protocol Plugin * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_CAPS_H_ #define PURPLE_JABBER_CAPS_H_ typedef struct _JabberCapsClientInfo JabberCapsClientInfo; #include "jabber.h" /* Implementation of XEP-0115 - Entity Capabilities */ typedef struct _JabberCapsNodeExts JabberCapsNodeExts; typedef struct _JabberCapsTuple { const char *node; const char *ver; const char *hash; } JabberCapsTuple; struct _JabberCapsClientInfo { GList *identities; /* JabberIdentity */ GList *features; /* char * */ GList *forms; /* xmlnode * */ JabberCapsNodeExts *exts; const JabberCapsTuple tuple; }; /* * This stores a set of exts "known" for a specific node (which indicates * a specific client -- for reference, Pidgin, Finch, Meebo, et al share one * node.) In XEP-0115 v1.3, exts are used for features that may or may not be * present at a given time (PEP things, buzz might be disabled, etc). * * This structure is shared among all JabberCapsClientInfo instances matching * a specific node (if the capstable key->hash == NULL, which indicates that * the ClientInfo is using v1.3 caps as opposed to v1.5 caps). * * It's only exposed so that jabber_resource_has_capability can use it. * Everyone else, STAY AWAY! */ struct _JabberCapsNodeExts { guint ref; GHashTable *exts; /* char *ext_name -> GList *features */ }; typedef void (*jabber_caps_get_info_cb)(JabberCapsClientInfo *info, GList *exts, gpointer user_data); void jabber_caps_init(void); void jabber_caps_uninit(void); /** * Check whether all of the exts in a char* array are known to the given info. */ gboolean jabber_caps_exts_known(const JabberCapsClientInfo *info, char **exts); /** * Main entity capabilites function to get the capabilities of a contact. * * The callback will be called synchronously if we already have the * capabilities for the specified (node,ver,hash) (and, if exts are specified, * if we know what each means) * * @param exts A g_strsplit'd (NULL-terminated) array of strings. This * function is responsible for freeing it. */ void jabber_caps_get_info(JabberStream *js, const char *who, const char *node, const char *ver, const char *hash, char **exts, jabber_caps_get_info_cb cb, gpointer user_data); /** * Takes a JabberCapsClientInfo pointer and returns the caps hash according to * XEP-0115 Version 1.5. * * @param info A JabberCapsClientInfo pointer. * @param hash Hash cipher to be used. Either sha-1 or md5. * @return The base64 encoded SHA-1 hash; must be freed by caller */ gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash); /** * Calculate SHA1 hash for own featureset. */ void jabber_caps_calculate_own_hash(JabberStream *js); /** Get the current caps hash. * @ret hash **/ const gchar* jabber_caps_get_own_hash(JabberStream *js); /** * Broadcast a new calculated hash using a stanza. */ void jabber_caps_broadcast_change(void); /** * Parse the element from an IQ stanza into a JabberCapsClientInfo * struct. * * Exposed for tests * * @param query The 'query' element from an IQ reply stanza. * @returns A JabberCapsClientInfo struct, or NULL on error */ JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query); #endif /* PURPLE_JABBER_CAPS_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/chat.h000077500000000000000000000107141412664500700222100ustar00rootroot00000000000000/** * @file chat.h Chat stuff * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_CHAT_H_ #define PURPLE_JABBER_CHAT_H_ #include "connection.h" #include "conversation.h" #include "request.h" #include "roomlist.h" #include "jabber.h" typedef struct _JabberChatMember { char *handle; char *jid; } JabberChatMember; typedef struct _JabberChat { JabberStream *js; char *room; char *server; char *handle; GHashTable *components; int id; PurpleConversation *conv; gboolean muc; gboolean xhtml; PurpleRequestType config_dialog_type; void *config_dialog_handle; GHashTable *members; gboolean left; time_t joined; } JabberChat; GList *jabber_chat_info(PurpleConnection *gc); GHashTable *jabber_chat_info_defaults(PurpleConnection *gc, const char *chat_name); char *jabber_get_chat_name(GHashTable *data); /** * in-prpl function for joining a chat room. Doesn't require sticking goop * into a hash table. * * @param room The room to join. This MUST be normalized already. * @param server The server the room is on. This MUST be normalized already. * @param password The password (if required) to join the room. May be NULL. * @param data The chat hash table. May be NULL (it will be generated * for current core<>prpl API interface.) */ JabberChat *jabber_join_chat(JabberStream *js, const char *room, const char *server, const char *handle, const char *password, GHashTable *data); void jabber_chat_join(PurpleConnection *gc, GHashTable *data); JabberChat *jabber_chat_find(JabberStream *js, const char *room, const char *server); JabberChat *jabber_chat_find_by_id(JabberStream *js, int id); JabberChat *jabber_chat_find_by_conv(PurpleConversation *conv); void jabber_chat_destroy(JabberChat *chat); void jabber_chat_free(JabberChat *chat); gboolean jabber_chat_find_buddy(PurpleConversation *conv, const char *name); void jabber_chat_invite(PurpleConnection *gc, int id, const char *message, const char *name); void jabber_chat_leave(PurpleConnection *gc, int id); char *jabber_chat_buddy_real_name(PurpleConnection *gc, int id, const char *who); void jabber_chat_request_room_configure(JabberChat *chat); void jabber_chat_create_instant_room(JabberChat *chat); void jabber_chat_register(JabberChat *chat); void jabber_chat_change_topic(JabberChat *chat, const char *topic); void jabber_chat_set_topic(PurpleConnection *gc, int id, const char *topic); gboolean jabber_chat_change_nick(JabberChat *chat, const char *nick); void jabber_chat_part(JabberChat *chat, const char *msg); void jabber_chat_track_handle(JabberChat *chat, const char *handle, const char *jid, const char *affiliation, const char *role); void jabber_chat_remove_handle(JabberChat *chat, const char *handle); gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why); gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation); gboolean jabber_chat_affiliation_list(JabberChat *chat, const char *affiliation); gboolean jabber_chat_role_user(JabberChat *chat, const char *who, const char *role, const char *why); gboolean jabber_chat_role_list(JabberChat *chat, const char *role); PurpleRoomlist *jabber_roomlist_get_list(PurpleConnection *gc); void jabber_roomlist_cancel(PurpleRoomlist *list); void jabber_chat_disco_traffic(JabberChat *chat); char *jabber_roomlist_room_serialize(PurpleRoomlistRoom *room); gboolean jabber_chat_all_participants_have_capability(const JabberChat *chat, const gchar *cap); guint jabber_chat_get_num_participants(const JabberChat *chat); #endif /* PURPLE_JABBER_CHAT_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/data.h000077500000000000000000000061241412664500700222020ustar00rootroot00000000000000/* * purple - Jabber Service Discovery * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_DATA_H #define PURPLE_JABBER_DATA_H #include "xmlnode.h" #include "jabber.h" #include #define JABBER_DATA_MAX_SIZE 8192 typedef struct { char *cid; char *type; gsize size; gpointer data; gboolean ephemeral; } JabberData; typedef void (JabberDataRequestCallback)(JabberData *data, gchar *alt, gpointer userdata); /* creates a JabberData instance from raw data */ JabberData *jabber_data_create_from_data(gconstpointer data, gsize size, const char *type, gboolean ephemeral, JabberStream *js); /* create a JabberData instance from an XML "data" element (as defined by XEP 0231 */ JabberData *jabber_data_create_from_xml(xmlnode *tag); /* destroy a JabberData instance, NOT to be used on data that has been associated, since they get "owned" */ void jabber_data_destroy(JabberData *data); const char *jabber_data_get_cid(const JabberData *data); const char *jabber_data_get_type(const JabberData *data); gsize jabber_data_get_size(const JabberData *data); gpointer jabber_data_get_data(const JabberData *data); /* returns the XML definition for the data element */ xmlnode *jabber_data_get_xml_definition(const JabberData *data); /* returns an XHTML-IM "img" tag given a data instance */ xmlnode *jabber_data_get_xhtml_im(const JabberData *data, const gchar *alt); void jabber_data_request(JabberStream *js, const gchar *cid, const gchar *who, gchar *alt, gboolean ephemeral, JabberDataRequestCallback cb, gpointer userdata); /* lookup functions */ const JabberData *jabber_data_find_local_by_alt(const gchar *alt); const JabberData *jabber_data_find_local_by_cid(const gchar *cid); const JabberData *jabber_data_find_remote_by_cid(JabberStream *js, const gchar *who, const gchar *cid); /* store data objects */ void jabber_data_associate_local(JabberData *data, const gchar *alt); void jabber_data_associate_remote(JabberStream *js, const gchar *who, JabberData *data); /* handles iq requests */ void jabber_data_parse(JabberStream *js, const char *who, JabberIqType type, const char *id, xmlnode *data_node); void jabber_data_init(void); void jabber_data_uninit(void); #endif /* PURPLE_JABBER_DATA_H */ purple-xmpp-http-upload-0.2.4/headers/jabber/disco.h000077500000000000000000000036341412664500700223750ustar00rootroot00000000000000/** * @file disco.h Jabber Service Discovery * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_DISCO_H_ #define PURPLE_JABBER_DISCO_H_ #include "jabber.h" typedef struct _JabberDiscoItem { const char *jid; /* MUST */ const char *node; /* SHOULD */ const char *name; /* MAY */ } JabberDiscoItem; typedef void (JabberDiscoInfoCallback)(JabberStream *js, const char *who, JabberCapabilities capabilities, gpointer data); typedef void (JabberDiscoItemsCallback)(JabberStream *js, const char *jid, const char *node, GSList *items, gpointer data); void jabber_disco_info_parse(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *in_query); void jabber_disco_items_parse(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *query); void jabber_disco_items_server(JabberStream *js); void jabber_disco_info_do(JabberStream *js, const char *who, JabberDiscoInfoCallback *callback, gpointer data); #endif /* PURPLE_JABBER_DISCO_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/facebook_roster.h000077500000000000000000000024141412664500700244360ustar00rootroot00000000000000/** * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_XMPP_FACEBOOK_ROSTER_H_ #define PURPLE_XMPP_FACEBOOK_ROSTER_H_ #include "jabber.h" /* removes deleted buddies from the list */ void jabber_facebook_roster_cleanup(JabberStream *js, xmlnode *query); /* ignores facebook roster quirks */ gboolean jabber_facebook_roster_incoming(JabberStream *js, xmlnode *item); #endif /* PURPLE_XMPP_FACEBOOK_ROSTER_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/ibb.h000077500000000000000000000110411412664500700220170ustar00rootroot00000000000000/* * purple - Jabber Service Discovery * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_IBB_H_ #define PURPLE_JABBER_IBB_H_ #include "jabber.h" #include "iq.h" typedef struct _JabberIBBSession JabberIBBSession; typedef void (JabberIBBDataCallback)(JabberIBBSession *, const gpointer data, gsize size); typedef void (JabberIBBOpenedCallback)(JabberIBBSession *); typedef void (JabberIBBClosedCallback)(JabberIBBSession *); typedef void (JabberIBBErrorCallback)(JabberIBBSession *); typedef void (JabberIBBSentCallback)(JabberIBBSession *); typedef gboolean (JabberIBBOpenHandler)(JabberStream *js, const char *from, const char *id, xmlnode *open); typedef enum { JABBER_IBB_SESSION_NOT_OPENED, JABBER_IBB_SESSION_OPENED, JABBER_IBB_SESSION_CLOSED, JABBER_IBB_SESSION_ERROR } JabberIBBSessionState; struct _JabberIBBSession { JabberStream *js; gchar *who; gchar *sid; gchar *id; guint16 send_seq; guint16 recv_seq; gsize block_size; /* session state */ JabberIBBSessionState state; /* user data (f.ex. a handle to a PurpleXfer) */ gpointer user_data; /* callbacks */ JabberIBBOpenedCallback *opened_cb; JabberIBBSentCallback *data_sent_cb; JabberIBBClosedCallback *closed_cb; /* callback for receiving data */ JabberIBBDataCallback *data_received_cb; JabberIBBErrorCallback *error_cb; /* store the last sent IQ (to permit cancel of callback) */ gchar *last_iq_id; }; JabberIBBSession *jabber_ibb_session_create(JabberStream *js, const gchar *sid, const gchar *who, gpointer user_data); JabberIBBSession *jabber_ibb_session_create_from_xmlnode(JabberStream *js, const gchar *from, const gchar *id, xmlnode *open, gpointer user_data); void jabber_ibb_session_destroy(JabberIBBSession *sess); void jabber_ibb_session_set_opened_callback(JabberIBBSession *sess, JabberIBBOpenedCallback *cb); void jabber_ibb_session_set_data_sent_callback(JabberIBBSession *sess, JabberIBBSentCallback *cb); void jabber_ibb_session_set_closed_callback(JabberIBBSession *sess, JabberIBBClosedCallback *cb); void jabber_ibb_session_set_data_received_callback(JabberIBBSession *sess, JabberIBBDataCallback *cb); void jabber_ibb_session_set_error_callback(JabberIBBSession *sess, JabberIBBErrorCallback *cb); void jabber_ibb_session_open(JabberIBBSession *sess); void jabber_ibb_session_close(JabberIBBSession *sess); void jabber_ibb_session_accept(JabberIBBSession *sess); void jabber_ibb_session_send_data(JabberIBBSession *sess, gconstpointer data, gsize size); const gchar *jabber_ibb_session_get_sid(const JabberIBBSession *sess); JabberStream *jabber_ibb_session_get_js(JabberIBBSession *sess); const gchar *jabber_ibb_session_get_who(const JabberIBBSession *sess); guint16 jabber_ibb_session_get_send_seq(const JabberIBBSession *sess); guint16 jabber_ibb_session_get_recv_seq(const JabberIBBSession *sess); JabberIBBSessionState jabber_ibb_session_get_state(const JabberIBBSession *sess); gsize jabber_ibb_session_get_block_size(const JabberIBBSession *sess); void jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size); /* get maximum size data block to send (in bytes) (before encoded to BASE64) */ gsize jabber_ibb_session_get_max_data_size(const JabberIBBSession *sess); gpointer jabber_ibb_session_get_user_data(JabberIBBSession *sess); /* handle incoming packet */ void jabber_ibb_parse(JabberStream *js, const char *who, JabberIqType type, const char *id, xmlnode *child); /* add a handler for open session */ void jabber_ibb_register_open_handler(JabberIBBOpenHandler *cb); void jabber_ibb_unregister_open_handler(JabberIBBOpenHandler *cb); void jabber_ibb_init(void); void jabber_ibb_uninit(void); #endif /* PURPLE_JABBER_IBB_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/iq.h000077500000000000000000000103341412664500700217000ustar00rootroot00000000000000/** * @file iq.h JabberID handlers * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_IQ_H_ #define PURPLE_JABBER_IQ_H_ typedef enum { JABBER_IQ_SET, JABBER_IQ_GET, JABBER_IQ_RESULT, JABBER_IQ_ERROR, JABBER_IQ_NONE } JabberIqType; #include "jabber.h" #include "connection.h" typedef struct _JabberIq JabberIq; typedef struct _JabberIqCallbackData JabberIqCallbackData; /** * A JabberIqHandler is called to process an incoming IQ stanza. * Handlers typically process unsolicited incoming GETs or SETs for their * registered namespace, but may be called to handle the results of a * GET or SET that we generated if no JabberIqCallback was generated * The handler may be called for the results of a GET or SET (RESULT or ERROR) * that we generated * if the generating function did not register a JabberIqCallback. * * @param js The JabberStream object. * @param from The remote entity (the from attribute on the stanza) * @param type The IQ type. * @param id The IQ id (the id attribute on the stanza) * @param child The child element of the stanza that matches the name * and namespace registered with jabber_iq_register_handler. * * @see jabber_iq_register_handler() * @see JabberIqCallback */ typedef void (JabberIqHandler)(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *child); /** * A JabberIqCallback is called to process the results of a GET or SET that * we send to a remote entity. The callback is matched based on the id * of the incoming stanza (which matches the one on the initial stanza). * * @param js The JabberStream object. * @param from The remote entity (the from attribute on the stanza) * @param type The IQ type. The only possible values are JABBER_IQ_RESULT * and JABBER_IQ_ERROR. * @param id The IQ id (the id attribute on the stanza) * @param packet The stanza * @param data The callback data passed to jabber_iq_set_callback() * * @see jabber_iq_set_callback() */ typedef void (JabberIqCallback)(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *packet, gpointer data); struct _JabberIq { JabberIqType type; char *id; xmlnode *node; JabberIqCallback *callback; gpointer callback_data; JabberStream *js; }; JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type); JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type, const char *xmlns); void jabber_iq_parse(JabberStream *js, xmlnode *packet); void jabber_iq_callbackdata_free(JabberIqCallbackData *jcd); void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id); void jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *cb, gpointer data); void jabber_iq_set_id(JabberIq *iq, const char *id); void jabber_iq_send(JabberIq *iq); void jabber_iq_free(JabberIq *iq); void jabber_iq_init(void); void jabber_iq_uninit(void); void jabber_iq_register_handler(const char *node, const char *xmlns, JabberIqHandler *func); /* Connected to namespace-handler registration signals */ void jabber_iq_signal_register(const gchar *node, const gchar *xmlns); void jabber_iq_signal_unregister(const gchar *node, const gchar *xmlns); #endif /* PURPLE_JABBER_IQ_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/jabber.h000077500000000000000000000311301412664500700225110ustar00rootroot00000000000000/** * @file jabber.h * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_H_ #define PURPLE_JABBER_H_ typedef enum { JABBER_CAP_NONE = 0, /* JABBER_CAP_XHTML = 1 << 0, */ /* JABBER_CAP_COMPOSING = 1 << 1, */ JABBER_CAP_SI = 1 << 2, JABBER_CAP_SI_FILE_XFER = 1 << 3, JABBER_CAP_BYTESTREAMS = 1 << 4, JABBER_CAP_IBB = 1 << 5, JABBER_CAP_CHAT_STATES = 1 << 6, JABBER_CAP_IQ_SEARCH = 1 << 7, JABBER_CAP_IQ_REGISTER = 1 << 8, /* Google Talk extensions: * http://code.google.com/apis/talk/jep_extensions/extensions.html */ JABBER_CAP_GMAIL_NOTIFY = 1 << 9, JABBER_CAP_GOOGLE_ROSTER = 1 << 10, JABBER_CAP_PING = 1 << 11, JABBER_CAP_ADHOC = 1 << 12, JABBER_CAP_BLOCKING = 1 << 13, JABBER_CAP_ITEMS = 1 << 14, JABBER_CAP_ROSTER_VERSIONING = 1 << 15, JABBER_CAP_FACEBOOK = 1 << 16, JABBER_CAP_RETRIEVED = 1 << 31 } JabberCapabilities; typedef struct _JabberStream JabberStream; #include #include #include "circbuffer.h" #include "connection.h" #include "dnsquery.h" #include "dnssrv.h" #include "media.h" #include "mediamanager.h" #include "roomlist.h" #include "sslconn.h" #include "namespaces.h" #include "auth.h" #include "iq.h" #include "jutil.h" #include "xmlnode.h" #include "buddy.h" #include "bosh.h" #ifdef HAVE_CYRUS_SASL #include #endif #define CAPS0115_NODE "http://pidgin.im/" #define JABBER_DEFAULT_REQUIRE_TLS "require_starttls" #define JABBER_DEFAULT_FT_PROXIES "proxy.eu.jabber.org" /* Index into attention_types list */ #define JABBER_BUZZ 0 typedef enum { JABBER_STREAM_OFFLINE, JABBER_STREAM_CONNECTING, JABBER_STREAM_INITIALIZING, JABBER_STREAM_INITIALIZING_ENCRYPTION, JABBER_STREAM_AUTHENTICATING, JABBER_STREAM_POST_AUTH, JABBER_STREAM_CONNECTED } JabberStreamState; struct _JabberStream { int fd; PurpleSrvTxtQueryData *srv_query_data; xmlParserCtxt *context; xmlnode *current; struct { guint8 major; guint8 minor; } protocol_version; JabberSaslMech *auth_mech; gpointer auth_mech_data; /** * The header from the opening tag. This being NULL is treated * as a special condition in the parsing code (signifying the next * stanza started is an opening stream tag), and its being missing on * the stream header is treated as a fatal error. */ char *stream_id; JabberStreamState state; GHashTable *buddies; /* * This boolean was added to eliminate a heinous bug where we would * get into a loop with the server and move a buddy back and forth * from one group to another. * * The sequence goes something like this: * 1. Our resource and another resource both approve an authorization * request at the exact same time. We put the buddy in group A and * the other resource put the buddy in group B. * 2. The server receives the roster add for group B and sends us a * roster push. * 3. We receive this roster push and modify our local blist. This * triggers us to send a roster add for group B. * 4. The server recieves our earlier roster add for group A and sends * us a roster push. * 5. We receive this roster push and modify our local blist. This * triggers us to send a roster add for group A. * 6. The server receives our earlier roster add for group B and sends * us a roster push. * (repeat steps 3 through 6 ad infinitum) * * This boolean is used to short-circuit the sending of a roster add * when we receive a roster push. * * See these bug reports: * http://trac.adiumx.com/ticket/8834 * http://developer.pidgin.im/ticket/5484 * http://developer.pidgin.im/ticket/6188 */ gboolean currently_parsing_roster_push; GHashTable *chats; GList *chat_servers; PurpleRoomlist *roomlist; GList *user_directories; GHashTable *iq_callbacks; int next_id; GList *bs_proxies; GList *oob_file_transfers; GList *file_transfers; time_t idle; time_t old_idle; /** When we last pinged the server, so we don't ping more * often than once every minute. */ time_t last_ping; JabberID *user; JabberBuddy *user_jb; PurpleConnection *gc; PurpleSslConnection *gsc; gboolean registration; char *initial_avatar_hash; char *avatar_hash; GSList *pending_avatar_requests; GSList *pending_buddy_info_requests; PurpleCircBuffer *write_buffer; guint writeh; gboolean reinit; JabberCapabilities server_caps; gboolean googletalk; char *server_name; char *gmail_last_time; char *gmail_last_tid; char *serverFQDN; #ifdef HAVE_CYRUS_SASL sasl_conn_t *sasl; sasl_callback_t *sasl_cb; sasl_secret_t *sasl_secret; const char *current_mech; int auth_fail_count; int sasl_state; int sasl_maxbuf; GString *sasl_mechs; #endif gboolean unregistration; PurpleAccountUnregistrationCb unregistration_cb; void *unregistration_user_data; gboolean vcard_fetched; /* Timer at login to push updated avatar */ guint vcard_timer; /* Entity Capabilities hash */ char *caps_hash; /* does the local server support PEP? */ gboolean pep; /* Is Buzz enabled? */ gboolean allowBuzz; /* A list of JabberAdHocCommands supported by the server */ GList *commands; /* last presence update to check for differences */ JabberBuddyState old_state; char *old_msg; int old_priority; char *old_avatarhash; /* same for user tune */ char *old_artist; char *old_title; char *old_source; char *old_uri; int old_length; char *old_track; char *certificate_CN; /* A purple timeout tag for the keepalive */ guint keepalive_timeout; guint max_inactivity; guint inactivity_timer; PurpleSrvResponse *srv_rec; guint srv_rec_idx; guint max_srv_rec_idx; /* BOSH stuff */ PurpleBOSHConnection *bosh; /** * This linked list contains PurpleUtilFetchUrlData structs * for when we lookup buddy icons from a url */ GSList *url_datas; /* keep a hash table of JingleSessions */ GHashTable *sessions; /* maybe this should only be present when USE_VV? */ gchar *stun_ip; int stun_port; PurpleDnsQueryData *stun_query; /* stuff for Google's relay handling */ gchar *google_relay_token; gchar *google_relay_host; GList *google_relay_requests; /* the HTTP requests to get */ /* relay info */ /* facebook quirks */ gboolean facebook_roster_cleanup_performed; }; typedef gboolean (JabberFeatureEnabled)(JabberStream *js, const gchar *namespace); typedef struct _JabberFeature { gchar *namespace; JabberFeatureEnabled *is_enabled; } JabberFeature; typedef struct _JabberIdentity { gchar *category; gchar *type; gchar *name; gchar *lang; } JabberIdentity; typedef struct _JabberBytestreamsStreamhost { char *jid; char *host; int port; char *zeroconf; } JabberBytestreamsStreamhost; /* what kind of additional features as returned from disco#info are supported? */ extern GList *jabber_features; /* A sorted list of identities advertised. Use jabber_add_identity to add * so it remains sorted. */ extern GList *jabber_identities; void jabber_stream_features_parse(JabberStream *js, xmlnode *packet); void jabber_process_packet(JabberStream *js, xmlnode **packet); void jabber_send(JabberStream *js, xmlnode *data); void jabber_send_raw(JabberStream *js, const char *data, int len); void jabber_send_signal_cb(PurpleConnection *pc, xmlnode **packet, gpointer unused); void jabber_stream_set_state(JabberStream *js, JabberStreamState state); void jabber_register_parse(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *query); void jabber_register_start(JabberStream *js); char *jabber_get_next_id(JabberStream *js); /** Parse an error into a human-readable string and optionally a disconnect * reason. * @param js the stream on which the error occurred. * @param packet the error packet * @param reason where to store the disconnection reason, or @c NULL if you * don't care or you don't intend to close the connection. */ char *jabber_parse_error(JabberStream *js, xmlnode *packet, PurpleConnectionError *reason); /** * Add a feature to the list of features advertised via disco#info. If you * call this while accounts are connected, Bad Things(TM) will happen because * the Entity Caps hash will be out-of-date (which should be fixed :/) * * @param namespace The namespace of the feature * @param cb A callback determining whether or not this feature * will advertised; may be NULL. */ void jabber_add_feature(const gchar *namespace, JabberFeatureEnabled cb); void jabber_remove_feature(const gchar *namespace); /** Adds an identity to this jabber library instance. For list of valid values * visit the website of the XMPP Registrar * (http://www.xmpp.org/registrar/disco-categories.html#client). * * Like with jabber_add_feature, if you call this while accounts are connected, * Bad Things will happen. * * @param category the category of the identity. * @param type the type of the identity. * @param language the language localization of the name. Can be NULL. * @param name the name of the identity. */ void jabber_add_identity(const gchar *category, const gchar *type, const gchar *lang, const gchar *name); /** * GCompareFunc for JabberIdentity structs. */ gint jabber_identity_compare(gconstpointer a, gconstpointer b); /** * Returns true if this connection is over a secure (SSL) stream. Use this * instead of checking js->gsc because BOSH stores its PurpleSslConnection * members in its own data structure. */ gboolean jabber_stream_is_ssl(JabberStream *js); /** * Restart the "we haven't sent anything in a while and should send * something or the server will kick us off" timer (obviously * called when sending something. It's exposed for BOSH.) */ void jabber_stream_restart_inactivity_timer(JabberStream *js); /** PRPL functions */ const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b); const char* jabber_list_emblem(PurpleBuddy *b); char *jabber_status_text(PurpleBuddy *b); void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full); GList *jabber_status_types(PurpleAccount *account); void jabber_login(PurpleAccount *account); void jabber_close(PurpleConnection *gc); void jabber_idle_set(PurpleConnection *gc, int idle); void jabber_blocklist_parse_push(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *child); void jabber_request_block_list(JabberStream *js); void jabber_add_deny(PurpleConnection *gc, const char *who); void jabber_rem_deny(PurpleConnection *gc, const char *who); void jabber_keepalive(PurpleConnection *gc); void jabber_register_gateway(JabberStream *js, const char *gateway); void jabber_register_account(PurpleAccount *account); void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data); gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code); GList *jabber_attention_types(PurpleAccount *account); void jabber_convo_closed(PurpleConnection *gc, const char *who); PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name); gboolean jabber_offline_message(const PurpleBuddy *buddy); int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len); GList *jabber_actions(PurplePlugin *plugin, gpointer context); gboolean jabber_audio_enabled(JabberStream *js, const char *unused); gboolean jabber_video_enabled(JabberStream *js, const char *unused); gboolean jabber_initiate_media(PurpleAccount *account, const char *who, PurpleMediaSessionType type); PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, const char *who); gboolean jabber_can_receive_file(PurpleConnection *gc, const gchar *who); void jabber_plugin_init(PurplePlugin *plugin); void jabber_plugin_uninit(PurplePlugin *plugin); #endif /* PURPLE_JABBER_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/jutil.h000077500000000000000000000065411412664500700224230ustar00rootroot00000000000000/** * @file jutil.h utility functions * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_JUTIL_H_ #define PURPLE_JABBER_JUTIL_H_ typedef struct _JabberID { char *node; char *domain; char *resource; } JabberID; typedef enum { JABBER_BUDDY_STATE_UNKNOWN = -2, JABBER_BUDDY_STATE_ERROR = -1, JABBER_BUDDY_STATE_UNAVAILABLE = 0, JABBER_BUDDY_STATE_ONLINE, JABBER_BUDDY_STATE_CHAT, JABBER_BUDDY_STATE_AWAY, JABBER_BUDDY_STATE_XA, JABBER_BUDDY_STATE_DND } JabberBuddyState; #include "jabber.h" JabberID* jabber_id_new(const char *str); /** * Compare two JIDs for equality. In addition to the node and domain, * the resources of the two JIDs must also be equal (or both absent). */ gboolean jabber_id_equal(const JabberID *jid1, const JabberID *jid2); void jabber_id_free(JabberID *jid); char *jabber_get_domain(const char *jid); char *jabber_get_resource(const char *jid); char *jabber_get_bare_jid(const char *jid); char *jabber_id_get_bare_jid(const JabberID *jid); char *jabber_id_get_full_jid(const JabberID *jid); JabberID *jabber_id_to_bare_jid(const JabberID *jid); gboolean jabber_jid_is_domain(const char *jid); const char *jabber_normalize(const PurpleAccount *account, const char *in); /* Returns true if JID is the bare JID of our server. */ gboolean jabber_is_own_server(JabberStream *js, const char *jid); /* Returns true if JID is the bare JID of our account. */ gboolean jabber_is_own_account(JabberStream *js, const char *jid); gboolean jabber_nodeprep_validate(const char *); gboolean jabber_domain_validate(const char *); gboolean jabber_resourceprep_validate(const char *); /** * Apply the SASLprep profile of stringprep to the string passed in. * * @returns A newly allocated string containing the normalized version * of the input, or NULL if an error occurred (the string could * not be normalized) */ char *jabber_saslprep(const char *); /* state -> readable name */ const char *jabber_buddy_state_get_name(JabberBuddyState state); /* state -> core id */ const char *jabber_buddy_state_get_status_id(JabberBuddyState state); /* state -> show attr (for presence stanza) */ const char *jabber_buddy_state_get_show(JabberBuddyState state); /* core id -> state */ JabberBuddyState jabber_buddy_status_id_get_state(const char *id); /* show attr (presence stanza) -> state */ JabberBuddyState jabber_buddy_show_get_state(const char *id); char *jabber_calculate_data_hash(gconstpointer data, size_t len, const gchar *hash_algo); #endif /* PURPLE_JABBER_JUTIL_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/message.h000077500000000000000000000045501412664500700227160ustar00rootroot00000000000000/** * @file message.h Message handlers * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_MESSAGE_H_ #define PURPLE_JABBER_MESSAGE_H_ #include "buddy.h" #include "jabber.h" #include "xmlnode.h" typedef struct _JabberMessage { JabberStream *js; enum { JABBER_MESSAGE_NORMAL, JABBER_MESSAGE_CHAT, JABBER_MESSAGE_GROUPCHAT, JABBER_MESSAGE_HEADLINE, JABBER_MESSAGE_ERROR, JABBER_MESSAGE_GROUPCHAT_INVITE, JABBER_MESSAGE_EVENT, JABBER_MESSAGE_OTHER } type; time_t sent; gboolean delayed; gboolean hasBuzz; char *id; char *from; char *to; char *subject; char *body; char *xhtml; char *password; char *error; char *thread_id; enum { JM_STATE_NONE, JM_STATE_ACTIVE, JM_STATE_COMPOSING, JM_STATE_PAUSED, JM_STATE_INACTIVE, JM_STATE_GONE } chat_state; GList *etc; GList *eventitems; } JabberMessage; void jabber_message_free(JabberMessage *jm); void jabber_message_send(JabberMessage *jm); void jabber_message_parse(JabberStream *js, xmlnode *packet); int jabber_message_send_im(PurpleConnection *gc, const char *who, const char *msg, PurpleMessageFlags flags); int jabber_message_send_chat(PurpleConnection *gc, int id, const char *message, PurpleMessageFlags flags); unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state); gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace); gboolean jabber_custom_smileys_isenabled(JabberStream *js, const const gchar *namespace); #endif /* PURPLE_JABBER_MESSAGE_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/namespaces.h000077500000000000000000000101521412664500700234040ustar00rootroot00000000000000/* * purple - Jabber Protocol Plugin * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_NAMESPACES_H_ #define PURPLE_JABBER_NAMESPACES_H_ #define NS_XMPP_BIND "urn:ietf:params:xml:ns:xmpp-bind" #define NS_XMPP_CLIENT "jabber:client" #define NS_XMPP_SASL "urn:ietf:params:xml:ns:xmpp-sasl" #define NS_XMPP_SESSION "urn:ietf:params:xml:ns:xmpp-session" #define NS_XMPP_STANZAS "urn:ietf:params:xml:ns:xmpp-stanzas" #define NS_XMPP_STREAMS "http://etherx.jabber.org/streams" #define NS_XMPP_TLS "urn:ietf:params:xml:ns:xmpp-tls" /* XEP-0012 Last Activity (and XEP-0256 Last Activity in Presence) */ #define NS_LAST_ACTIVITY "jabber:iq:last" /* XEP-0030 Service Discovery */ #define NS_DISCO_INFO "http://jabber.org/protocol/disco#info" #define NS_DISCO_ITEMS "http://jabber.org/protocol/disco#items" /* XEP-0047 IBB (In-band bytestreams) */ #define NS_IBB "http://jabber.org/protocol/ibb" /* XEP-0065 SOCKS5 Bytestreams */ #define NS_BYTESTREAMS "http://jabber.org/protocol/bytestreams" /* XEP-0066 Out of Band Data (OOB) */ #define NS_OOB_IQ_DATA "jabber:iq:oob" #define NS_OOB_X_DATA "jabber:x:oob" /* XEP-0071 XHTML-IM (rich-text messages) */ #define NS_XHTML_IM "http://jabber.org/protocol/xhtml-im" #define NS_XHTML "http://www.w3.org/1999/xhtml" /* XEP-0084 v0.12 User Avatar */ #define NS_AVATAR_0_12_DATA "http://www.xmpp.org/extensions/xep-0084.html#ns-data" #define NS_AVATAR_0_12_METADATA "http://www.xmpp.org/extensions/xep-0084.html#ns-metadata" /* XEP-0084 v1.1 User Avatar */ #define NS_AVATAR_1_1_DATA "urn:xmpp:avatar:data" #define NS_AVATAR_1_1_METADATA "urn:xmpp:avatar:metadata" /* XEP-0096 SI File Transfer */ #define NS_SI_FILE_TRANSFER "http://jabber.org/protocol/si/profile/file-transfer" /* XEP-0124 Bidirectional-streams Over Synchronous HTTP (BOSH) */ #define NS_BOSH "http://jabber.org/protocol/httpbind" /* XEP-0191 Simple Communications Blocking */ #define NS_SIMPLE_BLOCKING "urn:xmpp:blocking" /* XEP-0199 Ping */ #define NS_PING "urn:xmpp:ping" /* XEP-0202 Entity Time */ #define NS_ENTITY_TIME "urn:xmpp:time" /* XEP-0203 Delayed Delivery (and legacy delayed delivery) */ #define NS_DELAYED_DELIVERY "urn:xmpp:delay" #define NS_DELAYED_DELIVERY_LEGACY "jabber:x:delay" /* XEP-0206 XMPP over BOSH */ #define NS_XMPP_BOSH "urn:xmpp:xbosh" /* XEP-0224 Attention */ #define NS_ATTENTION "urn:xmpp:attention:0" /* XEP-0231 BoB (Bits of Binary) */ #define NS_BOB "urn:xmpp:bob" /* XEP-0237 Roster Versioning */ #define NS_ROSTER_VERSIONING "urn:xmpp:features:rosterver" /* XEP-0264 File Transfer Thumbnails (Thumbs) */ #define NS_THUMBS "urn:xmpp:thumbs:0" /* Google extensions */ #define NS_GOOGLE_CAMERA "http://www.google.com/xmpp/protocol/camera/v1" #define NS_GOOGLE_VIDEO "http://www.google.com/xmpp/protocol/video/v1" #define NS_GOOGLE_VOICE "http://www.google.com/xmpp/protocol/voice/v1" #define NS_GOOGLE_JINGLE_INFO "google:jingleinfo" #define NS_GOOGLE_MAIL_NOTIFY "google:mail:notify" #define NS_GOOGLE_ROSTER "google:roster" #define NS_GOOGLE_PROTOCOL_SESSION "http://www.google.com/xmpp/protocol/session" #define NS_GOOGLE_SESSION "http://www.google.com/session" #define NS_GOOGLE_SESSION_PHONE "http://www.google.com/session/phone" #define NS_GOOGLE_SESSION_VIDEO "http://www.google.com/session/video" #endif /* PURPLE_JABBER_NAMESPACES_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/oob.h000077500000000000000000000023051412664500700220450ustar00rootroot00000000000000/** * @file oob.h out-of-band transfer functions * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_OOB_H_ #define PURPLE_JABBER_OOB_H_ #include "jabber.h" void jabber_oob_parse(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *querynode); #endif /* PURPLE_JABBER_OOB_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/parser.h000077500000000000000000000023361412664500700225660ustar00rootroot00000000000000/** * @file parser.h XML parser functions * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_PARSER_H_ #define PURPLE_JABBER_PARSER_H_ #include "jabber.h" void jabber_parser_setup(JabberStream *js); void jabber_parser_free(JabberStream *js); void jabber_parser_process(JabberStream *js, const char *buf, int len); #endif /* PURPLE_JABBER_PARSER_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/pep.h000077500000000000000000000065161412664500700220620ustar00rootroot00000000000000/* * purple - Jabber Protocol Plugin * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_PEP_H_ #define PURPLE_JABBER_PEP_H_ #include "jabber.h" #include "message.h" #include "buddy.h" void jabber_pep_init(void); void jabber_pep_uninit(void); void jabber_pep_init_actions(GList **m); /* * Callback for receiving PEP events. * * @parameter js The JabberStream this item was received on * @parameter items The <items/>-tag with the <item/>-children */ typedef void (JabberPEPHandler)(JabberStream *js, const char *from, xmlnode *items); /* * Registers a callback for PEP events. Also automatically announces this receiving capability via disco#info. * Don't forget to use jabber_add_feature when supporting the sending of PEP events of this type. * * @parameter xmlns The namespace for this event * @parameter handlerfunc The callback to be used when receiving an event with this namespace */ void jabber_pep_register_handler(const char *xmlns, JabberPEPHandler handlerfunc); /* * Request a specific item from another PEP node. * * @parameter js The JabberStream that should be used * @parameter to The target PEP node * @parameter node The node name of the item that is requested * @parameter id The item id of the requested item (may be NULL) * @parameter cb The callback to be used when this item is received * * The items element passed to the callback will be NULL if any error occurred (like a permission error, node doesn't exist etc.) */ void jabber_pep_request_item(JabberStream *js, const char *to, const char *node, const char *id, JabberPEPHandler cb); /* * Default callback that can be used for namespaces which should only be enabled when PEP is supported * * @parameter js The JabberStream struct for this connection * @parameter namespace The namespace that's queried, ignored. * * @returns TRUE when PEP is enabled, FALSE otherwise */ gboolean jabber_pep_namespace_only_when_pep_enabled_cb(JabberStream *js, const gchar *namespace); void jabber_handle_event(JabberMessage *jm); /** * Delete the specified PEP node. */ void jabber_pep_delete_node(JabberStream *js, const gchar *node); /* * Publishes PEP item(s) * * @parameter js The JabberStream associated with the connection this event should be published * @parameter publish The publish node. This could be for example <publish node='http://jabber.org/protocol/tune'/> with an <item/> as subnode */ void jabber_pep_publish(JabberStream *js, xmlnode *publish); #endif /* PURPLE_JABBER_PEP_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/ping.h000077500000000000000000000025021412664500700222220ustar00rootroot00000000000000/** * @file ping.h ping functions * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_PING_H_ #define PURPLE_JABBER_PING_H_ #include "jabber.h" #include "iq.h" #include "xmlnode.h" void jabber_ping_parse(JabberStream *js, const char *from, JabberIqType, const char *id, xmlnode *child); gboolean jabber_ping_jid(JabberStream *js, const char *jid); void jabber_keepalive_ping(JabberStream *js); #endif /* PURPLE_JABBER_PING_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/presence.h000077500000000000000000000063211412664500700230740ustar00rootroot00000000000000/** * @file presence.h Presence * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_PRESENCE_H_ #define PURPLE_JABBER_PRESENCE_H_ typedef enum { JABBER_PRESENCE_ERROR = -2, JABBER_PRESENCE_PROBE = -1, JABBER_PRESENCE_AVAILABLE, JABBER_PRESENCE_UNAVAILABLE, JABBER_PRESENCE_SUBSCRIBE, JABBER_PRESENCE_SUBSCRIBED, JABBER_PRESENCE_UNSUBSCRIBE, JABBER_PRESENCE_UNSUBSCRIBED } JabberPresenceType; typedef struct _JabberPresenceChatInfo JabberPresenceChatInfo; typedef struct _JabberPresence JabberPresence; #include "buddy.h" #include "chat.h" #include "jabber.h" #include "jutil.h" #include "xmlnode.h" struct _JabberPresenceChatInfo { GSList *codes; xmlnode *item; }; struct _JabberPresence { JabberPresenceType type; JabberID *jid_from; const char *from; const char *to; const char *id; JabberBuddy *jb; JabberChat *chat; JabberPresenceChatInfo chat_info; xmlnode *caps; /* TODO: Temporary, see presence.c:parse_caps */ JabberBuddyState state; gchar *status; int priority; char *vcard_avatar_hash; char *nickname; gboolean delayed; time_t sent; int idle; }; typedef void (JabberPresenceHandler)(JabberStream *js, JabberPresence *presence, xmlnode *child); void jabber_presence_register_handler(const char *node, const char *xmlns, JabberPresenceHandler *handler); void jabber_presence_init(void); void jabber_presence_uninit(void); void jabber_set_status(PurpleAccount *account, PurpleStatus *status); /** * Send a full presence stanza. * * @param js A JabberStream object. * @param force Force sending the presence stanza, irrespective of whether * the contents seem to have changed. */ void jabber_presence_send(JabberStream *js, gboolean force); xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority); /* DEPRECATED */ xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, const char *msg, int priority); void jabber_presence_parse(JabberStream *js, xmlnode *packet); void jabber_presence_subscription_set(JabberStream *js, const char *who, const char *type); void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status); void purple_status_to_jabber(const PurpleStatus *status, JabberBuddyState *state, char **msg, int *priority); #endif /* PURPLE_JABBER_PRESENCE_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/roster.h000077500000000000000000000036371412664500700226150ustar00rootroot00000000000000/** * @file roster.h Roster manipulation * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_ROSTER_H_ #define PURPLE_JABBER_ROSTER_H_ /* it must *not* be localized */ #define JABBER_ROSTER_DEFAULT_GROUP "Buddies" #include "jabber.h" void jabber_roster_request(JabberStream *js); void jabber_roster_parse(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *query); void jabber_roster_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group); void jabber_roster_alias_change(PurpleConnection *gc, const char *name, const char *alias); void jabber_roster_group_change(PurpleConnection *gc, const char *name, const char *old_group, const char *new_group); void jabber_roster_group_rename(PurpleConnection *gc, const char *old_name, PurpleGroup *group, GList *moved_buddies); void jabber_roster_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group); const gchar * jabber_roster_group_get_global_name(PurpleGroup *group); #endif /* PURPLE_JABBER_ROSTER_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/si.h000077500000000000000000000030461412664500700217040ustar00rootroot00000000000000/** * @file si.h SI transfer functions * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_SI_H_ #define PURPLE_JABBER_SI_H_ #include "ft.h" #include "jabber.h" void jabber_bytestreams_parse(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *query); void jabber_si_parse(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *si); PurpleXfer *jabber_si_new_xfer(PurpleConnection *gc, const char *who); void jabber_si_xfer_send(PurpleConnection *gc, const char *who, const char *file); void jabber_si_init(void); void jabber_si_uninit(void); #endif /* PURPLE_JABBER_SI_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/useravatar.h000077500000000000000000000024131412664500700234430ustar00rootroot00000000000000/* * purple - Jabber Protocol Plugin * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef _PURPLE_JABBER_USERAVATAR_H_ #define _PURPLE_JABBER_USERAVATAR_H_ #include "jabber.h" #include "imgstore.h" /* Implementation of XEP-0084 */ void jabber_avatar_init(void); void jabber_avatar_set(JabberStream *js, PurpleStoredImage *img); void jabber_avatar_fetch_mine(JabberStream *js); #endif /* _PURPLE_JABBER_USERAVATAR_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/usermood.h000077500000000000000000000025261412664500700231300ustar00rootroot00000000000000/* * purple - Jabber Protocol Plugin * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_USERMOOD_H_ #define PURPLE_JABBER_USERMOOD_H_ #include "jabber.h" /* Implementation of XEP-0107 */ void jabber_mood_init(void); void jabber_mood_set(JabberStream *js, const char *mood, /* must be one of the valid strings defined in the XEP */ const char *text /* might be NULL */); PurpleMood *jabber_get_moods(PurpleAccount *account); #endif /* PURPLE_JABBER_USERMOOD_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/usernick.h000077500000000000000000000022371412664500700231150ustar00rootroot00000000000000/* * purple - Jabber Protocol Plugin * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_USERNICK_H_ #define PURPLE_JABBER_USERNICK_H_ #include "jabber.h" /* Implementation of XEP-0172 */ void jabber_nick_init(void); void jabber_nick_init_action(GList **m); #endif /* PURPLE_JABBER_USERNICK_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/usertune.h000077500000000000000000000027411412664500700231440ustar00rootroot00000000000000/* * purple - Jabber Protocol Plugin * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA * */ #ifndef PURPLE_JABBER_USERTUNE_H_ #define PURPLE_JABBER_USERTUNE_H_ #include "jabber.h" /* Implementation of XEP-0118 */ typedef struct _PurpleJabberTuneInfo PurpleJabberTuneInfo; struct _PurpleJabberTuneInfo { char *artist; char *title; char *album; char *track; /* either the index of the track in the album or the URL for a stream */ int time; /* in seconds, -1 for unknown */ char *url; }; void jabber_tune_init(void); void jabber_tune_set(PurpleConnection *gc, const PurpleJabberTuneInfo *tuneinfo); #endif /* PURPLE_JABBER_USERTUNE_H_ */ purple-xmpp-http-upload-0.2.4/headers/jabber/xdata.h000077500000000000000000000041661412664500700223760ustar00rootroot00000000000000/** * @file xdata.h utility functions * * purple * * Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ #ifndef PURPLE_JABBER_XDATA_H_ #define PURPLE_JABBER_XDATA_H_ #include "jabber.h" #include "xmlnode.h" typedef struct _JabberXDataAction { char *name; char *handle; } JabberXDataAction; typedef void (*jabber_x_data_cb)(JabberStream *js, xmlnode *result, gpointer user_data); typedef void (*jabber_x_data_action_cb)(JabberStream *js, xmlnode *result, const char *actionhandle, gpointer user_data); void *jabber_x_data_request(JabberStream *js, xmlnode *packet, jabber_x_data_cb cb, gpointer user_data); void *jabber_x_data_request_with_actions(JabberStream *js, xmlnode *packet, GList *actions, int defaultaction, jabber_x_data_action_cb cb, gpointer user_data); /* * Return the form type (the CDATA of the value child of the FORM_TYPE * field entry. * E.g., for the following, "http://jabber.org/protocol/muc#roominfo". * * * http://jabber.org/protocol/muc#roominfo * * * * @param form The xmlnode for the form (the 'x' element) * @returns The FORM_TYPE. Must be freed by caller. */ gchar *jabber_x_data_get_formtype(const xmlnode *form); #endif /* PURPLE_JABBER_XDATA_H_ */ purple-xmpp-http-upload-0.2.4/makefile000066400000000000000000000020501412664500700177470ustar00rootroot00000000000000CC ?= gcc CFLAGS ?= -g -pipe PKG_CONFIG ?= pkg-config DIR_PERM = 0755 FILE_PERM = 0644 HEADERS=-I./headers/jabber CFLAGS += -fPIC $(shell $(PKG_CONFIG) --cflags glib-2.0 gio-2.0 purple) $(shell xml2-config --cflags) $(HEADERS) LIBS += $(shell $(PKG_CONFIG) --libs glib-2.0 gio-2.0 purple) $(shell xml2-config --libs) -L$(shell $(PKG_CONFIG) --variable=plugindir purple) -ldl -lm -ljabber PLUGIN_DIR_PURPLE = $(shell $(PKG_CONFIG) --variable=plugindir purple) DATA_ROOT_DIR_PURPLE = $(shell $(PKG_CONFIG) --variable=datarootdir purple) PRPL_NAME = jabber_http_file_upload.so PRPL_LIBNAME = ${PRPL_NAME} SKYPEWEB_SOURCES = \ src/hfu_disco.c \ src/hfu_util.c \ src/jabber_http_file_upload.c .PHONY: all clean install all: $(PRPL_NAME) install: mkdir -m $(DIR_PERM) -p $(DESTDIR)$(PLUGIN_DIR_PURPLE) install -m $(FILE_PERM) $(PRPL_LIBNAME) $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME) clean: rm -f jabber_http_file_upload.so $(PRPL_NAME): $(SKYPEWEB_SOURCES) $(CC) -Wall -I. $(CFLAGS) $(SKYPEWEB_SOURCES) -o $@ $(CFLAGS) $(LIBS) $(LDFLAGS) -shared purple-xmpp-http-upload-0.2.4/makefile.mingw000066400000000000000000000027341412664500700211000ustar00rootroot00000000000000 PIDGIN_TREE_TOP ?= ../pidgin-2.10.11 WIN32_DEV_TOP ?= $(PIDGIN_TREE_TOP)/../win32-dev #only defined on 64-bit windows PROGFILES32 = ${ProgramFiles(x86)} ifndef PROGFILES32 PROGFILES32 = $(PROGRAMFILES) endif PLUGIN_DIR_PURPLE = "$(PROGFILES32)/Pidgin/plugins" CC ?= $(WIN32_DEV_TOP)/mingw-4.7.2/bin/gcc CFLAGS ?= -O2 -g -ggdb -pipe LDFLAGS ?= -ljabber PKG_CONFIG ?= pkg-config DIR_PERM = 0755 FILE_PERM = 0644 HEADERS = -I./headers/jabber CFLAGS += -I$(WIN32_DEV_TOP)/glib-2.28.8/include -I$(WIN32_DEV_TOP)/glib-2.28.8/include/glib-2.0 -I$(WIN32_DEV_TOP)/glib-2.28.8/lib/glib-2.0/include -I$(WIN32_DEV_TOP)/glib-2.28.8/gio-2.0 -DENABLE_NLS -I$(PIDGIN_TREE_TOP)/libpurple -I$(PIDGIN_TREE_TOP) -I$(WIN32_DEV_TOP)/libxml2-2.9.0/include/libxml2 $(HEADERS) LIBS += -L$(PIDGIN_TREE_TOP)/libpurple -L$(PIDGIN_TREE_TOP)/libpurple/protocols/jabber/ -L$(WIN32_DEV_TOP)/glib-2.28.8/lib -L$(WIN32_DEV_TOP)/libxml2-2.9.0/lib -lpurple -lintl -lglib-2.0 -lgio-2.0 -lxml2 -static-libgcc -lz PRPL_NAME = jabber_http_file_upload.dll PRPL_LIBNAME = ${PRPL_NAME} PRPL_SOURCES = \ src/hfu_disco.c \ src/hfu_util.c \ src/jabber_http_file_upload.c .PHONY: all clean install all: $(PRPL_NAME) install: $(PRPL_LIBNAME) mkdir -m $(DIR_PERM) -p $(DESTDIR)$(PLUGIN_DIR_PURPLE) install -m $(FILE_PERM) $(PRPL_LIBNAME) $(DESTDIR)$(PLUGIN_DIR_PURPLE)/$(PRPL_NAME) clean: rm -f $(PRPL_NAME) $(PRPL_NAME): $(PRPL_SOURCES) $(CC) -Wall -I. $(CFLAGS) $(PRPL_SOURCES) -o $@ $(CFLAGS) $(LIBS) $(LDFLAGS) -shared purple-xmpp-http-upload-0.2.4/src/000077500000000000000000000000001412664500700170415ustar00rootroot00000000000000purple-xmpp-http-upload-0.2.4/src/hfu_disco.c000066400000000000000000000060241412664500700211520ustar00rootroot00000000000000 #include #include #include "debug.h" #include "disco.h" #include "iq.h" #include "hfu_disco.h" #include "hfu_util.h" #include "jabber_http_file_upload.h" static void jabber_hfu_disco_info_cb(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *packet, gpointer data) { xmlnode *query, *feature = NULL, *field = NULL, *value = NULL, *x = NULL; HFUJabberStreamData *js_data = NULL; query = xmlnode_get_child_with_namespace(packet, "query", NS_DISCO_INFO); if (type != JABBER_IQ_RESULT || query == NULL) return; js_data = g_hash_table_lookup(HFUJabberStreamDataTable, js); // Always prefer latest standard, skip if already found if (!js_data || str_equal(js_data->ns, NS_HTTP_FILE_UPLOAD_V0)) return; for (feature = xmlnode_get_child(query, "feature") ; feature; feature = xmlnode_get_next_twin(feature)) { const char *var = xmlnode_get_attrib(feature, "var"); if(!var) continue; if(str_equal(var, NS_HTTP_FILE_UPLOAD) && js_data->ns == NULL) js_data->ns = NS_HTTP_FILE_UPLOAD; else if(str_equal(var, NS_HTTP_FILE_UPLOAD_V0)) js_data->ns = NS_HTTP_FILE_UPLOAD_V0; else continue; g_free(js_data->host); js_data->host = g_strdup(from); x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"); if (x) { for(field = xmlnode_get_child(x, "field"); field; field = xmlnode_get_next_twin(field)) { const char *var = xmlnode_get_attrib(field, "var"); if(var && str_equal(var, "max-file-size")) if((value = xmlnode_get_child(field, "value"))) js_data->max_file_size = (gsize) atol(xmlnode_get_data(value)); } } } } static void jabber_hfu_disco_server_items_result_cb(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *packet, gpointer data) { xmlnode *query, *child; if (!from || strcmp(from, js->user->domain) != 0) return; if (type == JABBER_IQ_ERROR) return; query = xmlnode_get_child(packet, "query"); for(child = xmlnode_get_child(query, "item"); child; child = xmlnode_get_next_twin(child)) { JabberIq *iq; const char *jid; if(!(jid = xmlnode_get_attrib(child, "jid"))) continue; if(xmlnode_get_attrib(child, "node") != NULL) continue; iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO); xmlnode_set_attrib(iq->node, "to", jid); jabber_iq_set_callback(iq, jabber_hfu_disco_info_cb, NULL); jabber_iq_send(iq); } } void jabber_hfu_disco_items_server(JabberStream *js) { JabberIq *iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_ITEMS); xmlnode_set_attrib(iq->node, "to", js->user->domain); jabber_iq_set_callback(iq, jabber_hfu_disco_server_items_result_cb, NULL); jabber_iq_send(iq); iq = jabber_iq_new_query(js, JABBER_IQ_GET, NS_DISCO_INFO); xmlnode_set_attrib(iq->node, "to", js->user->domain); jabber_iq_set_callback(iq, jabber_hfu_disco_info_cb, NULL); jabber_iq_send(iq); } purple-xmpp-http-upload-0.2.4/src/hfu_disco.h000066400000000000000000000001121412664500700211470ustar00rootroot00000000000000#include "jabber.h" void jabber_hfu_disco_items_server(JabberStream *js);purple-xmpp-http-upload-0.2.4/src/hfu_util.c000066400000000000000000000005641412664500700210310ustar00rootroot00000000000000#include gchar* file_get_mime(const gchar *filename) { gboolean is_certain = FALSE; char *content_type = g_content_type_guess(filename, NULL, 0, &is_certain); if (content_type != NULL) { gchar *mime_type = g_content_type_get_mime_type(content_type); g_free(content_type); return mime_type; } return NULL; }purple-xmpp-http-upload-0.2.4/src/hfu_util.h000066400000000000000000000001441412664500700210300ustar00rootroot00000000000000#define str_equal(str1, str2) (!g_strcmp0(str1, str2)) gchar* file_get_mime(const gchar *filename);purple-xmpp-http-upload-0.2.4/src/jabber_http_file_upload.c000066400000000000000000000442001412664500700240340ustar00rootroot00000000000000#define PURPLE_PLUGINS #include #include #include #include #include #include "cmds.h" #include "debug.h" #include "notify.h" #include "plugin.h" #include "version.h" #include "sslconn.h" #include "util.h" #include "prpl.h" #include "jutil.h" #include "chat.h" #include "ft.h" #include "iq.h" #include "disco.h" #include "hfu_disco.h" #include "hfu_util.h" #include "jabber_http_file_upload.h" GHashTable *HFUJabberStreamDataTable; GList *(*old_blist_node_menu)(PurpleBlistNode *node); typedef struct { gchar *host; gint port; gchar *path; gchar *user; gchar *passwd; } PurpleHttpURL; static inline PurpleHttpURL *purple_http_url_parse(const gchar *url) { PurpleHttpURL *ret = g_new0(PurpleHttpURL, 1); purple_url_parse(url, &(ret->host), &(ret->port), &(ret->path), &(ret->user), &(ret->passwd)); return ret; } GHashTable *HFUJabberStreamDataTable; GHashTable *ht_hfu_sending; #define purple_http_url_get_host(httpurl) (httpurl->host) #define purple_http_url_get_port(httpurl) (httpurl->port) #define purple_http_url_get_path(httpurl) (httpurl->path) static inline void purple_http_url_free(PurpleHttpURL *phl) { g_free(phl->host); g_free(phl->path); g_free(phl->user); g_free(phl->passwd); g_free(phl); } #define PREF_PREFIX "/plugins/xmpp-http-upload" #define JABBER_PLUGIN_ID "prpl-jabber" static void jabber_hfu_http_read(gpointer user_data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond) { PurpleXfer *xfer = user_data; gchar buf[1024] = {0}; //Read the server buffer size_t rl = purple_ssl_read(ssl_connection, buf, 1024); purple_debug_info("jabber_http_upload", "Server file send response was %" G_GSIZE_FORMAT " bytes: %s\n", (gsize) rl, buf); if(rl == (size_t)-1) return; if ((purple_xfer_get_bytes_sent(xfer)) >= purple_xfer_get_size(xfer)) { // Looking for HTTP/1.1 201 if(rl > 12 && g_str_has_prefix(buf, "HTTP/1.") && g_str_has_prefix(buf+8, " 20")) { // 20x statuses are good, should be 201 but who knows those servers purple_xfer_set_completed(xfer, TRUE); purple_xfer_end(xfer); return; } } // We've read everything it seems but didn't understand a word purple_xfer_cancel_remote(xfer); g_return_if_reached(); } static void jabber_hfu_http_send_connect_cb(gpointer data, PurpleSslConnection *ssl_connection, PurpleInputCondition cond) { PurpleHttpURL *httpurl; gchar *headers, *auth = NULL, *expire = NULL, *cookie = NULL; PurpleXfer *xfer = data; HFUXfer *hfux = purple_xfer_get_protocol_data(xfer); HFUJabberStreamData *js_data = hfux->js_data; char *filemime = file_get_mime(purple_xfer_get_local_filename(xfer)); httpurl = purple_http_url_parse(hfux->put_url); if (str_equal(js_data->ns, NS_HTTP_FILE_UPLOAD_V0)) { char *a = g_hash_table_lookup(hfux->put_headers, "Authorisation"); char *c = g_hash_table_lookup(hfux->put_headers, "Cookie"); char *e = g_hash_table_lookup(hfux->put_headers, "Expires"); if(a) auth = g_strdup_printf("Authorisation: %s\r\n", a); if(c) cookie = g_strdup_printf("Cookie: %s\r\n", c); if(e) expire = g_strdup_printf("Expires: %s\r\n", e); } headers = g_strdup_printf("PUT /%s HTTP/1.0\r\n" "Connection: close\r\n" "Host: %s\r\n" "Content-Length: %" G_GSIZE_FORMAT "\r\n" "Content-Type: %s\r\n" "User-Agent: libpurple\r\n" "%s%s%s\r\n", purple_http_url_get_path(httpurl), purple_http_url_get_host(httpurl), (gsize) purple_xfer_get_size(xfer), (filemime?:"application/octet-stream"), (auth?:""), (expire?:""), (cookie?:"")); g_free(auth); g_free(expire); g_free(cookie); g_free(filemime); hfux->ssl_conn = ssl_connection; purple_ssl_input_add(ssl_connection, jabber_hfu_http_read, xfer); purple_ssl_write(ssl_connection, headers, strlen(headers)); g_free(headers); purple_xfer_ref(xfer); purple_xfer_start(xfer, ssl_connection->fd, NULL, 0); purple_xfer_prpl_ready(xfer); purple_http_url_free(httpurl); } static void jabber_hfu_http_error_connect_cb(PurpleSslConnection *ssl_connection, PurpleSslErrorType *error_type, gpointer data) { purple_debug_info("jabber_http_upload", "SSL error\n"); } static void jabber_hfu_request_cb(JabberStream *js, const char *from, JabberIqType type, const char *id, xmlnode *packet, gpointer data) { PurpleAccount *account; xmlnode *slot, *put, *get, *header = NULL; PurpleHttpURL *put_httpurl; PurpleXfer *xfer = data; HFUXfer *hfux = purple_xfer_get_protocol_data(xfer); HFUJabberStreamData *js_data = hfux->js_data; account = purple_connection_get_account(js->gc); if(!(slot = xmlnode_get_child_with_namespace(packet, "slot", js_data->ns))) { purple_xfer_cancel_remote(xfer); return; } put = xmlnode_get_child(slot, "put"); get = xmlnode_get_child(slot, "get"); if (str_equal(js_data->ns, NS_HTTP_FILE_UPLOAD_V0)) { hfux->put_headers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); for (header = xmlnode_get_child(put, "header") ; header; header = xmlnode_get_next_twin(header)) { g_hash_table_insert(hfux->put_headers, g_strdup(xmlnode_get_attrib(header, "name")), xmlnode_get_data(header)); } hfux->put_url = g_strdup(xmlnode_get_attrib(put, "url")); hfux->get_url = g_strdup(xmlnode_get_attrib(get, "url")); } else { hfux->put_url = xmlnode_get_data(put); hfux->get_url = xmlnode_get_data(get); } put_httpurl = purple_http_url_parse(hfux->put_url); g_debug("Connecting to %s:%d for %s", purple_http_url_get_host(put_httpurl), purple_http_url_get_port(put_httpurl), hfux->put_url); purple_ssl_connect(account, purple_http_url_get_host(put_httpurl), purple_http_url_get_port(put_httpurl), jabber_hfu_http_send_connect_cb, (PurpleSslErrorFunction)jabber_hfu_http_error_connect_cb, xfer); purple_http_url_free(put_httpurl); } static void jabber_hfu_xfer_free(PurpleXfer *xfer) { HFUXfer *hfux = purple_xfer_get_protocol_data(xfer); g_return_if_fail(hfux != NULL); g_free(hfux->put_url); g_free(hfux->get_url); if(hfux->put_headers) g_hash_table_destroy(hfux->put_headers); if (hfux->ssl_conn) { purple_ssl_close(hfux->ssl_conn); } g_free(hfux); purple_xfer_set_protocol_data(xfer, NULL); } static void jabber_hfu_send_request(PurpleXfer *xfer) { xmlnode *request_node; const gchar *filename, *filepath; gchar *filemime, *filesize; HFUXfer *hfux = purple_xfer_get_protocol_data(xfer); JabberStream *js = hfux->js; HFUJabberStreamData *js_data = hfux->js_data; JabberIq *iq = jabber_iq_new(js, JABBER_IQ_GET); xmlnode_set_attrib(iq->node, "to", js_data->host); request_node = xmlnode_new_child(iq->node, "request"); xmlnode_set_namespace(request_node, js_data->ns); filename = purple_xfer_get_filename(xfer); filepath = purple_xfer_get_local_filename(xfer); filesize = g_strdup_printf("%" G_GSIZE_FORMAT, (gsize) purple_xfer_get_size(xfer)); filemime = file_get_mime(filepath); if (str_equal(js_data->ns, NS_HTTP_FILE_UPLOAD_V0)) { xmlnode_set_attrib(request_node, "filename", filename); xmlnode_set_attrib(request_node, "size", filesize); if (filemime) xmlnode_set_attrib(request_node, "content-type", filemime); } else { xmlnode *filename_node = xmlnode_new_child(request_node, "filename"); xmlnode_insert_data(filename_node, filename, -1); xmlnode *size_node = xmlnode_new_child(request_node, "size"); xmlnode_insert_data(size_node, filesize, -1); if (filemime) { xmlnode *content_type_node = xmlnode_new_child(request_node, "content-type"); xmlnode_insert_data(content_type_node, filemime, -1); } } jabber_iq_set_callback(iq, jabber_hfu_request_cb, xfer); jabber_iq_send(iq); g_free(filesize); if (filemime) g_free(filemime); } static void jabber_hfu_xmlnode_send_cb(PurpleConnection *gc, xmlnode **packet, gpointer null) { if (*packet != NULL && (*packet)->name) { if (g_strcmp0 ((*packet)->name, "message") == 0) { xmlnode *node_body = xmlnode_get_child (*packet, "body"); if (node_body) { char *url = xmlnode_get_data(node_body); HFUXfer *hfux = g_hash_table_lookup(ht_hfu_sending, url); g_free(url); if(hfux) { xmlnode *x, *url; x = xmlnode_new_child (*packet, "x"); xmlnode_set_namespace (x, NS_OOB_X_DATA); g_debug ("Adding OOB Data to URL: %s", hfux->get_url); url = xmlnode_new_child(x, "url"); xmlnode_insert_data(url, hfux->get_url, -1); } } } } } static void jabber_hfu_send_url_to_conv(PurpleXfer *xfer) { PurpleConversation *conv; HFUXfer *hfux = purple_xfer_get_protocol_data(xfer); PurpleAccount *account = purple_xfer_get_account(xfer); PurpleConversationType conv_type; conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, xfer->who, account); if (!conv) { conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, xfer->who, account); } if (conv) { conv_type = purple_conversation_get_type(conv); if (conv_type == PURPLE_CONV_TYPE_CHAT) { PurpleConvChat *conv_chat = purple_conversation_get_chat_data(conv); purple_conv_chat_send(conv_chat, hfux->get_url); } else if (conv_type == PURPLE_CONV_TYPE_IM) { PurpleConvIm *conv_im = purple_conversation_get_im_data(conv); // Send raw URL to handle it later g_hash_table_insert(ht_hfu_sending, hfux->get_url, hfux); purple_conv_im_send_with_flags(conv_im, hfux->get_url, PURPLE_MESSAGE_RAW); g_hash_table_remove(ht_hfu_sending, hfux->get_url); } } } static void jabber_hfu_xfer_end(PurpleXfer *xfer) { g_debug("This is the end."); jabber_hfu_send_url_to_conv(xfer); jabber_hfu_xfer_free(xfer); } static void jabber_hfu_xfer_cancel_send(PurpleXfer *xfer) { jabber_hfu_xfer_free(xfer); purple_debug_info("jabber_http_upload", "in jabber_hfu_xfer_cancel_send\n"); } static gssize jabber_hfu_xfer_write(const guchar *buffer, size_t len, PurpleXfer *xfer) { gssize tlen; HFUXfer *hfux = purple_xfer_get_protocol_data(xfer); tlen = purple_ssl_write(hfux->ssl_conn, buffer, len); if (tlen == -1) { if ((errno != EAGAIN) && (errno != EINTR)) return -1; return 0; } else if ((purple_xfer_get_bytes_sent(xfer)+tlen) >= purple_xfer_get_size(xfer)) xfer->status = PURPLE_XFER_STATUS_DONE; // sneaky cheat return tlen; } static void jabber_hfu_xfer_ack(PurpleXfer *xfer, const guchar *buffer, size_t len) { if (purple_xfer_is_completed(xfer)) xfer->status = PURPLE_XFER_STATUS_STARTED; // hideous uncheat } static void jabber_hfu_xfer_init(PurpleXfer *xfer) { HFUXfer *hfux = purple_xfer_get_protocol_data(xfer); JabberStream *js = hfux->js; HFUJabberStreamData *js_data = g_hash_table_lookup(HFUJabberStreamDataTable, js); hfux->js_data = js_data; purple_debug_info("jabber_http_upload", "in jabber_hfu_xfer_init\n"); if (!js_data->ns) { purple_notify_error(hfux->js->gc, _("File Send Failed"), _("File Send Failed"), _("HTTP File Upload is not supported by server")); purple_debug_info("jabber_http_upload", "HTTP File Upload is not supported by server\n"); purple_xfer_cancel_local(xfer); return; } if (js_data->max_file_size && purple_xfer_get_size(xfer) > js_data->max_file_size) { gchar *msg = g_strdup_printf(_("HTTP File Upload maximum file size is %" G_GSIZE_FORMAT " bytes"), js_data->max_file_size); purple_notify_error(hfux->js->gc, _("File Send Failed"), _("File Send Failed"), msg); g_free(msg); purple_debug_info("jabber_http_upload", "HTTP File Upload maximum file size limit\n"); purple_xfer_cancel_local(xfer); return; } jabber_hfu_send_request(xfer); } PurpleXfer *jabber_hfu_new_xfer(PurpleConnection *gc, const char *who) { JabberStream *js; PurpleXfer *xfer; HFUXfer *hfux = NULL; js = gc->proto_data; xfer = purple_xfer_new(gc->account, PURPLE_XFER_SEND, who); purple_xfer_set_protocol_data(xfer, hfux = g_new0(HFUXfer, 1)); hfux->js = js; purple_xfer_set_init_fnc(xfer, jabber_hfu_xfer_init); purple_xfer_set_cancel_send_fnc(xfer, jabber_hfu_xfer_cancel_send); purple_xfer_set_write_fnc(xfer, jabber_hfu_xfer_write); purple_xfer_set_ack_fnc(xfer, jabber_hfu_xfer_ack); purple_xfer_set_end_fnc(xfer, jabber_hfu_xfer_end); return xfer; } void jabber_hfu_xfer_send(PurpleConnection *gc, const char *who, const char *filename) { PurpleXfer *xfer; xfer = jabber_hfu_new_xfer(gc, who); if (filename && *filename) purple_xfer_request_accepted(xfer, filename); else purple_xfer_request(xfer); } static void jabber_hfu_signed_on_cb(PurpleConnection *conn, void *data) { PurpleAccount *account = purple_connection_get_account(conn); if (strcmp(JABBER_PLUGIN_ID, purple_account_get_protocol_id(account))) return; JabberStream *js = purple_connection_get_protocol_data(conn); HFUJabberStreamData *js_data = g_new0(HFUJabberStreamData, 1); g_hash_table_insert(HFUJabberStreamDataTable, js, js_data); jabber_hfu_disco_items_server(js); } static void jabber_hfu_signed_off_cb(PurpleConnection *conn, void *data) { PurpleAccount *account = purple_connection_get_account(conn); if (strcmp(JABBER_PLUGIN_ID, purple_account_get_protocol_id(account))) return; JabberStream *js = purple_connection_get_protocol_data(conn); HFUJabberStreamData *js_data = g_hash_table_lookup(HFUJabberStreamDataTable, js); if(js_data) { g_hash_table_remove(HFUJabberStreamDataTable, js); g_free(js_data->host); g_free(js_data); } } static void jabber_hfu_send_act(PurpleBlistNode *node, gpointer ignored) { PurpleConnection *gc = NULL; const gchar *bname; if(PURPLE_BLIST_NODE_IS_BUDDY(node)) { PurpleBuddy *buddy = (PurpleBuddy *)node; gc = purple_account_get_connection(purple_buddy_get_account(buddy)); bname = buddy->name; } else if (PURPLE_BLIST_NODE_IS_CHAT(node)) { PurpleChat *chat = PURPLE_CHAT(node); gc = purple_account_get_connection(purple_chat_get_account(chat)); bname = jabber_get_chat_name(purple_chat_get_components(chat)); } if (gc) jabber_hfu_xfer_send(gc, bname, NULL); } static GList *jabber_hfu_blist_node_menu(PurpleBlistNode *node) { PurpleMenuAction *act; GList *menu = old_blist_node_menu(node); act = purple_menu_action_new(_("HTTP File Upload"), PURPLE_CALLBACK(jabber_hfu_send_act), NULL, NULL); menu = g_list_append(menu, act); return menu; } gboolean plugin_unload(PurplePlugin *plugin) { PurplePlugin *jabber_plugin = purple_plugins_find_with_id(JABBER_PLUGIN_ID); PurplePluginProtocolInfo *jabber_protocol_info = PURPLE_PLUGIN_PROTOCOL_INFO(jabber_plugin); jabber_protocol_info->blist_node_menu = old_blist_node_menu; purple_signals_disconnect_by_handle(plugin); g_hash_table_destroy(ht_hfu_sending); g_hash_table_destroy(HFUJabberStreamDataTable); return TRUE; } gboolean plugin_load(PurplePlugin *plugin) { PurplePlugin *jabber_plugin = purple_plugins_find_with_id(JABBER_PLUGIN_ID); PurplePluginProtocolInfo *jabber_protocol_info = PURPLE_PLUGIN_PROTOCOL_INFO(jabber_plugin); gboolean force = purple_prefs_get_bool(PREF_PREFIX "/force"); if (force) { jabber_protocol_info->send_file = jabber_hfu_xfer_send; jabber_protocol_info->new_xfer = jabber_hfu_new_xfer; } old_blist_node_menu = jabber_protocol_info->blist_node_menu; jabber_protocol_info->blist_node_menu = jabber_hfu_blist_node_menu; purple_signal_connect(purple_connections_get_handle(), "signed-on", plugin, PURPLE_CALLBACK(jabber_hfu_signed_on_cb), NULL); purple_signal_connect(purple_connections_get_handle(), "signed-off", plugin, PURPLE_CALLBACK(jabber_hfu_signed_off_cb), NULL); HFUJabberStreamDataTable = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); ht_hfu_sending = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); purple_signal_connect(jabber_plugin, "jabber-sending-xmlnode", plugin, PURPLE_CALLBACK(jabber_hfu_xmlnode_send_cb), NULL); return TRUE; } static PurplePluginPrefFrame *get_plugin_pref_frame(PurplePlugin *plugin) { PurplePluginPrefFrame *frame; PurplePluginPref *pref; frame = purple_plugin_pref_frame_new(); pref = purple_plugin_pref_new_with_name_and_label(PREF_PREFIX "/force", _("Force HTTP File Upload")); purple_plugin_pref_frame_add(frame, pref); return frame; } static PurplePluginUiInfo prefs_info = { get_plugin_pref_frame, 0, /* page_num (Reserved) */ NULL, /* frame (Reserved) */ /* Padding */ NULL, NULL, NULL, NULL }; static PurplePluginInfo info = { PURPLE_PLUGIN_MAGIC, PURPLE_MAJOR_VERSION, PURPLE_MINOR_VERSION, PURPLE_PLUGIN_STANDARD, NULL, 0, NULL, PURPLE_PRIORITY_DEFAULT, "xep-http-file-upload", "XMPP HTTP File Upload", "0.1.0", "Implements XEP-0363: HTTP File Upload", "This plugin allows to upload a file to HTTP server", "Dmitry Kosenkov ", "https://github.com/Junker/purple-xmpp-http-upload", plugin_load, plugin_unload, NULL, NULL, NULL, &prefs_info, NULL, NULL, NULL, NULL, NULL }; static void plugin_init(PurplePlugin * plugin) { PurplePluginInfo * info = plugin->info; info->dependencies = g_list_prepend(info->dependencies, "prpl-jabber"); purple_prefs_add_none(PREF_PREFIX); purple_prefs_add_bool(PREF_PREFIX "/force", FALSE); } PURPLE_INIT_PLUGIN(jabber_http_file_upload, plugin_init, info) purple-xmpp-http-upload-0.2.4/src/jabber_http_file_upload.h000066400000000000000000000011761412664500700240460ustar00rootroot00000000000000#include "jabber.h" typedef struct _HFUJabberStreamData { gchar *host; gsize max_file_size; gchar *ns; } HFUJabberStreamData; typedef struct _HFUXfer { JabberStream *js; HFUJabberStreamData *js_data; PurpleSslConnection *ssl_conn; gchar *put_url; gchar *get_url; GHashTable *put_headers; } HFUXfer; extern GHashTable *HFUJabberStreamDataTable; #define NS_HTTP_FILE_UPLOAD "urn:xmpp:http:upload" #define NS_HTTP_FILE_UPLOAD_V0 "urn:xmpp:http:upload:0" #define purple_xfer_get_protocol_data(xfer) ((xfer)->data) #define purple_xfer_set_protocol_data(xfer, proto_data) ((xfer)->data = (proto_data))