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