├── .circleci └── config.yml ├── .envrc ├── .gitignore ├── LICENSE ├── README.md ├── Setup.hs ├── cbits ├── keywee.c ├── keywee.h └── weechat │ └── weechat-plugin.h ├── default.nix ├── keywee.cabal ├── keywee.scm ├── plugin ├── FRP.hs ├── Main.hs ├── Plugin.hs └── WeeChat │ ├── Buffer.hs │ ├── FFI.hs │ ├── Monad.hs │ └── Types.hsc ├── release.nix ├── shell.nix └── src ├── Data └── Conduit │ └── Process │ └── Typed │ └── Flush.hs ├── Keybase.hs └── Keybase ├── Chat.hs └── Chat ├── Monad.hs ├── Request.hs └── Types.hs /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | setup: 4 | docker: 5 | - image: fpco/stack-build:lts-10.4 6 | steps: 7 | - run: apt-get install -y weechat 8 | - run: stack upgrade 9 | - checkout 10 | - restore_cache: 11 | keys: 12 | - stack-deps 13 | - run: stack setup 14 | - run: stack build --only-dependencies 15 | - save_cache: 16 | key: stack-deps 17 | paths: 18 | - ~/.stack 19 | - .stack-work 20 | - .stack 21 | 22 | build: 23 | docker: 24 | - image: fpco/stack-build:lts-10.4 25 | steps: 26 | - checkout 27 | - run: stack setup 28 | - run: stack build 29 | - run: stack exec perl opts.pl keywe 30 | - run: make all 31 | 32 | workflows: 33 | version: 2 34 | build: 35 | jobs: 36 | - setup 37 | - build: 38 | requires: 39 | - setup 40 | -------------------------------------------------------------------------------- /.envrc: -------------------------------------------------------------------------------- 1 | use nix 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | dist-* 3 | cabal-dev 4 | *.o 5 | *.hi 6 | *.chi 7 | *.chs.h 8 | *.dyn_o 9 | *.dyn_hi 10 | *.tix 11 | .hpc 12 | .hsenv 13 | .cabal-sandbox/ 14 | cabal.sandbox.config 15 | *.prof 16 | *.aux 17 | *.hp 18 | .stack-work/ 19 | a.out 20 | *_stub.h 21 | 22 | # nix 23 | result 24 | -------------------------------------------------------------------------------- /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 | Keybase chat plugin for WeeChat 2 | =============== 3 | -------------------------------------------------------------------------------- /Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /cbits/keywee.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #if __GLASGOW_HASKELL__ 5 | #include 6 | #endif 7 | 8 | #include "keywee.h" 9 | 10 | extern void keyweeInit(void); 11 | 12 | WEECHAT_PLUGIN_NAME("keywee"); 13 | WEECHAT_PLUGIN_DESCRIPTION(N_("Keybase chat plugin for WeeChat")); 14 | WEECHAT_PLUGIN_AUTHOR("Jakub Kopański "); 15 | WEECHAT_PLUGIN_VERSION("0.1"); 16 | WEECHAT_PLUGIN_LICENSE("GPL3"); 17 | 18 | struct t_weechat_plugin *weechat_keywee_plugin = NULL; 19 | 20 | int 21 | my_input_cb (const void *pointer, void *data, 22 | struct t_gui_buffer *buffer, const char *input_data) 23 | { 24 | weechat_printf (buffer, "Text: %s", input_data); 25 | return WEECHAT_RC_OK; 26 | } 27 | 28 | int 29 | my_close_cb (const void *pointer, void *data, struct t_gui_buffer *buffer) 30 | { 31 | weechat_printf (NULL, "Buffer '%s' will be closed!", 32 | weechat_buffer_get_string (buffer, "name")); 33 | return WEECHAT_RC_OK; 34 | } 35 | 36 | int 37 | command_keybase_cb (const void *pointer, 38 | void *data, 39 | struct t_gui_buffer *buffer, 40 | int argc, 41 | char **argv, 42 | char **argv_eol) 43 | { 44 | if (argc > 1) 45 | { 46 | weechat_command (NULL, argv_eol[1]); 47 | weechat_command (NULL, argv_eol[1]); 48 | } 49 | 50 | return WEECHAT_RC_OK; 51 | } 52 | 53 | int 54 | weechat_plugin_init (struct t_weechat_plugin *plugin, 55 | int argc, 56 | char *argv[]) 57 | { 58 | int hsargc = 1; 59 | char* hsargv[] = { "+RTS", NULL }; 60 | char** pargv = hsargv; 61 | RtsConfig conf = defaultRtsConfig; 62 | conf.rts_opts_enabled = RtsOptsAll; 63 | hs_init_ghc(&hsargc, &pargv, conf); 64 | 65 | weechat_plugin = plugin; 66 | keyweeInit(); 67 | return WEECHAT_RC_OK; 68 | } 69 | 70 | int 71 | weechat_plugin_end (struct t_weechat_plugin *plugin) 72 | { 73 | hs_exit(); 74 | return WEECHAT_RC_OK; 75 | } 76 | -------------------------------------------------------------------------------- /cbits/keywee.h: -------------------------------------------------------------------------------- 1 | #ifndef PLUGIN_KEYWEE_H 2 | #define PLUGIN_KEYWEE_H 3 | 4 | #include 5 | 6 | #define weechat_plugin weechat_keywee_plugin 7 | 8 | extern struct t_weechat_plugin *weechat_plugin; 9 | 10 | int 11 | my_input_cb (const void *pointer, void *data, 12 | struct t_gui_buffer *buffer, const char *input_data); 13 | 14 | int 15 | my_close_cb (const void *pointer, void *data, struct t_gui_buffer *buffer); 16 | 17 | #endif /* PLUGIN_KEYWEE_H */ 18 | -------------------------------------------------------------------------------- /cbits/weechat/weechat-plugin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * weechat-plugin.h - header to compile WeeChat plugins 3 | * 4 | * Copyright (C) 2003-2018 Sébastien Helleu 5 | * 6 | * This file is part of WeeChat, the extensible chat client. 7 | * 8 | * WeeChat 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 3 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * WeeChat 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 WeeChat. If not, see . 20 | */ 21 | 22 | #ifndef WEECHAT_WEECHAT_PLUGIN_H 23 | #define WEECHAT_WEECHAT_PLUGIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif /* __cplusplus */ 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | /* some systems like GNU/Hurd do not define PATH_MAX */ 35 | #ifndef PATH_MAX 36 | #define PATH_MAX 4096 37 | #endif /* PATH_MAX */ 38 | 39 | struct t_config_option; 40 | struct t_config_section; 41 | struct t_config_file; 42 | struct t_gui_window; 43 | struct t_gui_buffer; 44 | struct t_gui_bar; 45 | struct t_gui_bar_item; 46 | struct t_gui_bar_window; 47 | struct t_gui_completion; 48 | struct t_gui_nick; 49 | struct t_gui_nick_group; 50 | struct t_infolist; 51 | struct t_infolist_item; 52 | struct t_upgrade_file; 53 | struct t_weelist; 54 | struct t_weelist_item; 55 | struct t_arraylist; 56 | struct t_hashtable; 57 | struct t_hdata; 58 | struct timeval; 59 | 60 | /* 61 | * IMPORTANT NOTE for WeeChat developers: if you update, add or remove 62 | * some functions in this file, then please update API version below. 63 | */ 64 | 65 | /* 66 | * API version (used to check that plugin has same API and can be loaded): 67 | * please change the date with current one; for a second change at same 68 | * date, increment the 01, otherwise please keep 01. 69 | */ 70 | #define WEECHAT_PLUGIN_API_VERSION "20180520-01" 71 | 72 | /* macros for defining plugin infos */ 73 | #define WEECHAT_PLUGIN_NAME(__name) \ 74 | char weechat_plugin_name[] = __name; \ 75 | char weechat_plugin_api_version[] = WEECHAT_PLUGIN_API_VERSION; 76 | #define WEECHAT_PLUGIN_AUTHOR(__author) \ 77 | char weechat_plugin_author[] = __author; 78 | #define WEECHAT_PLUGIN_DESCRIPTION(__desc) \ 79 | char weechat_plugin_description[] = __desc; 80 | #define WEECHAT_PLUGIN_VERSION(__version) \ 81 | char weechat_plugin_version[] = __version; 82 | #define WEECHAT_PLUGIN_LICENSE(__license) \ 83 | char weechat_plugin_license[] = __license; 84 | #define WEECHAT_PLUGIN_PRIORITY(__priority) \ 85 | int weechat_plugin_priority = __priority; 86 | 87 | /* return codes for plugin functions */ 88 | #define WEECHAT_RC_OK 0 89 | #define WEECHAT_RC_OK_EAT 1 90 | #define WEECHAT_RC_ERROR -1 91 | 92 | /* return codes for config read functions/callbacks */ 93 | #define WEECHAT_CONFIG_READ_OK 0 94 | #define WEECHAT_CONFIG_READ_MEMORY_ERROR -1 95 | #define WEECHAT_CONFIG_READ_FILE_NOT_FOUND -2 96 | 97 | /* return codes for config write functions/callbacks */ 98 | #define WEECHAT_CONFIG_WRITE_OK 0 99 | #define WEECHAT_CONFIG_WRITE_ERROR -1 100 | #define WEECHAT_CONFIG_WRITE_MEMORY_ERROR -2 101 | 102 | /* null value for option */ 103 | #define WEECHAT_CONFIG_OPTION_NULL "null" 104 | 105 | /* return codes for config option set */ 106 | #define WEECHAT_CONFIG_OPTION_SET_OK_CHANGED 2 107 | #define WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE 1 108 | #define WEECHAT_CONFIG_OPTION_SET_ERROR 0 109 | #define WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND -1 110 | 111 | /* return codes for config option unset */ 112 | #define WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET 0 113 | #define WEECHAT_CONFIG_OPTION_UNSET_OK_RESET 1 114 | #define WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED 2 115 | #define WEECHAT_CONFIG_OPTION_UNSET_ERROR -1 116 | 117 | /* list management (order of elements) */ 118 | #define WEECHAT_LIST_POS_SORT "sort" 119 | #define WEECHAT_LIST_POS_BEGINNING "beginning" 120 | #define WEECHAT_LIST_POS_END "end" 121 | 122 | /* type for keys and values in hashtable */ 123 | #define WEECHAT_HASHTABLE_INTEGER "integer" 124 | #define WEECHAT_HASHTABLE_STRING "string" 125 | #define WEECHAT_HASHTABLE_POINTER "pointer" 126 | #define WEECHAT_HASHTABLE_BUFFER "buffer" 127 | #define WEECHAT_HASHTABLE_TIME "time" 128 | 129 | /* types for hdata */ 130 | #define WEECHAT_HDATA_OTHER 0 131 | #define WEECHAT_HDATA_CHAR 1 132 | #define WEECHAT_HDATA_INTEGER 2 133 | #define WEECHAT_HDATA_LONG 3 134 | #define WEECHAT_HDATA_STRING 4 135 | #define WEECHAT_HDATA_POINTER 5 136 | #define WEECHAT_HDATA_TIME 6 137 | #define WEECHAT_HDATA_HASHTABLE 7 138 | #define WEECHAT_HDATA_SHARED_STRING 8 139 | 140 | /* flags for hdata lists */ 141 | #define WEECHAT_HDATA_LIST_CHECK_POINTERS 1 142 | 143 | /* buffer hotlist */ 144 | #define WEECHAT_HOTLIST_LOW "0" 145 | #define WEECHAT_HOTLIST_MESSAGE "1" 146 | #define WEECHAT_HOTLIST_PRIVATE "2" 147 | #define WEECHAT_HOTLIST_HIGHLIGHT "3" 148 | 149 | /* 150 | * process return code (for callback): 151 | * if >= 0, the process ended and it's return code of command 152 | * if -1, the process is still running 153 | * if -2, the process ended with an error 154 | * if -3, the callback is called in the child process (exec of function) 155 | * (note: the return code -3 is NEVER sent to script plugins, 156 | * it can be used only in C API) 157 | */ 158 | #define WEECHAT_HOOK_PROCESS_RUNNING -1 159 | #define WEECHAT_HOOK_PROCESS_ERROR -2 160 | #define WEECHAT_HOOK_PROCESS_CHILD -3 161 | 162 | /* connect status for connection hooked */ 163 | #define WEECHAT_HOOK_CONNECT_OK 0 164 | #define WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND 1 165 | #define WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND 2 166 | #define WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED 3 167 | #define WEECHAT_HOOK_CONNECT_PROXY_ERROR 4 168 | #define WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR 5 169 | #define WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR 6 170 | #define WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR 7 171 | #define WEECHAT_HOOK_CONNECT_MEMORY_ERROR 8 172 | #define WEECHAT_HOOK_CONNECT_TIMEOUT 9 173 | #define WEECHAT_HOOK_CONNECT_SOCKET_ERROR 10 174 | 175 | /* action for gnutls callback: verify or set certificate */ 176 | #define WEECHAT_HOOK_CONNECT_GNUTLS_CB_VERIFY_CERT 0 177 | #define WEECHAT_HOOK_CONNECT_GNUTLS_CB_SET_CERT 1 178 | 179 | /* type of data for signal hooked */ 180 | #define WEECHAT_HOOK_SIGNAL_STRING "string" 181 | #define WEECHAT_HOOK_SIGNAL_INT "int" 182 | #define WEECHAT_HOOK_SIGNAL_POINTER "pointer" 183 | 184 | /* macro to format string with variable args, using dynamic buffer size */ 185 | #define weechat_va_format(__format) \ 186 | va_list argptr; \ 187 | int vaa_size, vaa_num; \ 188 | char *vbuffer, *vaa_buffer2; \ 189 | vaa_size = 1024; \ 190 | vbuffer = malloc (vaa_size); \ 191 | if (vbuffer) \ 192 | { \ 193 | while (1) \ 194 | { \ 195 | va_start (argptr, __format); \ 196 | vaa_num = vsnprintf (vbuffer, vaa_size, __format, argptr); \ 197 | va_end (argptr); \ 198 | if ((vaa_num >= 0) && (vaa_num < vaa_size)) \ 199 | break; \ 200 | vaa_size = (vaa_num >= 0) ? vaa_num + 1 : vaa_size * 2; \ 201 | vaa_buffer2 = realloc (vbuffer, vaa_size); \ 202 | if (!vaa_buffer2) \ 203 | { \ 204 | free (vbuffer); \ 205 | vbuffer = NULL; \ 206 | break; \ 207 | } \ 208 | vbuffer = vaa_buffer2; \ 209 | } \ 210 | } 211 | 212 | /* 213 | * macro to return error in case of missing arguments in callback of 214 | * hook_command 215 | */ 216 | #define WEECHAT_COMMAND_MIN_ARGS(__min_args, __option) \ 217 | if (argc < __min_args) \ 218 | { \ 219 | weechat_printf_date_tags ( \ 220 | NULL, 0, "no_filter", \ 221 | _("%sToo few arguments for command \"%s%s%s\" " \ 222 | "(help on command: /help %s)"), \ 223 | weechat_prefix ("error"), \ 224 | argv[0], \ 225 | (__option && __option[0]) ? " " : "", \ 226 | (__option && __option[0]) ? __option : "", \ 227 | argv[0] + 1); \ 228 | return WEECHAT_RC_ERROR; \ 229 | } 230 | 231 | /* macro to return error in callback of hook_command */ 232 | #define WEECHAT_COMMAND_ERROR \ 233 | { \ 234 | weechat_printf_date_tags ( \ 235 | NULL, 0, "no_filter", \ 236 | _("%sError with command \"%s\" " \ 237 | "(help on command: /help %s)"), \ 238 | weechat_prefix ("error"), \ 239 | argv_eol[0], \ 240 | argv[0] + 1); \ 241 | return WEECHAT_RC_ERROR; \ 242 | } 243 | 244 | struct t_weechat_plugin 245 | { 246 | /* plugin variables */ 247 | char *filename; /* name of plugin on disk */ 248 | void *handle; /* handle of plugin (given by dlopen)*/ 249 | char *name; /* short name */ 250 | char *description; /* description */ 251 | char *author; /* author */ 252 | char *version; /* plugin version */ 253 | char *license; /* license */ 254 | char *charset; /* charset used by plugin */ 255 | int priority; /* plugin priority (default is 1000) */ 256 | int initialized; /* plugin initialized? (init called) */ 257 | int debug; /* debug level for plugin (0=off) */ 258 | struct t_hashtable *variables; /* plugin custom variables */ 259 | struct t_weechat_plugin *prev_plugin; /* link to previous plugin */ 260 | struct t_weechat_plugin *next_plugin; /* link to next plugin */ 261 | 262 | /* 263 | * plugin functions (API) 264 | * WeeChat developers: if you add functions in API, update value of 265 | * constant WEECHAT_PLUGIN_API_VERSION 266 | */ 267 | 268 | /* plugins */ 269 | const char *(*plugin_get_name) (struct t_weechat_plugin *plugin); 270 | 271 | /* strings */ 272 | void (*charset_set) (struct t_weechat_plugin *plugin, const char *charset); 273 | char *(*iconv_to_internal) (const char *charset, const char *string); 274 | char *(*iconv_from_internal) (const char *charset, const char *string); 275 | const char *(*gettext) (const char *string); 276 | const char *(*ngettext) (const char *single, const char *plural, int count); 277 | char *(*strndup) (const char *string, int length); 278 | void (*string_tolower) (char *string); 279 | void (*string_toupper) (char *string); 280 | int (*strcasecmp) (const char *string1, const char *string2); 281 | int (*strcasecmp_range) (const char *string1, const char *string2, 282 | int range); 283 | int (*strncasecmp) (const char *string1, const char *string2, int max); 284 | int (*strncasecmp_range) (const char *string1, const char *string2, 285 | int max, int range); 286 | int (*strcmp_ignore_chars) (const char *string1, const char *string2, 287 | const char *chars_ignored, int case_sensitive); 288 | const char *(*strcasestr) (const char *string, const char *search); 289 | int (*strlen_screen) (const char *string); 290 | int (*string_match) (const char *string, const char *mask, 291 | int case_sensitive); 292 | char *(*string_replace) (const char *string, const char *search, 293 | const char *replace); 294 | char *(*string_expand_home) (const char *path); 295 | char *(*string_eval_path_home) (const char *path, 296 | struct t_hashtable *pointers, 297 | struct t_hashtable *extra_vars, 298 | struct t_hashtable *options); 299 | char *(*string_remove_quotes) (const char *string, const char *quotes); 300 | char *(*string_strip) (const char *string, int left, int right, 301 | const char *chars); 302 | char *(*string_convert_escaped_chars) (const char *string); 303 | char *(*string_mask_to_regex) (const char *mask); 304 | const char *(*string_regex_flags) (const char *regex, int default_flags, 305 | int *flags); 306 | int (*string_regcomp) (void *preg, const char *regex, int default_flags); 307 | int (*string_has_highlight) (const char *string, 308 | const char *highlight_words); 309 | int (*string_has_highlight_regex) (const char *string, const char *regex); 310 | char *(*string_replace_regex) (const char *string, void *regex, 311 | const char *replace, 312 | const char reference_char, 313 | char *(*callback)(void *data, 314 | const char *text), 315 | void *callback_data); 316 | char **(*string_split) (const char *string, const char *separators, 317 | int keep_eol, int num_items_max, int *num_items); 318 | char **(*string_split_shell) (const char *string, int *num_items); 319 | void (*string_free_split) (char **split_string); 320 | char *(*string_build_with_split_string) (const char **split_string, 321 | const char *separator); 322 | char **(*string_split_command) (const char *command, char separator); 323 | void (*string_free_split_command) (char **split_command); 324 | char *(*string_format_size) (unsigned long long size); 325 | char *(*string_remove_color) (const char *string, const char *replacement); 326 | void (*string_encode_base64) (const char *from, int length, char *to); 327 | int (*string_decode_base64) (const char *from, char *to); 328 | char *(*string_hex_dump) (const char *data, int data_size, 329 | int bytes_per_line, const char *prefix, 330 | const char *suffix); 331 | int (*string_is_command_char) (const char *string); 332 | const char *(*string_input_for_buffer) (const char *string); 333 | char *(*string_eval_expression )(const char *expr, 334 | struct t_hashtable *pointers, 335 | struct t_hashtable *extra_vars, 336 | struct t_hashtable *options); 337 | char **(*string_dyn_alloc) (int size_alloc); 338 | int (*string_dyn_copy) (char **string, const char *new_string); 339 | int (*string_dyn_concat) (char **string, const char *add); 340 | char *(*string_dyn_free) (char **string, int free_string); 341 | 342 | /* UTF-8 strings */ 343 | int (*utf8_has_8bits) (const char *string); 344 | int (*utf8_is_valid) (const char *string, int length, char **error); 345 | void (*utf8_normalize) (char *string, char replacement); 346 | const char *(*utf8_prev_char) (const char *string_start, 347 | const char *string); 348 | const char *(*utf8_next_char) (const char *string); 349 | int (*utf8_char_int) (const char *string); 350 | int (*utf8_char_size) (const char *string); 351 | int (*utf8_strlen) (const char *string); 352 | int (*utf8_strnlen) (const char *string, int bytes); 353 | int (*utf8_strlen_screen) (const char *string); 354 | int (*utf8_charcmp) (const char *string1, const char *string2); 355 | int (*utf8_charcasecmp) (const char *string1, const char *string2); 356 | int (*utf8_char_size_screen) (const char *string); 357 | const char *(*utf8_add_offset) (const char *string, int offset); 358 | int (*utf8_real_pos) (const char *string, int pos); 359 | int (*utf8_pos) (const char *string, int real_pos); 360 | char *(*utf8_strndup) (const char *string, int length); 361 | 362 | /* directories/files */ 363 | int (*mkdir_home) (const char *directory, int mode); 364 | int (*mkdir) (const char *directory, int mode); 365 | int (*mkdir_parents) (const char *directory, int mode); 366 | void (*exec_on_files) (const char *directory, int recurse_subdirs, 367 | int hidden_files, 368 | void (*callback)(void *data, const char *filename), 369 | void *callback_data); 370 | char *(*file_get_content) (const char *filename); 371 | 372 | /* util */ 373 | int (*util_timeval_cmp) (struct timeval *tv1, struct timeval *tv2); 374 | long long (*util_timeval_diff) (struct timeval *tv1, struct timeval *tv2); 375 | void (*util_timeval_add) (struct timeval *tv, long long interval); 376 | const char *(*util_get_time_string) (const time_t *date); 377 | int (*util_version_number) (const char *version); 378 | 379 | /* sorted lists */ 380 | struct t_weelist *(*list_new) (); 381 | struct t_weelist_item *(*list_add) (struct t_weelist *weelist, 382 | const char *data, 383 | const char *where, 384 | void *user_data); 385 | struct t_weelist_item *(*list_search) (struct t_weelist *weelist, 386 | const char *data); 387 | int (*list_search_pos) (struct t_weelist *weelist, 388 | const char *data); 389 | struct t_weelist_item *(*list_casesearch) (struct t_weelist *weelist, 390 | const char *data); 391 | int (*list_casesearch_pos) (struct t_weelist *weelist, 392 | const char *data); 393 | struct t_weelist_item *(*list_get) (struct t_weelist *weelist, 394 | int position); 395 | void (*list_set) (struct t_weelist_item *item, const char *value); 396 | struct t_weelist_item *(*list_next) (struct t_weelist_item *item); 397 | struct t_weelist_item *(*list_prev) (struct t_weelist_item *item); 398 | const char *(*list_string) (struct t_weelist_item *item); 399 | int (*list_size) (struct t_weelist *weelist); 400 | void (*list_remove) (struct t_weelist *weelist, 401 | struct t_weelist_item *item); 402 | void (*list_remove_all) (struct t_weelist *weelist); 403 | void (*list_free) (struct t_weelist *weelist); 404 | 405 | /* array lists */ 406 | struct t_arraylist *(*arraylist_new) (int initial_size, 407 | int sorted, 408 | int allow_duplicates, 409 | int (*callback_cmp)(void *data, 410 | struct t_arraylist *arraylist, 411 | void *pointer1, 412 | void *pointer2), 413 | void *callback_cmp_data, 414 | void (*callback_free)(void *data, 415 | struct t_arraylist *arraylist, 416 | void *pointer), 417 | void *callback_free_data); 418 | int (*arraylist_size) (struct t_arraylist *arraylist); 419 | void *(*arraylist_get) (struct t_arraylist *arraylist, int index); 420 | void *(*arraylist_search) (struct t_arraylist *arraylist, void *pointer, 421 | int *index, int *index_insert); 422 | int (*arraylist_insert) (struct t_arraylist *arraylist, int index, 423 | void *pointer); 424 | int (*arraylist_add) (struct t_arraylist *arraylist, void *pointer); 425 | int (*arraylist_remove) (struct t_arraylist *arraylist, int index); 426 | int (*arraylist_clear) (struct t_arraylist *arraylist); 427 | void (*arraylist_free) (struct t_arraylist *arraylist); 428 | 429 | /* hash tables */ 430 | struct t_hashtable *(*hashtable_new) (int size, 431 | const char *type_keys, 432 | const char *type_values, 433 | unsigned long long (*callback_hash_key)(struct t_hashtable *hashtable, 434 | const void *key), 435 | int (*callback_keycmp)(struct t_hashtable *hashtable, 436 | const void *key1, 437 | const void *key2)); 438 | struct t_hashtable_item *(*hashtable_set_with_size) (struct t_hashtable *hashtable, 439 | const void *key, 440 | int key_size, 441 | const void *value, 442 | int value_size); 443 | struct t_hashtable_item *(*hashtable_set) (struct t_hashtable *hashtable, 444 | const void *key, 445 | const void *value); 446 | void *(*hashtable_get) (struct t_hashtable *hashtable, const void *key); 447 | int (*hashtable_has_key) (struct t_hashtable *hashtable, const void *key); 448 | void (*hashtable_map) (struct t_hashtable *hashtable, 449 | void (*callback_map) (void *data, 450 | struct t_hashtable *hashtable, 451 | const void *key, 452 | const void *value), 453 | void *callback_map_data); 454 | void (*hashtable_map_string) (struct t_hashtable *hashtable, 455 | void (*callback_map) (void *data, 456 | struct t_hashtable *hashtable, 457 | const char *key, 458 | const char *value), 459 | void *callback_map_data); 460 | struct t_hashtable *(*hashtable_dup) (struct t_hashtable *hashtable); 461 | int (*hashtable_get_integer) (struct t_hashtable *hashtable, 462 | const char *property); 463 | const char *(*hashtable_get_string) (struct t_hashtable *hashtable, 464 | const char *property); 465 | void (*hashtable_set_pointer) (struct t_hashtable *hashtable, 466 | const char *property, 467 | void *pointer); 468 | int (*hashtable_add_to_infolist) (struct t_hashtable *hashtable, 469 | struct t_infolist_item *infolist_item, 470 | const char *prefix); 471 | int (*hashtable_add_from_infolist) (struct t_hashtable *hashtable, 472 | struct t_infolist *infolist, 473 | const char *prefix); 474 | void (*hashtable_remove) (struct t_hashtable *hashtable, const void *key); 475 | void (*hashtable_remove_all) (struct t_hashtable *hashtable); 476 | void (*hashtable_free) (struct t_hashtable *hashtable); 477 | 478 | /* config files */ 479 | struct t_config_file *(*config_new) (struct t_weechat_plugin *plugin, 480 | const char *name, 481 | int (*callback_reload)(const void *pointer, 482 | void *data, 483 | struct t_config_file *config_file), 484 | const void *callback_reload_pointer, 485 | void *callback_reload_data); 486 | struct t_config_section *(*config_new_section) (struct t_config_file *config_file, 487 | const char *name, 488 | int user_can_add_options, 489 | int user_can_delete_options, 490 | int (*callback_read)(const void *pointer, 491 | void *data, 492 | struct t_config_file *config_file, 493 | struct t_config_section *section, 494 | const char *option_name, 495 | const char *value), 496 | const void *callback_read_pointer, 497 | void *callback_read_data, 498 | int (*callback_write)(const void *pointer, 499 | void *data, 500 | struct t_config_file *config_file, 501 | const char *section_name), 502 | const void *callback_write_pointer, 503 | void *callback_write_data, 504 | int (*callback_write_default)(const void *pointer, 505 | void *data, 506 | struct t_config_file *config_file, 507 | const char *section_name), 508 | const void *callback_write_default_pointer, 509 | void *callback_write_default_data, 510 | int (*callback_create_option)(const void *pointer, 511 | void *data, 512 | struct t_config_file *config_file, 513 | struct t_config_section *section, 514 | const char *option_name, 515 | const char *value), 516 | const void *callback_create_option_pointer, 517 | void *callback_create_option_data, 518 | int (*callback_delete_option)(const void *pointer, 519 | void *data, 520 | struct t_config_file *config_file, 521 | struct t_config_section *section, 522 | struct t_config_option *option), 523 | const void *callback_delete_option_pointer, 524 | void *callback_delete_option_data); 525 | struct t_config_section *(*config_search_section) (struct t_config_file *config_file, 526 | const char *section_name); 527 | struct t_config_option *(*config_new_option) (struct t_config_file *config_file, 528 | struct t_config_section *section, 529 | const char *name, 530 | const char *type, 531 | const char *description, 532 | const char *string_values, 533 | int min, 534 | int max, 535 | const char *default_value, 536 | const char *value, 537 | int null_value_allowed, 538 | int (*callback_check_value)(const void *pointer, 539 | void *data, 540 | struct t_config_option *option, 541 | const char *value), 542 | const void *callback_check_value_pointer, 543 | void *callback_check_value_data, 544 | void (*callback_change)(const void *pointer, 545 | void *data, 546 | struct t_config_option *option), 547 | const void *callback_change_pointer, 548 | void *callback_change_data, 549 | void (*callback_delete)(const void *pointer, 550 | void *data, 551 | struct t_config_option *option), 552 | const void *callback_delete_pointer, 553 | void *callback_delete_data); 554 | struct t_config_option *(*config_search_option) (struct t_config_file *config_file, 555 | struct t_config_section *section, 556 | const char *option_name); 557 | void (*config_search_section_option) (struct t_config_file *config_file, 558 | struct t_config_section *section, 559 | const char *option_name, 560 | struct t_config_section **section_found, 561 | struct t_config_option **option_found); 562 | void (*config_search_with_string) (const char *option_name, 563 | struct t_config_file **config_file, 564 | struct t_config_section **section, 565 | struct t_config_option **option, 566 | char **pos_option_name); 567 | int (*config_string_to_boolean) (const char *text); 568 | int (*config_option_reset) (struct t_config_option *option, 569 | int run_callback); 570 | int (*config_option_set) (struct t_config_option *option, 571 | const char *value, int run_callback); 572 | int (*config_option_set_null) (struct t_config_option *option, 573 | int run_callback); 574 | int (*config_option_unset) (struct t_config_option *option); 575 | void (*config_option_rename) (struct t_config_option *option, 576 | const char *new_name); 577 | const char *(*config_option_get_string) (struct t_config_option *option, 578 | const char *property); 579 | void *(*config_option_get_pointer) (struct t_config_option *option, 580 | const char *property); 581 | int (*config_option_is_null) (struct t_config_option *option); 582 | int (*config_option_default_is_null) (struct t_config_option *option); 583 | int (*config_boolean) (struct t_config_option *option); 584 | int (*config_boolean_default) (struct t_config_option *option); 585 | int (*config_integer) (struct t_config_option *option); 586 | int (*config_integer_default) (struct t_config_option *option); 587 | const char *(*config_string) (struct t_config_option *option); 588 | const char *(*config_string_default) (struct t_config_option *option); 589 | const char *(*config_color) (struct t_config_option *option); 590 | const char *(*config_color_default) (struct t_config_option *option); 591 | int (*config_write_option) (struct t_config_file *config_file, 592 | struct t_config_option *option); 593 | int (*config_write_line) (struct t_config_file *config_file, 594 | const char *option_name, 595 | const char *value, ...); 596 | int (*config_write) (struct t_config_file *config_file); 597 | int (*config_read) (struct t_config_file *config_file); 598 | int (*config_reload) (struct t_config_file *config_file); 599 | void (*config_option_free) (struct t_config_option *option); 600 | void (*config_section_free_options) (struct t_config_section *section); 601 | void (*config_section_free) (struct t_config_section *section); 602 | void (*config_free) (struct t_config_file *config_file); 603 | struct t_config_option *(*config_get) (const char *option_name); 604 | const char *(*config_get_plugin) (struct t_weechat_plugin *plugin, 605 | const char *option_name); 606 | int (*config_is_set_plugin) (struct t_weechat_plugin *plugin, 607 | const char *option_name); 608 | int (*config_set_plugin) (struct t_weechat_plugin *plugin, 609 | const char *option_name, const char *value); 610 | void (*config_set_desc_plugin) (struct t_weechat_plugin *plugin, 611 | const char *option_name, 612 | const char *description); 613 | int (*config_unset_plugin) (struct t_weechat_plugin *plugin, 614 | const char *option_name); 615 | 616 | /* key bindings */ 617 | int (*key_bind) (const char *context, struct t_hashtable *keys); 618 | int (*key_unbind) (const char *context, const char *key); 619 | 620 | /* display */ 621 | const char *(*prefix) (const char *prefix); 622 | const char *(*color) (const char *color_name); 623 | void (*printf_date_tags) (struct t_gui_buffer *buffer, time_t date, 624 | const char *tags, const char *message, ...); 625 | void (*printf_y) (struct t_gui_buffer *buffer, int y, 626 | const char *message, ...); 627 | void (*log_printf) (const char *message, ...); 628 | 629 | /* hooks */ 630 | struct t_hook *(*hook_command) (struct t_weechat_plugin *plugin, 631 | const char *command, 632 | const char *description, 633 | const char *args, 634 | const char *args_description, 635 | const char *completion, 636 | int (*callback)(const void *pointer, 637 | void *data, 638 | struct t_gui_buffer *buffer, 639 | int argc, char **argv, 640 | char **argv_eol), 641 | const void *callback_pointer, 642 | void *callback_data); 643 | struct t_hook *(*hook_command_run) (struct t_weechat_plugin *plugin, 644 | const char *command, 645 | int (*callback)(const void *pointer, 646 | void *data, 647 | struct t_gui_buffer *buffer, 648 | const char *command), 649 | const void *callback_pointer, 650 | void *callback_data); 651 | struct t_hook *(*hook_timer) (struct t_weechat_plugin *plugin, 652 | long interval, 653 | int align_second, 654 | int max_calls, 655 | int (*callback)(const void *pointer, 656 | void *data, 657 | int remaining_calls), 658 | const void *callback_pointer, 659 | void *callback_data); 660 | struct t_hook *(*hook_fd) (struct t_weechat_plugin *plugin, 661 | int fd, 662 | int flag_read, 663 | int flag_write, 664 | int flag_exception, 665 | int (*callback)(const void *pointer, 666 | void *data, 667 | int fd), 668 | const void *callback_pointer, 669 | void *callback_data); 670 | struct t_hook *(*hook_process) (struct t_weechat_plugin *plugin, 671 | const char *command, 672 | int timeout, 673 | int (*callback)(const void *pointer, 674 | void *data, 675 | const char *command, 676 | int return_code, 677 | const char *out, 678 | const char *err), 679 | const void *callback_pointer, 680 | void *callback_data); 681 | struct t_hook *(*hook_process_hashtable) (struct t_weechat_plugin *plugin, 682 | const char *command, 683 | struct t_hashtable *options, 684 | int timeout, 685 | int (*callback)(const void *pointer, 686 | void *data, 687 | const char *command, 688 | int return_code, 689 | const char *out, 690 | const char *err), 691 | const void *callback_pointer, 692 | void *callback_data); 693 | struct t_hook *(*hook_connect) (struct t_weechat_plugin *plugin, 694 | const char *proxy, 695 | const char *address, 696 | int port, 697 | int ipv6, 698 | int retry, 699 | void *gnutls_sess, void *gnutls_cb, 700 | int gnutls_dhkey_size, 701 | const char *gnutls_priorities, 702 | const char *local_hostname, 703 | int (*callback)(const void *pointer, 704 | void *data, 705 | int status, 706 | int gnutls_rc, 707 | int sock, 708 | const char *error, 709 | const char *ip_address), 710 | const void *callback_pointer, 711 | void *callback_data); 712 | struct t_hook *(*hook_print) (struct t_weechat_plugin *plugin, 713 | struct t_gui_buffer *buffer, 714 | const char *tags, 715 | const char *message, 716 | int strip_colors, 717 | int (*callback)(const void *pointer, 718 | void *data, 719 | struct t_gui_buffer *buffer, 720 | time_t date, 721 | int tags_count, 722 | const char **tags, 723 | int displayed, 724 | int highlight, 725 | const char *prefix, 726 | const char *message), 727 | const void *callback_pointer, 728 | void *callback_data); 729 | struct t_hook *(*hook_signal) (struct t_weechat_plugin *plugin, 730 | const char *signal, 731 | int (*callback)(const void *pointer, 732 | void *data, 733 | const char *signal, 734 | const char *type_data, 735 | void *signal_data), 736 | const void *callback_pointer, 737 | void *callback_data); 738 | int (*hook_signal_send) (const char *signal, const char *type_data, 739 | void *signal_data); 740 | struct t_hook *(*hook_hsignal) (struct t_weechat_plugin *plugin, 741 | const char *signal, 742 | int (*callback)(const void *pointer, 743 | void *data, 744 | const char *signal, 745 | struct t_hashtable *hashtable), 746 | const void *callback_pointer, 747 | void *callback_data); 748 | int (*hook_hsignal_send) (const char *signal, 749 | struct t_hashtable *hashtable); 750 | struct t_hook *(*hook_config) (struct t_weechat_plugin *plugin, 751 | const char *option, 752 | int (*callback)(const void *pointer, 753 | void *data, 754 | const char *option, 755 | const char *value), 756 | const void *callback_pointer, 757 | void *callback_data); 758 | struct t_hook *(*hook_completion) (struct t_weechat_plugin *plugin, 759 | const char *completion_item, 760 | const char *description, 761 | int (*callback)(const void *pointer, 762 | void *data, 763 | const char *completion_item, 764 | struct t_gui_buffer *buffer, 765 | struct t_gui_completion *completion), 766 | const void *callback_pointer, 767 | void *callback_data); 768 | const char *(*hook_completion_get_string) (struct t_gui_completion *completion, 769 | const char *property); 770 | void (*hook_completion_list_add) (struct t_gui_completion *completion, 771 | const char *word, 772 | int nick_completion, 773 | const char *where); 774 | struct t_hook *(*hook_modifier) (struct t_weechat_plugin *plugin, 775 | const char *modifier, 776 | char *(*callback)(const void *pointer, 777 | void *data, 778 | const char *modifier, 779 | const char *modifier_data, 780 | const char *string), 781 | const void *callback_pointer, 782 | void *callback_data); 783 | char *(*hook_modifier_exec) (struct t_weechat_plugin *plugin, 784 | const char *modifier, 785 | const char *modifier_data, 786 | const char *string); 787 | struct t_hook *(*hook_info) (struct t_weechat_plugin *plugin, 788 | const char *info_name, 789 | const char *description, 790 | const char *args_description, 791 | const char *(*callback)(const void *pointer, 792 | void *data, 793 | const char *info_name, 794 | const char *arguments), 795 | const void *callback_pointer, 796 | void *callback_data); 797 | struct t_hook *(*hook_info_hashtable) (struct t_weechat_plugin *plugin, 798 | const char *info_name, 799 | const char *description, 800 | const char *args_description, 801 | const char *output_description, 802 | struct t_hashtable *(*callback)(const void *pointer, 803 | void *data, 804 | const char *info_name, 805 | struct t_hashtable *hashtable), 806 | const void *callback_pointer, 807 | void *callback_data); 808 | struct t_hook *(*hook_infolist) (struct t_weechat_plugin *plugin, 809 | const char *infolist_name, 810 | const char *description, 811 | const char *pointer_description, 812 | const char *args_description, 813 | struct t_infolist *(*callback)(const void *cb_pointer, 814 | void *data, 815 | const char *infolist_name, 816 | void *obj_pointer, 817 | const char *arguments), 818 | const void *callback_pointer, 819 | void *callback_data); 820 | struct t_hook *(*hook_hdata) (struct t_weechat_plugin *plugin, 821 | const char *hdata_name, 822 | const char *description, 823 | struct t_hdata *(*callback)(const void *pointer, 824 | void *data, 825 | const char *hdata_name), 826 | const void *callback_pointer, 827 | void *callback_data); 828 | struct t_hook *(*hook_focus) (struct t_weechat_plugin *plugin, 829 | const char *area, 830 | struct t_hashtable *(*callback)(const void *pointer, 831 | void *data, 832 | struct t_hashtable *info), 833 | const void *callback_pointer, 834 | void *callback_data); 835 | void (*hook_set) (struct t_hook *hook, const char *property, 836 | const char *value); 837 | void (*unhook) (struct t_hook *hook); 838 | void (*unhook_all) (struct t_weechat_plugin *plugin, 839 | const char *subplugin); 840 | 841 | /* buffers */ 842 | struct t_gui_buffer *(*buffer_new) (struct t_weechat_plugin *plugin, 843 | const char *name, 844 | int (*input_callback)(const void *pointer, 845 | void *data, 846 | struct t_gui_buffer *buffer, 847 | const char *input_data), 848 | const void *input_callback_pointer, 849 | void *input_callback_data, 850 | int (*close_callback)(const void *pointer, 851 | void *data, 852 | struct t_gui_buffer *buffer), 853 | const void *close_callback_pointer, 854 | void *close_callback_data); 855 | struct t_gui_buffer *(*buffer_search) (const char *plugin, const char *name); 856 | struct t_gui_buffer *(*buffer_search_main) (); 857 | void (*buffer_clear) (struct t_gui_buffer *buffer); 858 | void (*buffer_close) (struct t_gui_buffer *buffer); 859 | void (*buffer_merge) (struct t_gui_buffer *buffer, 860 | struct t_gui_buffer *target_buffer); 861 | void (*buffer_unmerge) (struct t_gui_buffer *buffer, int number); 862 | int (*buffer_get_integer) (struct t_gui_buffer *buffer, 863 | const char *property); 864 | const char *(*buffer_get_string) (struct t_gui_buffer *buffer, 865 | const char *property); 866 | void *(*buffer_get_pointer) (struct t_gui_buffer *buffer, 867 | const char *property); 868 | void (*buffer_set) (struct t_gui_buffer *buffer, const char *property, 869 | const char *value); 870 | void (*buffer_set_pointer) (struct t_gui_buffer *buffer, 871 | const char *property, void *pointer); 872 | char *(*buffer_string_replace_local_var) (struct t_gui_buffer *buffer, 873 | const char *string); 874 | int (*buffer_match_list) (struct t_gui_buffer *buffer, const char *string); 875 | 876 | /* windows */ 877 | struct t_gui_window *(*window_search_with_buffer) (struct t_gui_buffer *buffer); 878 | int (*window_get_integer) (struct t_gui_window *window, 879 | const char *property); 880 | const char *(*window_get_string) (struct t_gui_window *window, 881 | const char *property); 882 | void *(*window_get_pointer) (struct t_gui_window *window, 883 | const char *property); 884 | void (*window_set_title) (const char *title); 885 | 886 | /* nicklist */ 887 | struct t_gui_nick_group *(*nicklist_add_group) (struct t_gui_buffer *buffer, 888 | struct t_gui_nick_group *parent_group, 889 | const char *name, 890 | const char *color, 891 | int visible); 892 | struct t_gui_nick_group *(*nicklist_search_group) (struct t_gui_buffer *buffer, 893 | struct t_gui_nick_group *from_group, 894 | const char *name); 895 | struct t_gui_nick *(*nicklist_add_nick) (struct t_gui_buffer *buffer, 896 | struct t_gui_nick_group *group, 897 | const char *name, 898 | const char *color, 899 | const char *prefix, 900 | const char *prefix_color, 901 | int visible); 902 | struct t_gui_nick *(*nicklist_search_nick) (struct t_gui_buffer *buffer, 903 | struct t_gui_nick_group *from_group, 904 | const char *name); 905 | void (*nicklist_remove_group) (struct t_gui_buffer *buffer, 906 | struct t_gui_nick_group *group); 907 | void (*nicklist_remove_nick) (struct t_gui_buffer *buffer, 908 | struct t_gui_nick *nick); 909 | void (*nicklist_remove_all) (struct t_gui_buffer *buffer); 910 | void (*nicklist_get_next_item) (struct t_gui_buffer *buffer, 911 | struct t_gui_nick_group **group, 912 | struct t_gui_nick **nick); 913 | int (*nicklist_group_get_integer) (struct t_gui_buffer *buffer, 914 | struct t_gui_nick_group *group, 915 | const char *property); 916 | const char *(*nicklist_group_get_string) (struct t_gui_buffer *buffer, 917 | struct t_gui_nick_group *group, 918 | const char *property); 919 | void *(*nicklist_group_get_pointer) (struct t_gui_buffer *buffer, 920 | struct t_gui_nick_group *group, 921 | const char *property); 922 | void (*nicklist_group_set) (struct t_gui_buffer *buffer, 923 | struct t_gui_nick_group *group, 924 | const char *property, const char *value); 925 | int (*nicklist_nick_get_integer) (struct t_gui_buffer *buffer, 926 | struct t_gui_nick *nick, 927 | const char *property); 928 | const char *(*nicklist_nick_get_string) (struct t_gui_buffer *buffer, 929 | struct t_gui_nick *nick, 930 | const char *property); 931 | void *(*nicklist_nick_get_pointer) (struct t_gui_buffer *buffer, 932 | struct t_gui_nick *nick, 933 | const char *property); 934 | void (*nicklist_nick_set) (struct t_gui_buffer *buffer, 935 | struct t_gui_nick *nick, 936 | const char *property, const char *value); 937 | 938 | /* bars */ 939 | struct t_gui_bar_item *(*bar_item_search) (const char *name); 940 | struct t_gui_bar_item *(*bar_item_new) (struct t_weechat_plugin *plugin, 941 | const char *name, 942 | char *(*build_callback)(const void *pointer, 943 | void *data, 944 | struct t_gui_bar_item *item, 945 | struct t_gui_window *window, 946 | struct t_gui_buffer *buffer, 947 | struct t_hashtable *extra_info), 948 | const void *build_callback_pointer, 949 | void *build_callback_data); 950 | void (*bar_item_update) (const char *name); 951 | void (*bar_item_remove) (struct t_gui_bar_item *item); 952 | struct t_gui_bar *(*bar_search) (const char *name); 953 | struct t_gui_bar *(*bar_new) (const char *name, 954 | const char *hidden, 955 | const char *priority, 956 | const char *type, 957 | const char *condition, 958 | const char *position, 959 | const char *filling_top_bottom, 960 | const char *filling_left_right, 961 | const char *size, 962 | const char *size_max, 963 | const char *color_fg, 964 | const char *color_delim, 965 | const char *color_bg, 966 | const char *separator, 967 | const char *items); 968 | int (*bar_set) (struct t_gui_bar *bar, const char *property, 969 | const char *value); 970 | void (*bar_update) (const char *name); 971 | void (*bar_remove) (struct t_gui_bar *bar); 972 | 973 | /* command */ 974 | int (*command) (struct t_weechat_plugin *plugin, 975 | struct t_gui_buffer *buffer, const char *command); 976 | 977 | /* network */ 978 | int (*network_pass_proxy) (const char *proxy, int sock, 979 | const char *address, int port); 980 | int (*network_connect_to) (const char *proxy, 981 | struct sockaddr *address, 982 | socklen_t address_length); 983 | 984 | /* infos */ 985 | const char *(*info_get) (struct t_weechat_plugin *plugin, 986 | const char *info_name, 987 | const char *arguments); 988 | struct t_hashtable *(*info_get_hashtable) (struct t_weechat_plugin *plugin, 989 | const char *info_name, 990 | struct t_hashtable *hashtable); 991 | 992 | /* infolists */ 993 | struct t_infolist *(*infolist_new) (struct t_weechat_plugin *plugin); 994 | struct t_infolist_item *(*infolist_new_item) (struct t_infolist *infolist); 995 | struct t_infolist_var *(*infolist_new_var_integer) (struct t_infolist_item *item, 996 | const char *name, 997 | int value); 998 | struct t_infolist_var *(*infolist_new_var_string) (struct t_infolist_item *item, 999 | const char *name, 1000 | const char *value); 1001 | struct t_infolist_var *(*infolist_new_var_pointer) (struct t_infolist_item *item, 1002 | const char *name, 1003 | void *pointer); 1004 | struct t_infolist_var *(*infolist_new_var_buffer) (struct t_infolist_item *item, 1005 | const char *name, 1006 | void *pointer, 1007 | int size); 1008 | struct t_infolist_var *(*infolist_new_var_time) (struct t_infolist_item *item, 1009 | const char *name, 1010 | time_t time); 1011 | struct t_infolist_var *(*infolist_search_var) (struct t_infolist *infolist, 1012 | const char *name); 1013 | struct t_infolist *(*infolist_get) (struct t_weechat_plugin *plugin, 1014 | const char *infolist_name, 1015 | void *pointer, 1016 | const char *arguments); 1017 | int (*infolist_next) (struct t_infolist *infolist); 1018 | int (*infolist_prev) (struct t_infolist *infolist); 1019 | void (*infolist_reset_item_cursor) (struct t_infolist *infolist); 1020 | const char *(*infolist_fields) (struct t_infolist *infolist); 1021 | int (*infolist_integer) (struct t_infolist *infolist, const char *var); 1022 | const char *(*infolist_string) (struct t_infolist *infolist, const char *var); 1023 | void *(*infolist_pointer) (struct t_infolist *infolist, const char *var); 1024 | void *(*infolist_buffer) (struct t_infolist *infolist, const char *var, 1025 | int *size); 1026 | time_t (*infolist_time) (struct t_infolist *infolist, const char *var); 1027 | void (*infolist_free) (struct t_infolist *infolist); 1028 | 1029 | /* hdata */ 1030 | struct t_hdata *(*hdata_new) (struct t_weechat_plugin *plugin, 1031 | const char *hdata_name, const char *var_prev, 1032 | const char *var_next, 1033 | int create_allowed, int delete_allowed, 1034 | int (*callback_update)(void *data, 1035 | struct t_hdata *hdata, 1036 | void *pointer, 1037 | struct t_hashtable *hashtable), 1038 | void *callback_update_data); 1039 | void (*hdata_new_var) (struct t_hdata *hdata, const char *name, int offset, 1040 | int type, int update_allowed, const char *array_size, 1041 | const char *hdata_name); 1042 | void (*hdata_new_list) (struct t_hdata *hdata, const char *name, 1043 | void *pointer, int flags); 1044 | struct t_hdata *(*hdata_get) (struct t_weechat_plugin *plugin, 1045 | const char *hdata_name); 1046 | int (*hdata_get_var_offset) (struct t_hdata *hdata, const char *name); 1047 | int (*hdata_get_var_type) (struct t_hdata *hdata, const char *name); 1048 | const char *(*hdata_get_var_type_string) (struct t_hdata *hdata, 1049 | const char *name); 1050 | int (*hdata_get_var_array_size) (struct t_hdata *hdata, void *pointer, 1051 | const char *name); 1052 | const char *(*hdata_get_var_array_size_string) (struct t_hdata *hdata, 1053 | void *pointer, 1054 | const char *name); 1055 | const char *(*hdata_get_var_hdata) (struct t_hdata *hdata, 1056 | const char *name); 1057 | void *(*hdata_get_var) (struct t_hdata *hdata, void *pointer, 1058 | const char *name); 1059 | void *(*hdata_get_var_at_offset) (struct t_hdata *hdata, void *pointer, 1060 | int offset); 1061 | void *(*hdata_get_list) (struct t_hdata *hdata, const char *name); 1062 | int (*hdata_check_pointer) (struct t_hdata *hdata, void *list, 1063 | void *pointer); 1064 | void *(*hdata_move) (struct t_hdata *hdata, void *pointer, int count); 1065 | void *(*hdata_search) (struct t_hdata *hdata, void *pointer, 1066 | const char *search, int move); 1067 | char (*hdata_char) (struct t_hdata *hdata, void *pointer, 1068 | const char *name); 1069 | int (*hdata_integer) (struct t_hdata *hdata, void *pointer, 1070 | const char *name); 1071 | long (*hdata_long) (struct t_hdata *hdata, void *pointer, 1072 | const char *name); 1073 | const char *(*hdata_string) (struct t_hdata *hdata, void *pointer, 1074 | const char *name); 1075 | void *(*hdata_pointer) (struct t_hdata *hdata, void *pointer, 1076 | const char *name); 1077 | time_t (*hdata_time) (struct t_hdata *hdata, void *pointer, 1078 | const char *name); 1079 | struct t_hashtable *(*hdata_hashtable) (struct t_hdata *hdata, 1080 | void *pointer, const char *name); 1081 | int (*hdata_compare) (struct t_hdata *hdata, 1082 | void *pointer1, void *pointer2, const char *name, 1083 | int case_sensitive); 1084 | int (*hdata_set) (struct t_hdata *hdata, void *pointer, const char *name, 1085 | const char *value); 1086 | int (*hdata_update) (struct t_hdata *hdata, void *pointer, 1087 | struct t_hashtable *hashtable); 1088 | const char *(*hdata_get_string) (struct t_hdata *hdata, 1089 | const char *property); 1090 | 1091 | /* upgrade */ 1092 | struct t_upgrade_file *(*upgrade_new) (const char *filename, 1093 | int (*callback_read)(const void *pointer, 1094 | void *data, 1095 | struct t_upgrade_file *upgrade_file, 1096 | int object_id, 1097 | struct t_infolist *infolist), 1098 | const void *callback_read_pointer, 1099 | void *callback_read_data); 1100 | int (*upgrade_write_object) (struct t_upgrade_file *upgrade_file, 1101 | int object_id, 1102 | struct t_infolist *infolist); 1103 | int (*upgrade_read) (struct t_upgrade_file *upgrade_file); 1104 | void (*upgrade_close) (struct t_upgrade_file *upgrade_file); 1105 | }; 1106 | 1107 | extern int weechat_plugin_init (struct t_weechat_plugin *plugin, 1108 | int argc, char *argv[]); 1109 | extern int weechat_plugin_end (struct t_weechat_plugin *plugin); 1110 | 1111 | /* macros for easy call to plugin API */ 1112 | 1113 | /* plugins */ 1114 | #define weechat_plugin_get_name(__plugin) \ 1115 | (weechat_plugin->plugin_get_name)(__plugin) 1116 | 1117 | /* strings */ 1118 | #define weechat_charset_set(__charset) \ 1119 | (weechat_plugin->charset_set)(weechat_plugin, __charset) 1120 | #define weechat_iconv_to_internal(__charset, __string) \ 1121 | (weechat_plugin->iconv_to_internal)(__charset, __string) 1122 | #define weechat_iconv_from_internal(__charset, __string) \ 1123 | (weechat_plugin->iconv_from_internal)(__charset, __string) 1124 | #ifndef WEECHAT_H 1125 | #ifndef _ 1126 | #define _(string) (weechat_plugin->gettext)(string) 1127 | #endif /* _ */ 1128 | #ifndef N_ 1129 | #define N_(string) (string) 1130 | #endif /* N_ */ 1131 | #ifndef NG_ 1132 | #define NG_(single,plural,number) \ 1133 | (weechat_plugin->ngettext)(single, plural, number) 1134 | #endif /* NG_ */ 1135 | #endif /* WEECHAT_H */ 1136 | #define weechat_gettext(string) (weechat_plugin->gettext)(string) 1137 | #define weechat_ngettext(single,plural,number) \ 1138 | (weechat_plugin->ngettext)(single, plural, number) 1139 | #define weechat_strndup(__string, __length) \ 1140 | (weechat_plugin->strndup)(__string, __length) 1141 | #define weechat_string_tolower(__string) \ 1142 | (weechat_plugin->string_tolower)(__string) 1143 | #define weechat_string_toupper(__string) \ 1144 | (weechat_plugin->string_toupper)(__string) 1145 | #define weechat_strcasecmp(__string1, __string2) \ 1146 | (weechat_plugin->strcasecmp)(__string1, __string2) 1147 | #define weechat_strcasecmp_range(__string1, __string2, __range) \ 1148 | (weechat_plugin->strcasecmp_range)(__string1, __string2, __range) 1149 | #define weechat_strncasecmp(__string1, __string2, __max) \ 1150 | (weechat_plugin->strncasecmp)(__string1, __string2, __max) 1151 | #define weechat_strncasecmp_range(__string1, __string2, __max, __range) \ 1152 | (weechat_plugin->strncasecmp_range)(__string1, __string2, __max, \ 1153 | __range) 1154 | #define weechat_strcmp_ignore_chars(__string1, __string2, \ 1155 | __chars_ignored, __case_sensitive) \ 1156 | (weechat_plugin->strcmp_ignore_chars)(__string1, __string2, \ 1157 | __chars_ignored, \ 1158 | __case_sensitive) 1159 | #define weechat_strcasestr(__string, __search) \ 1160 | (weechat_plugin->strcasestr)(__string, __search) 1161 | #define weechat_strlen_screen(__string) \ 1162 | (weechat_plugin->strlen_screen)(__string) 1163 | #define weechat_string_match(__string, __mask, __case_sensitive) \ 1164 | (weechat_plugin->string_match)(__string, __mask, __case_sensitive) 1165 | #define weechat_string_replace(__string, __search, __replace) \ 1166 | (weechat_plugin->string_replace)(__string, __search, __replace) 1167 | #define weechat_string_expand_home(__path) \ 1168 | (weechat_plugin->string_expand_home)(__path) 1169 | #define weechat_string_eval_path_home(__path, __pointers, \ 1170 | __extra_vars, __options) \ 1171 | (weechat_plugin->string_eval_path_home)(__path, __pointers, \ 1172 | __extra_vars, __options) 1173 | #define weechat_string_remove_quotes(__string, __quotes) \ 1174 | (weechat_plugin->string_remove_quotes)(__string, __quotes) 1175 | #define weechat_string_strip(__string, __left, __right, __chars) \ 1176 | (weechat_plugin->string_strip)(__string, __left, __right, __chars) 1177 | #define weechat_string_convert_escaped_chars(__string) \ 1178 | (weechat_plugin->string_convert_escaped_chars)(__string) 1179 | #define weechat_string_mask_to_regex(__mask) \ 1180 | (weechat_plugin->string_mask_to_regex)(__mask) 1181 | #define weechat_string_regex_flags(__regex, __default_flags, __flags) \ 1182 | (weechat_plugin->string_regex_flags)(__regex, __default_flags, \ 1183 | __flags) 1184 | #define weechat_string_regcomp(__preg, __regex, __default_flags) \ 1185 | (weechat_plugin->string_regcomp)(__preg, __regex, __default_flags) 1186 | #define weechat_string_has_highlight(__string, __highlight_words) \ 1187 | (weechat_plugin->string_has_highlight)(__string, __highlight_words) 1188 | #define weechat_string_has_highlight_regex(__string, __regex) \ 1189 | (weechat_plugin->string_has_highlight_regex)(__string, __regex) 1190 | #define weechat_string_replace_regex(__string, __regex, __replace, \ 1191 | __reference_char, __callback, \ 1192 | __callback_data) \ 1193 | (weechat_plugin->string_replace_regex)(__string, __regex, \ 1194 | __replace, \ 1195 | __reference_char, \ 1196 | __callback, \ 1197 | __callback_data) 1198 | #define weechat_string_split(__string, __separator, __eol, __max, \ 1199 | __num_items) \ 1200 | (weechat_plugin->string_split)(__string, __separator, __eol, \ 1201 | __max, __num_items) 1202 | #define weechat_string_split_shell(__string, __num_items) \ 1203 | (weechat_plugin->string_split_shell)(__string, __num_items) 1204 | #define weechat_string_free_split(__split_string) \ 1205 | (weechat_plugin->string_free_split)(__split_string) 1206 | #define weechat_string_build_with_split_string(__split_string, \ 1207 | __separator) \ 1208 | (weechat_plugin->string_build_with_split_string)(__split_string, \ 1209 | __separator) 1210 | #define weechat_string_split_command(__command, __separator) \ 1211 | (weechat_plugin->string_split_command)(__command, __separator) 1212 | #define weechat_string_free_split_command(__split_command) \ 1213 | (weechat_plugin->string_free_split_command)(__split_command) 1214 | #define weechat_string_format_size(__size) \ 1215 | (weechat_plugin->string_format_size)(__size) 1216 | #define weechat_string_remove_color(__string, __replacement) \ 1217 | (weechat_plugin->string_remove_color)(__string, __replacement) 1218 | #define weechat_string_encode_base64(__from, __length, __to) \ 1219 | (weechat_plugin->string_encode_base64)(__from, __length, __to) 1220 | #define weechat_string_decode_base64(__from, __to) \ 1221 | (weechat_plugin->string_decode_base64)(__from, __to) 1222 | #define weechat_string_hex_dump(__data, __data_size, __bytes_per_line, \ 1223 | __prefix, __suffix) \ 1224 | (weechat_plugin->string_hex_dump)(__data, __data_size, \ 1225 | __bytes_per_line, __prefix, \ 1226 | __suffix) 1227 | #define weechat_string_is_command_char(__string) \ 1228 | (weechat_plugin->string_is_command_char)(__string) 1229 | #define weechat_string_input_for_buffer(__string) \ 1230 | (weechat_plugin->string_input_for_buffer)(__string) 1231 | #define weechat_string_eval_expression(__expr, __pointers, \ 1232 | __extra_vars, __options) \ 1233 | (weechat_plugin->string_eval_expression)(__expr, __pointers, \ 1234 | __extra_vars, __options) 1235 | #define weechat_string_dyn_alloc(__size_alloc) \ 1236 | (weechat_plugin->string_dyn_alloc)(__size_alloc) 1237 | #define weechat_string_dyn_copy(__string, __new_string) \ 1238 | (weechat_plugin->string_dyn_copy)(__string, __new_string) 1239 | #define weechat_string_dyn_concat(__string, __add) \ 1240 | (weechat_plugin->string_dyn_concat)(__string, __add) 1241 | #define weechat_string_dyn_free(__string, __free_string) \ 1242 | (weechat_plugin->string_dyn_free)(__string, __free_string) 1243 | 1244 | /* UTF-8 strings */ 1245 | #define weechat_utf8_has_8bits(__string) \ 1246 | (weechat_plugin->utf8_has_8bits)(__string) 1247 | #define weechat_utf8_is_valid(__string, __length, __error) \ 1248 | (weechat_plugin->utf8_is_valid)(__string, __length, __error) 1249 | #define weechat_utf8_normalize(__string, __char) \ 1250 | (weechat_plugin->utf8_normalize)(__string, __char) 1251 | #define weechat_utf8_prev_char(__start, __string) \ 1252 | (weechat_plugin->utf8_prev_char)(__start, __string) 1253 | #define weechat_utf8_next_char(__string) \ 1254 | (weechat_plugin->utf8_next_char)(__string) 1255 | #define weechat_utf8_char_int(__string) \ 1256 | (weechat_plugin->utf8_char_int)(__string) 1257 | #define weechat_utf8_char_size(__string) \ 1258 | (weechat_plugin->utf8_char_size)(__string) 1259 | #define weechat_utf8_strlen(__string) \ 1260 | (weechat_plugin->utf8_strlen)(__string) 1261 | #define weechat_utf8_strnlen(__string, __bytes) \ 1262 | (weechat_plugin->utf8_strnlen)(__string, __bytes) 1263 | #define weechat_utf8_strlen_screen(__string) \ 1264 | (weechat_plugin->utf8_strlen_screen)(__string) 1265 | #define weechat_utf8_charcmp(__string1, __string2) \ 1266 | (weechat_plugin->utf8_charcmp)(__string1, __string2) 1267 | #define weechat_utf8_charcasecmp(__string1, __string2) \ 1268 | (weechat_plugin->utf8_charcasecmp)(__string1, __string2) 1269 | #define weechat_utf8_char_size_screen(__string) \ 1270 | (weechat_plugin->utf8_char_size_screen)(__string) 1271 | #define weechat_utf8_add_offset(__string, __offset) \ 1272 | (weechat_plugin->utf8_add_offset)(__string, __offset) 1273 | #define weechat_utf8_real_pos(__string, __pos) \ 1274 | (weechat_plugin->utf8_real_pos)(__string, __pos) 1275 | #define weechat_utf8_pos(__string, __real_pos) \ 1276 | (weechat_plugin->utf8_pos)(__string, __real_pos) 1277 | #define weechat_utf8_strndup(__string, __length) \ 1278 | (weechat_plugin->utf8_strndup)(__string, __length) 1279 | 1280 | /* directories */ 1281 | #define weechat_mkdir_home(__directory, __mode) \ 1282 | (weechat_plugin->mkdir_home)(__directory, __mode) 1283 | #define weechat_mkdir(__directory, __mode) \ 1284 | (weechat_plugin->mkdir)(__directory, __mode) 1285 | #define weechat_mkdir_parents(__directory, __mode) \ 1286 | (weechat_plugin->mkdir_parents)(__directory, __mode) 1287 | #define weechat_exec_on_files(__directory, __recurse_subdirs, \ 1288 | __hidden_files, __callback, \ 1289 | __callback_data) \ 1290 | (weechat_plugin->exec_on_files)(__directory, __recurse_subdirs, \ 1291 | __hidden_files, \ 1292 | __callback, __callback_data) 1293 | #define weechat_file_get_content(__filename) \ 1294 | (weechat_plugin->file_get_content)(__filename) 1295 | 1296 | /* util */ 1297 | #define weechat_util_timeval_cmp(__time1, __time2) \ 1298 | (weechat_plugin->util_timeval_cmp)(__time1, __time2) 1299 | #define weechat_util_timeval_diff(__time1, __time2) \ 1300 | (weechat_plugin->util_timeval_diff)(__time1, __time2) 1301 | #define weechat_util_timeval_add(__time, __interval) \ 1302 | (weechat_plugin->util_timeval_add)(__time, __interval) 1303 | #define weechat_util_get_time_string(__date) \ 1304 | (weechat_plugin->util_get_time_string)(__date) 1305 | #define weechat_util_version_number(__version) \ 1306 | (weechat_plugin->util_version_number)(__version) 1307 | 1308 | /* sorted list */ 1309 | #define weechat_list_new() \ 1310 | (weechat_plugin->list_new)() 1311 | #define weechat_list_add(__list, __string, __where, __user_data) \ 1312 | (weechat_plugin->list_add)(__list, __string, __where, __user_data) 1313 | #define weechat_list_search(__list, __string) \ 1314 | (weechat_plugin->list_search)(__list, __string) 1315 | #define weechat_list_search_pos(__list, __string) \ 1316 | (weechat_plugin->list_search_pos)(__list, __string) 1317 | #define weechat_list_casesearch(__list, __string) \ 1318 | (weechat_plugin->list_casesearch)(__list, __string) 1319 | #define weechat_list_casesearch_pos(__list, __string) \ 1320 | (weechat_plugin->list_casesearch_pos)(__list, __string) 1321 | #define weechat_list_get(__list, __index) \ 1322 | (weechat_plugin->list_get)(__list, __index) 1323 | #define weechat_list_set(__item, __value) \ 1324 | (weechat_plugin->list_set)(__item, __value) 1325 | #define weechat_list_next(__item) \ 1326 | (weechat_plugin->list_next)(__item) 1327 | #define weechat_list_prev(__item) \ 1328 | (weechat_plugin->list_prev)(__item) 1329 | #define weechat_list_string(__item) \ 1330 | (weechat_plugin->list_string)(__item) 1331 | #define weechat_list_size(__list) \ 1332 | (weechat_plugin->list_size)(__list) 1333 | #define weechat_list_remove(__list, __item) \ 1334 | (weechat_plugin->list_remove)(__list, __item) 1335 | #define weechat_list_remove_all(__list) \ 1336 | (weechat_plugin->list_remove_all)(__list) 1337 | #define weechat_list_free(__list) \ 1338 | (weechat_plugin->list_free)(__list) 1339 | 1340 | /* array lists */ 1341 | #define weechat_arraylist_new(__initial_size, __sorted, \ 1342 | __allow_duplicates, __callback_cmp, \ 1343 | __callback_cmp_data, __callback_free, \ 1344 | __callback_free_data) \ 1345 | (weechat_plugin->arraylist_new)(__initial_size, __sorted, \ 1346 | __allow_duplicates, __callback_cmp, \ 1347 | __callback_cmp_data, __callback_free, \ 1348 | __callback_free_data) 1349 | #define weechat_arraylist_size(__arraylist) \ 1350 | (weechat_plugin->arraylist_size)(__arraylist) 1351 | #define weechat_arraylist_get(__arraylist, __index) \ 1352 | (weechat_plugin->arraylist_get)(__arraylist, __index) 1353 | #define weechat_arraylist_search(__arraylist, __pointer, __index, \ 1354 | __index_insert) \ 1355 | (weechat_plugin->arraylist_search)(__arraylist, __pointer, __index, \ 1356 | __index_insert) 1357 | #define weechat_arraylist_insert(__arraylist, __index, __pointer) \ 1358 | (weechat_plugin->arraylist_insert)(__arraylist, __index, __pointer) 1359 | #define weechat_arraylist_add(__arraylist, __pointer) \ 1360 | (weechat_plugin->arraylist_add)(__arraylist, __pointer) 1361 | #define weechat_arraylist_remove(__arraylist, __index) \ 1362 | (weechat_plugin->arraylist_remove)(__arraylist, __index) 1363 | #define weechat_arraylist_clear(__arraylist) \ 1364 | (weechat_plugin->arraylist_clear)(__arraylist) 1365 | #define weechat_arraylist_free(__arraylist) \ 1366 | (weechat_plugin->arraylist_free)(__arraylist) 1367 | 1368 | /* hash tables */ 1369 | #define weechat_hashtable_new(__size, __type_keys, __type_values, \ 1370 | __callback_hash_key, __callback_keycmp) \ 1371 | (weechat_plugin->hashtable_new)(__size, __type_keys, __type_values, \ 1372 | __callback_hash_key, \ 1373 | __callback_keycmp) 1374 | #define weechat_hashtable_set_with_size(__hashtable, __key, __key_size, \ 1375 | __value, __value_size) \ 1376 | (weechat_plugin->hashtable_set_with_size)(__hashtable, __key, \ 1377 | __key_size, __value, \ 1378 | __value_size) 1379 | #define weechat_hashtable_set(__hashtable, __key, __value) \ 1380 | (weechat_plugin->hashtable_set)(__hashtable, __key, __value) 1381 | #define weechat_hashtable_get(__hashtable, __key) \ 1382 | (weechat_plugin->hashtable_get)(__hashtable, __key) 1383 | #define weechat_hashtable_has_key(__hashtable, __key) \ 1384 | (weechat_plugin->hashtable_has_key)(__hashtable, __key) 1385 | #define weechat_hashtable_map(__hashtable, __cb_map, __cb_map_data) \ 1386 | (weechat_plugin->hashtable_map)(__hashtable, __cb_map, \ 1387 | __cb_map_data) 1388 | #define weechat_hashtable_map_string(__hashtable, __cb_map, \ 1389 | __cb_map_data) \ 1390 | (weechat_plugin->hashtable_map_string)(__hashtable, __cb_map, \ 1391 | __cb_map_data) 1392 | #define weechat_hashtable_dup(__hashtable) \ 1393 | (weechat_plugin->hashtable_dup)(__hashtable) 1394 | #define weechat_hashtable_get_integer(__hashtable, __property) \ 1395 | (weechat_plugin->hashtable_get_integer)(__hashtable, __property) 1396 | #define weechat_hashtable_get_string(__hashtable, __property) \ 1397 | (weechat_plugin->hashtable_get_string)(__hashtable, __property) 1398 | #define weechat_hashtable_set_pointer(__hashtable, __property, \ 1399 | __pointer) \ 1400 | (weechat_plugin->hashtable_set_pointer)(__hashtable, __property, \ 1401 | __pointer) 1402 | #define weechat_hashtable_add_to_infolist(__hashtable, __infolist_item, \ 1403 | __prefix) \ 1404 | (weechat_plugin->hashtable_add_to_infolist)(__hashtable, \ 1405 | __infolist_item, \ 1406 | __prefix) 1407 | #define weechat_hashtable_add_from_infolist(__hashtable, __infolist, \ 1408 | __prefix) \ 1409 | (weechat_plugin->hashtable_add_from_infolist)(__hashtable, \ 1410 | __infolist, \ 1411 | __prefix) 1412 | #define weechat_hashtable_remove(__hashtable, __key) \ 1413 | (weechat_plugin->hashtable_remove)(__hashtable, __key) 1414 | #define weechat_hashtable_remove_all(__hashtable) \ 1415 | (weechat_plugin->hashtable_remove_all)(__hashtable) 1416 | #define weechat_hashtable_free(__hashtable) \ 1417 | (weechat_plugin->hashtable_free)(__hashtable) 1418 | 1419 | /* config files */ 1420 | #define weechat_config_new(__name, __callback_reload, \ 1421 | __callback_reload_pointer, \ 1422 | __callback_reload_data) \ 1423 | (weechat_plugin->config_new)(weechat_plugin, __name, \ 1424 | __callback_reload, \ 1425 | __callback_reload_pointer, \ 1426 | __callback_reload_data) 1427 | #define weechat_config_new_section(__config, __name, \ 1428 | __user_can_add_options, \ 1429 | __user_can_delete_options, \ 1430 | __cb_read, \ 1431 | __cb_read_pointer, \ 1432 | __cb_read_data, \ 1433 | __cb_write_std, \ 1434 | __cb_write_std_pointer, \ 1435 | __cb_write_std_data, \ 1436 | __cb_write_def, \ 1437 | __cb_write_def_pointer, \ 1438 | __cb_write_def_data, \ 1439 | __cb_create_option, \ 1440 | __cb_create_option_pointer, \ 1441 | __cb_create_option_data, \ 1442 | __cb_delete_option, \ 1443 | __cb_delete_option_pointer, \ 1444 | __cb_delete_option_data) \ 1445 | (weechat_plugin->config_new_section)(__config, __name, \ 1446 | __user_can_add_options, \ 1447 | __user_can_delete_options, \ 1448 | __cb_read, \ 1449 | __cb_read_pointer, \ 1450 | __cb_read_data, \ 1451 | __cb_write_std, \ 1452 | __cb_write_std_pointer, \ 1453 | __cb_write_std_data, \ 1454 | __cb_write_def, \ 1455 | __cb_write_def_pointer, \ 1456 | __cb_write_def_data, \ 1457 | __cb_create_option, \ 1458 | __cb_create_option_pointer, \ 1459 | __cb_create_option_data, \ 1460 | __cb_delete_option, \ 1461 | __cb_delete_option_pointer, \ 1462 | __cb_delete_option_data) 1463 | #define weechat_config_search_section(__config, __name) \ 1464 | (weechat_plugin->config_search_section)(__config, __name) 1465 | #define weechat_config_new_option(__config, __section, __name, __type, \ 1466 | __desc, __string_values, __min, \ 1467 | __max, __default, __value, \ 1468 | __null_value_allowed, \ 1469 | __callback_check, \ 1470 | __callback_check_pointer, \ 1471 | __callback_check_data, \ 1472 | __callback_change, \ 1473 | __callback_change_pointer, \ 1474 | __callback_change_data, \ 1475 | __callback_delete, \ 1476 | __callback_delete_pointer, \ 1477 | __callback_delete_data) \ 1478 | (weechat_plugin->config_new_option)(__config, __section, __name, \ 1479 | __type, __desc, \ 1480 | __string_values, \ 1481 | __min, __max, __default, \ 1482 | __value, \ 1483 | __null_value_allowed, \ 1484 | __callback_check, \ 1485 | __callback_check_pointer, \ 1486 | __callback_check_data, \ 1487 | __callback_change, \ 1488 | __callback_change_pointer, \ 1489 | __callback_change_data, \ 1490 | __callback_delete, \ 1491 | __callback_delete_pointer, \ 1492 | __callback_delete_data) 1493 | #define weechat_config_search_option(__config, __section, __name) \ 1494 | (weechat_plugin->config_search_option)(__config, __section, __name) 1495 | #define weechat_config_search_section_option(__config, __section, \ 1496 | __name, __section_found, \ 1497 | __option_found) \ 1498 | (weechat_plugin->config_search_section_option)(__config, __section, \ 1499 | __name, \ 1500 | __section_found, \ 1501 | __option_found); 1502 | #define weechat_config_search_with_string(__name, __config, __section, \ 1503 | __option, __pos_option) \ 1504 | (weechat_plugin->config_search_with_string)(__name, __config, \ 1505 | __section, __option, \ 1506 | __pos_option); 1507 | #define weechat_config_string_to_boolean(__string) \ 1508 | (weechat_plugin->config_string_to_boolean)(__string) 1509 | #define weechat_config_option_reset(__option, __run_callback) \ 1510 | (weechat_plugin->config_option_reset)(__option, __run_callback) 1511 | #define weechat_config_option_set(__option, __value, __run_callback) \ 1512 | (weechat_plugin->config_option_set)(__option, __value, \ 1513 | __run_callback) 1514 | #define weechat_config_option_set_null(__option, __run_callback) \ 1515 | (weechat_plugin->config_option_set_null)(__option, __run_callback) 1516 | #define weechat_config_option_unset(__option) \ 1517 | (weechat_plugin->config_option_unset)(__option) 1518 | #define weechat_config_option_rename(__option, __new_name) \ 1519 | (weechat_plugin->config_option_rename)(__option, __new_name) 1520 | #define weechat_config_option_get_string(__option, __property) \ 1521 | (weechat_plugin->config_option_get_string)(__option, __property) 1522 | #define weechat_config_option_get_pointer(__option, __property) \ 1523 | (weechat_plugin->config_option_get_pointer)(__option, __property) 1524 | #define weechat_config_option_is_null(__option) \ 1525 | (weechat_plugin->config_option_is_null)(__option) 1526 | #define weechat_config_option_default_is_null(__option) \ 1527 | (weechat_plugin->config_option_default_is_null)(__option) 1528 | #define weechat_config_boolean(__option) \ 1529 | (weechat_plugin->config_boolean)(__option) 1530 | #define weechat_config_boolean_default(__option) \ 1531 | (weechat_plugin->config_boolean_default)(__option) 1532 | #define weechat_config_integer(__option) \ 1533 | (weechat_plugin->config_integer)(__option) 1534 | #define weechat_config_integer_default(__option) \ 1535 | (weechat_plugin->config_integer_default)(__option) 1536 | #define weechat_config_string(__option) \ 1537 | (weechat_plugin->config_string)(__option) 1538 | #define weechat_config_string_default(__option) \ 1539 | (weechat_plugin->config_string_default)(__option) 1540 | #define weechat_config_color(__option) \ 1541 | (weechat_plugin->config_color)(__option) 1542 | #define weechat_config_color_default(__option) \ 1543 | (weechat_plugin->config_color_default)(__option) 1544 | #define weechat_config_write_option(__config, __option) \ 1545 | (weechat_plugin->config_write_option)(__config, __option) 1546 | #define weechat_config_write_line(__config, __option, __value...) \ 1547 | (weechat_plugin->config_write_line)(__config, __option, ##__value) 1548 | #define weechat_config_write(__config) \ 1549 | (weechat_plugin->config_write)(__config) 1550 | #define weechat_config_read(__config) \ 1551 | (weechat_plugin->config_read)(__config) 1552 | #define weechat_config_reload(__config) \ 1553 | (weechat_plugin->config_reload)(__config) 1554 | #define weechat_config_option_free(__option) \ 1555 | (weechat_plugin->config_option_free)(__option) 1556 | #define weechat_config_section_free_options(__section) \ 1557 | (weechat_plugin->config_section_free_options)(__section) 1558 | #define weechat_config_section_free(__section) \ 1559 | (weechat_plugin->config_section_free)(__section) 1560 | #define weechat_config_free(__config) \ 1561 | (weechat_plugin->config_free)(__config) 1562 | #define weechat_config_get(__option) \ 1563 | (weechat_plugin->config_get)(__option) 1564 | #define weechat_config_get_plugin(__option) \ 1565 | (weechat_plugin->config_get_plugin)(weechat_plugin, __option) 1566 | #define weechat_config_is_set_plugin(__option) \ 1567 | (weechat_plugin->config_is_set_plugin)(weechat_plugin, __option) 1568 | #define weechat_config_set_plugin(__option, __value) \ 1569 | (weechat_plugin->config_set_plugin)(weechat_plugin, __option, \ 1570 | __value) 1571 | #define weechat_config_set_desc_plugin(__option, __description) \ 1572 | (weechat_plugin->config_set_desc_plugin)(weechat_plugin, __option, \ 1573 | __description) 1574 | #define weechat_config_unset_plugin(__option) \ 1575 | (weechat_plugin->config_unset_plugin)(weechat_plugin, __option) 1576 | 1577 | /* key bindings */ 1578 | #define weechat_key_bind(__context, __keys) \ 1579 | (weechat_plugin->key_bind)(__context, __keys) 1580 | #define weechat_key_unbind(__context, __key) \ 1581 | (weechat_plugin->key_unbind)(__context, __key) 1582 | 1583 | /* display */ 1584 | #define weechat_prefix(__prefix) \ 1585 | (weechat_plugin->prefix)(__prefix) 1586 | #define weechat_color(__color_name) \ 1587 | (weechat_plugin->color)(__color_name) 1588 | #define weechat_printf(__buffer, __message, __argz...) \ 1589 | (weechat_plugin->printf_date_tags)(__buffer, 0, NULL, __message, \ 1590 | ##__argz) 1591 | #define weechat_printf_date_tags(__buffer, __date, __tags, __message, \ 1592 | __argz...) \ 1593 | (weechat_plugin->printf_date_tags)(__buffer, __date, __tags, \ 1594 | __message, ##__argz) 1595 | #define weechat_printf_y(__buffer, __y, __message, __argz...) \ 1596 | (weechat_plugin->printf_y)(__buffer, __y, __message, ##__argz) 1597 | #define weechat_log_printf(__message, __argz...) \ 1598 | (weechat_plugin->log_printf)(__message, ##__argz) 1599 | 1600 | /* hooks */ 1601 | #define weechat_hook_command(__command, __description, __args, \ 1602 | __args_desc, __completion, __callback, \ 1603 | __pointer, __data) \ 1604 | (weechat_plugin->hook_command)(weechat_plugin, __command, \ 1605 | __description, __args, __args_desc, \ 1606 | __completion, __callback, __pointer, \ 1607 | __data) 1608 | #define weechat_hook_command_run(__command, __callback, __pointer, \ 1609 | __data) \ 1610 | (weechat_plugin->hook_command_run)(weechat_plugin, __command, \ 1611 | __callback, __pointer, __data) 1612 | #define weechat_hook_timer(__interval, __align_second, __max_calls, \ 1613 | __callback, __pointer, __data) \ 1614 | (weechat_plugin->hook_timer)(weechat_plugin, __interval, \ 1615 | __align_second, __max_calls, \ 1616 | __callback, __pointer, __data) 1617 | #define weechat_hook_fd(__fd, __flag_read, __flag_write, \ 1618 | __flag_exception, __callback, __pointer, \ 1619 | __data) \ 1620 | (weechat_plugin->hook_fd)(weechat_plugin, __fd, __flag_read, \ 1621 | __flag_write, __flag_exception, \ 1622 | __callback, __pointer, __data) 1623 | #define weechat_hook_process(__command, __timeout, __callback, \ 1624 | __callback_pointer, __callback_data) \ 1625 | (weechat_plugin->hook_process)(weechat_plugin, __command, \ 1626 | __timeout, __callback, \ 1627 | __callback_pointer, __callback_data) 1628 | #define weechat_hook_process_hashtable(__command, __options, __timeout, \ 1629 | __callback, __callback_pointer, \ 1630 | __callback_data) \ 1631 | (weechat_plugin->hook_process_hashtable)(weechat_plugin, __command, \ 1632 | __options, __timeout, \ 1633 | __callback, \ 1634 | __callback_pointer, \ 1635 | __callback_data) 1636 | #define weechat_hook_connect(__proxy, __address, __port, __ipv6, \ 1637 | __retry, __gnutls_sess, __gnutls_cb, \ 1638 | __gnutls_dhkey_size, __gnutls_priorities, \ 1639 | __local_hostname, __callback, __pointer, \ 1640 | __data) \ 1641 | (weechat_plugin->hook_connect)(weechat_plugin, __proxy, __address, \ 1642 | __port, __ipv6, __retry, \ 1643 | __gnutls_sess, __gnutls_cb, \ 1644 | __gnutls_dhkey_size, \ 1645 | __gnutls_priorities, \ 1646 | __local_hostname, \ 1647 | __callback, __pointer, __data) 1648 | #define weechat_hook_print(__buffer, __tags, __msg, __strip__colors, \ 1649 | __callback, __pointer, __data) \ 1650 | (weechat_plugin->hook_print)(weechat_plugin, __buffer, __tags, \ 1651 | __msg, __strip__colors, __callback, \ 1652 | __pointer, __data) 1653 | #define weechat_hook_signal(__signal, __callback, __pointer, __data) \ 1654 | (weechat_plugin->hook_signal)(weechat_plugin, __signal, __callback, \ 1655 | __pointer, __data) 1656 | #define weechat_hook_signal_send(__signal, __type_data, __signal_data) \ 1657 | (weechat_plugin->hook_signal_send)(__signal, __type_data, \ 1658 | __signal_data) 1659 | #define weechat_hook_hsignal(__signal, __callback, __pointer, __data) \ 1660 | (weechat_plugin->hook_hsignal)(weechat_plugin, __signal, \ 1661 | __callback, __pointer, __data) 1662 | #define weechat_hook_hsignal_send(__signal, __hashtable) \ 1663 | (weechat_plugin->hook_hsignal_send)(__signal, __hashtable) 1664 | #define weechat_hook_config(__option, __callback, __pointer, __data) \ 1665 | (weechat_plugin->hook_config)(weechat_plugin, __option, __callback, \ 1666 | __pointer, __data) 1667 | #define weechat_hook_completion(__completion, __description, \ 1668 | __callback, __pointer, __data) \ 1669 | (weechat_plugin->hook_completion)(weechat_plugin, __completion, \ 1670 | __description, __callback, \ 1671 | __pointer, __data) 1672 | #define weechat_hook_completion_get_string(__completion, __property) \ 1673 | (weechat_plugin->hook_completion_get_string)(__completion, \ 1674 | __property) 1675 | #define weechat_hook_completion_list_add(__completion, __word, \ 1676 | __nick_completion, __where) \ 1677 | (weechat_plugin->hook_completion_list_add)(__completion, __word, \ 1678 | __nick_completion, \ 1679 | __where) 1680 | #define weechat_hook_modifier(__modifier, __callback, __pointer, \ 1681 | __data) \ 1682 | (weechat_plugin->hook_modifier)(weechat_plugin, __modifier, \ 1683 | __callback, __pointer, __data) 1684 | #define weechat_hook_modifier_exec(__modifier, __modifier_data, \ 1685 | __string) \ 1686 | (weechat_plugin->hook_modifier_exec)(weechat_plugin, __modifier, \ 1687 | __modifier_data, __string) 1688 | #define weechat_hook_info(__info_name, __description, \ 1689 | __args_description, __callback, __pointer, \ 1690 | __data) \ 1691 | (weechat_plugin->hook_info)(weechat_plugin, __info_name, \ 1692 | __description, __args_description, \ 1693 | __callback, __pointer, __data) 1694 | #define weechat_hook_info_hashtable(__info_name, __description, \ 1695 | __args_description, \ 1696 | __output_description, \ 1697 | __callback, \ 1698 | __pointer, \ 1699 | __data) \ 1700 | (weechat_plugin->hook_info_hashtable)(weechat_plugin, __info_name, \ 1701 | __description, \ 1702 | __args_description, \ 1703 | __output_description, \ 1704 | __callback, __pointer, \ 1705 | __data) 1706 | #define weechat_hook_infolist(__infolist_name, __description, \ 1707 | __pointer_description, \ 1708 | __args_description, __callback, \ 1709 | __pointer, __data) \ 1710 | (weechat_plugin->hook_infolist)(weechat_plugin, __infolist_name, \ 1711 | __description, \ 1712 | __pointer_description, \ 1713 | __args_description, __callback, \ 1714 | __pointer, __data) 1715 | #define weechat_hook_hdata(__hdata_name, __description, __callback, \ 1716 | __pointer, __data) \ 1717 | (weechat_plugin->hook_hdata)(weechat_plugin, __hdata_name, \ 1718 | __description, __callback, __pointer, \ 1719 | __data) 1720 | #define weechat_hook_focus(__area, __callback, __pointer, __data) \ 1721 | (weechat_plugin->hook_focus)(weechat_plugin, __area, __callback, \ 1722 | __pointer, __data) 1723 | #define weechat_hook_set(__hook, __property, __value) \ 1724 | (weechat_plugin->hook_set)(__hook, __property, __value) 1725 | #define weechat_unhook(__hook) \ 1726 | (weechat_plugin->unhook)( __hook) 1727 | #define weechat_unhook_all(__subplugin) \ 1728 | (weechat_plugin->unhook_all)(weechat_plugin, __subplugin) 1729 | 1730 | /* buffers */ 1731 | #define weechat_buffer_new(__name, __input_callback, \ 1732 | __input_callback_pointer, \ 1733 | __input_callback_data, \ 1734 | __close_callback, \ 1735 | __close_callback_pointer, \ 1736 | __close_callback_data) \ 1737 | (weechat_plugin->buffer_new)(weechat_plugin, __name, \ 1738 | __input_callback, \ 1739 | __input_callback_pointer, \ 1740 | __input_callback_data, \ 1741 | __close_callback, \ 1742 | __close_callback_pointer, \ 1743 | __close_callback_data) 1744 | #define weechat_buffer_search(__plugin, __name) \ 1745 | (weechat_plugin->buffer_search)(__plugin, __name) 1746 | #define weechat_buffer_search_main() \ 1747 | (weechat_plugin->buffer_search_main)() 1748 | #define weechat_current_buffer() \ 1749 | (weechat_plugin->buffer_search)(NULL, NULL) 1750 | #define weechat_buffer_clear(__buffer) \ 1751 | (weechat_plugin->buffer_clear)(__buffer) 1752 | #define weechat_buffer_close(__buffer) \ 1753 | (weechat_plugin->buffer_close)(__buffer) 1754 | #define weechat_buffer_merge(__buffer, __target_buffer) \ 1755 | (weechat_plugin->buffer_merge)(__buffer, __target_buffer) 1756 | #define weechat_buffer_unmerge(__buffer, __number) \ 1757 | (weechat_plugin->buffer_unmerge)(__buffer, __number) 1758 | #define weechat_buffer_get_integer(__buffer, __property) \ 1759 | (weechat_plugin->buffer_get_integer)(__buffer, __property) 1760 | #define weechat_buffer_get_string(__buffer, __property) \ 1761 | (weechat_plugin->buffer_get_string)(__buffer, __property) 1762 | #define weechat_buffer_get_pointer(__buffer, __property) \ 1763 | (weechat_plugin->buffer_get_pointer)(__buffer, __property) 1764 | #define weechat_buffer_set(__buffer, __property, __value) \ 1765 | (weechat_plugin->buffer_set)(__buffer, __property, __value) 1766 | #define weechat_buffer_set_pointer(__buffer, __property, __pointer) \ 1767 | (weechat_plugin->buffer_set_pointer)(__buffer, __property, \ 1768 | __pointer) 1769 | #define weechat_buffer_string_replace_local_var(__buffer, __string) \ 1770 | (weechat_plugin->buffer_string_replace_local_var)(__buffer, \ 1771 | __string) 1772 | #define weechat_buffer_match_list(__buffer, __string) \ 1773 | (weechat_plugin->buffer_match_list)(__buffer, __string) 1774 | 1775 | /* windows */ 1776 | #define weechat_window_search_with_buffer(__buffer) \ 1777 | (weechat_plugin->window_search_with_buffer)(__buffer) 1778 | #define weechat_window_get_integer(__window, __property) \ 1779 | (weechat_plugin->window_get_integer)(__window, __property) 1780 | #define weechat_window_get_string(__window, __property) \ 1781 | (weechat_plugin->window_get_string)(__window, __property) 1782 | #define weechat_window_get_pointer(__window, __property) \ 1783 | (weechat_plugin->window_get_pointer)(__window, __property) 1784 | #define weechat_current_window() \ 1785 | (weechat_plugin->window_get_pointer)(NULL, "current") 1786 | #define weechat_window_set_title(__title) \ 1787 | (weechat_plugin->window_set_title)(__title) 1788 | 1789 | /* nicklist */ 1790 | #define weechat_nicklist_add_group(__buffer, __parent_group, __name, \ 1791 | __color, __visible) \ 1792 | (weechat_plugin->nicklist_add_group)(__buffer, __parent_group, \ 1793 | __name, __color, __visible) 1794 | #define weechat_nicklist_search_group(__buffer, __from_group, __name) \ 1795 | (weechat_plugin->nicklist_search_group)(__buffer, __from_group, \ 1796 | __name) 1797 | #define weechat_nicklist_add_nick(__buffer, __group, __name, __color, \ 1798 | __prefix, __prefix_color, __visible) \ 1799 | (weechat_plugin->nicklist_add_nick)(__buffer, __group, __name, \ 1800 | __color, __prefix, \ 1801 | __prefix_color, __visible) 1802 | #define weechat_nicklist_search_nick(__buffer, __from_group, __name) \ 1803 | (weechat_plugin->nicklist_search_nick)(__buffer, __from_group, \ 1804 | __name) 1805 | #define weechat_nicklist_remove_group(__buffer, __group) \ 1806 | (weechat_plugin->nicklist_remove_group)(__buffer, __group) 1807 | #define weechat_nicklist_remove_nick(__buffer, __nick) \ 1808 | (weechat_plugin->nicklist_remove_nick)(__buffer, __nick) 1809 | #define weechat_nicklist_remove_all(__buffer) \ 1810 | (weechat_plugin->nicklist_remove_all)(__buffer) 1811 | #define weechat_nicklist_get_next_item(__buffer, __group, __nick) \ 1812 | (weechat_plugin->nicklist_get_next_item)(__buffer, __group, __nick) 1813 | #define weechat_nicklist_group_get_integer(__buffer, __group, \ 1814 | __property) \ 1815 | (weechat_plugin->nicklist_group_get_integer)(__buffer, __group, \ 1816 | __property) 1817 | #define weechat_nicklist_group_get_string(__buffer, __group, \ 1818 | __property) \ 1819 | (weechat_plugin->nicklist_group_get_string)(__buffer, __group, \ 1820 | __property) 1821 | #define weechat_nicklist_group_get_pointer(__buffer, __group, \ 1822 | __property) \ 1823 | (weechat_plugin->nicklist_group_get_pointer)(__buffer, __group, \ 1824 | __property) 1825 | #define weechat_nicklist_group_set(__buffer, __group, __property, \ 1826 | __value) \ 1827 | (weechat_plugin->nicklist_group_set)(__buffer, __group, __property, \ 1828 | __value) 1829 | #define weechat_nicklist_nick_get_integer(__buffer, __nick, __property) \ 1830 | (weechat_plugin->nicklist_nick_get_integer)(__buffer, __nick, \ 1831 | __property) 1832 | #define weechat_nicklist_nick_get_string(__buffer, __nick, __property) \ 1833 | (weechat_plugin->nicklist_nick_get_string)(__buffer, __nick, \ 1834 | __property) 1835 | #define weechat_nicklist_nick_get_pointer(__buffer, __nick, __property) \ 1836 | (weechat_plugin->nicklist_nick_get_pointer)(__buffer, __nick, \ 1837 | __property) 1838 | #define weechat_nicklist_nick_set(__buffer, __nick, __property, \ 1839 | __value) \ 1840 | (weechat_plugin->nicklist_nick_set)(__buffer, __nick, __property, \ 1841 | __value) 1842 | 1843 | /* bars */ 1844 | #define weechat_bar_item_search(__name) \ 1845 | (weechat_plugin->bar_item_search)(__name) 1846 | #define weechat_bar_item_new(__name, __build_callback, \ 1847 | __build_callback_pointer, \ 1848 | __build_callback_data) \ 1849 | (weechat_plugin->bar_item_new)(weechat_plugin, __name, \ 1850 | __build_callback, \ 1851 | __build_callback_pointer, \ 1852 | __build_callback_data) 1853 | #define weechat_bar_item_update(__name) \ 1854 | (weechat_plugin->bar_item_update)(__name) 1855 | #define weechat_bar_item_remove(__item) \ 1856 | (weechat_plugin->bar_item_remove)(__item) 1857 | #define weechat_bar_search(__name) \ 1858 | (weechat_plugin->bar_search)(__name) 1859 | #define weechat_bar_new(__name, __hidden, __priority, __type, \ 1860 | __condition, __position, __filling_top_bottom, \ 1861 | __filling_left_right, __size, __size_max, \ 1862 | __color_fg, __color_delim, __color_bg, \ 1863 | __separator, __items) \ 1864 | (weechat_plugin->bar_new)(__name, __hidden, __priority, __type, \ 1865 | __condition, __position, \ 1866 | __filling_top_bottom, \ 1867 | __filling_left_right, \ 1868 | __size, __size_max, __color_fg, \ 1869 | __color_delim, __color_bg, __separator, \ 1870 | __items) 1871 | #define weechat_bar_set(__bar, __property, __value) \ 1872 | (weechat_plugin->bar_set)(__bar, __property, __value) 1873 | #define weechat_bar_update(__name) \ 1874 | (weechat_plugin->bar_update)(__name) 1875 | #define weechat_bar_remove(__bar) \ 1876 | (weechat_plugin->bar_remove)(__bar) 1877 | 1878 | /* command */ 1879 | #define weechat_command(__buffer, __command) \ 1880 | (weechat_plugin->command)(weechat_plugin, __buffer, __command) 1881 | 1882 | /* network */ 1883 | #define weechat_network_pass_proxy(__proxy, __sock, __address, __port) \ 1884 | (weechat_plugin->network_pass_proxy)(__proxy, __sock, __address, \ 1885 | __port) 1886 | #define weechat_network_connect_to(__proxy, __address, \ 1887 | __address_length) \ 1888 | (weechat_plugin->network_connect_to)(__proxy, __address, \ 1889 | __address_length) 1890 | 1891 | /* infos */ 1892 | #define weechat_info_get(__info_name, __arguments) \ 1893 | (weechat_plugin->info_get)(weechat_plugin, __info_name, \ 1894 | __arguments) 1895 | #define weechat_info_get_hashtable(__info_name, __hashtable) \ 1896 | (weechat_plugin->info_get_hashtable)(weechat_plugin, __info_name, \ 1897 | __hashtable) 1898 | 1899 | /* infolists */ 1900 | #define weechat_infolist_new() \ 1901 | (weechat_plugin->infolist_new)(weechat_plugin) 1902 | #define weechat_infolist_new_item(__list) \ 1903 | (weechat_plugin->infolist_new_item)(__list) 1904 | #define weechat_infolist_new_var_integer(__item, __name, __value) \ 1905 | (weechat_plugin->infolist_new_var_integer)(__item, __name, __value) 1906 | #define weechat_infolist_new_var_string(__item, __name, __value) \ 1907 | (weechat_plugin->infolist_new_var_string)(__item, __name, __value) 1908 | #define weechat_infolist_new_var_pointer(__item, __name, __pointer) \ 1909 | (weechat_plugin->infolist_new_var_pointer)(__item, __name, \ 1910 | __pointer) 1911 | #define weechat_infolist_new_var_buffer(__item, __name, __buffer, \ 1912 | __size) \ 1913 | (weechat_plugin->infolist_new_var_buffer)(__item, __name, __buffer, \ 1914 | __size) 1915 | #define weechat_infolist_new_var_time(__item, __name, __time) \ 1916 | (weechat_plugin->infolist_new_var_time)(__item, __name, __time) 1917 | #define weechat_infolist_search_var(__list, __name) \ 1918 | (weechat_plugin->infolist_search_var)(__list, __name) 1919 | #define weechat_infolist_get(__infolist_name, __pointer, __arguments) \ 1920 | (weechat_plugin->infolist_get)(weechat_plugin, __infolist_name, \ 1921 | __pointer, __arguments) 1922 | #define weechat_infolist_next(__list) \ 1923 | (weechat_plugin->infolist_next)(__list) 1924 | #define weechat_infolist_prev(__list) \ 1925 | (weechat_plugin->infolist_prev)(__list) 1926 | #define weechat_infolist_reset_item_cursor(__list) \ 1927 | (weechat_plugin->infolist_reset_item_cursor)(__list) 1928 | #define weechat_infolist_fields(__list) \ 1929 | (weechat_plugin->infolist_fields)(__list) 1930 | #define weechat_infolist_integer(__item, __var) \ 1931 | (weechat_plugin->infolist_integer)(__item, __var) 1932 | #define weechat_infolist_string(__item, __var) \ 1933 | (weechat_plugin->infolist_string)(__item, __var) 1934 | #define weechat_infolist_pointer(__item, __var) \ 1935 | (weechat_plugin->infolist_pointer)(__item, __var) 1936 | #define weechat_infolist_buffer(__item, __var, __size) \ 1937 | (weechat_plugin->infolist_buffer)(__item, __var, __size) 1938 | #define weechat_infolist_time(__item, __var) \ 1939 | (weechat_plugin->infolist_time)(__item, __var) 1940 | #define weechat_infolist_free(__list) \ 1941 | (weechat_plugin->infolist_free)(__list) 1942 | 1943 | /* hdata */ 1944 | #define weechat_hdata_new(__hdata_name, __var_prev, __var_next, \ 1945 | __create_allowed, __delete_allowed, \ 1946 | __callback_update, __callback_update_data) \ 1947 | (weechat_plugin->hdata_new)(weechat_plugin, __hdata_name, \ 1948 | __var_prev, __var_next, \ 1949 | __create_allowed, __delete_allowed, \ 1950 | __callback_update, \ 1951 | __callback_update_data) 1952 | #define weechat_hdata_new_var(__hdata, __name, __offset, __type, \ 1953 | __update_allowed, __array_size, \ 1954 | __hdata_name) \ 1955 | (weechat_plugin->hdata_new_var)(__hdata, __name, __offset, __type, \ 1956 | __update_allowed, __array_size, \ 1957 | __hdata_name) 1958 | #define WEECHAT_HDATA_VAR(__struct, __name, __type, __update_allowed, \ 1959 | __array_size, __hdata_name) \ 1960 | weechat_hdata_new_var (hdata, #__name, offsetof (__struct, __name), \ 1961 | WEECHAT_HDATA_##__type, __update_allowed, \ 1962 | __array_size, __hdata_name) 1963 | #define weechat_hdata_new_list(__hdata, __name, __pointer, __flags) \ 1964 | (weechat_plugin->hdata_new_list)(__hdata, __name, __pointer, \ 1965 | __flags) 1966 | #define WEECHAT_HDATA_LIST(__name, __flags) \ 1967 | weechat_hdata_new_list (hdata, #__name, &(__name), __flags); 1968 | #define weechat_hdata_get(__hdata_name) \ 1969 | (weechat_plugin->hdata_get)(weechat_plugin, __hdata_name) 1970 | #define weechat_hdata_get_var_offset(__hdata, __name) \ 1971 | (weechat_plugin->hdata_get_var_offset)(__hdata, __name) 1972 | #define weechat_hdata_get_var_type(__hdata, __name) \ 1973 | (weechat_plugin->hdata_get_var_type)(__hdata, __name) 1974 | #define weechat_hdata_get_var_type_string(__hdata, __name) \ 1975 | (weechat_plugin->hdata_get_var_type_string)(__hdata, __name) 1976 | #define weechat_hdata_get_var_array_size(__hdata, __pointer, __name) \ 1977 | (weechat_plugin->hdata_get_var_array_size)(__hdata, __pointer, \ 1978 | __name) 1979 | #define weechat_hdata_get_var_array_size_string(__hdata, __pointer, \ 1980 | __name) \ 1981 | (weechat_plugin->hdata_get_var_array_size_string)(__hdata, \ 1982 | __pointer, \ 1983 | __name) 1984 | #define weechat_hdata_get_var_hdata(__hdata, __name) \ 1985 | (weechat_plugin->hdata_get_var_hdata)(__hdata, __name) 1986 | #define weechat_hdata_get_var(__hdata, __pointer, __name) \ 1987 | (weechat_plugin->hdata_get_var)(__hdata, __pointer, __name) 1988 | #define weechat_hdata_get_var_at_offset(__hdata, __pointer, __offset) \ 1989 | (weechat_plugin->hdata_get_var_at_offset)(__hdata, __pointer, \ 1990 | __offset) 1991 | #define weechat_hdata_get_list(__hdata, __name) \ 1992 | (weechat_plugin->hdata_get_list)(__hdata, __name) 1993 | #define weechat_hdata_check_pointer(__hdata, __list, __pointer) \ 1994 | (weechat_plugin->hdata_check_pointer)(__hdata, __list, __pointer) 1995 | #define weechat_hdata_move(__hdata, __pointer, __count) \ 1996 | (weechat_plugin->hdata_move)(__hdata, __pointer, __count) 1997 | #define weechat_hdata_search(__hdata, __pointer, __search, __move) \ 1998 | (weechat_plugin->hdata_search)(__hdata, __pointer, __search, \ 1999 | __move) 2000 | #define weechat_hdata_char(__hdata, __pointer, __name) \ 2001 | (weechat_plugin->hdata_char)(__hdata, __pointer, __name) 2002 | #define weechat_hdata_integer(__hdata, __pointer, __name) \ 2003 | (weechat_plugin->hdata_integer)(__hdata, __pointer, __name) 2004 | #define weechat_hdata_long(__hdata, __pointer, __name) \ 2005 | (weechat_plugin->hdata_long)(__hdata, __pointer, __name) 2006 | #define weechat_hdata_string(__hdata, __pointer, __name) \ 2007 | (weechat_plugin->hdata_string)(__hdata, __pointer, __name) 2008 | #define weechat_hdata_pointer(__hdata, __pointer, __name) \ 2009 | (weechat_plugin->hdata_pointer)(__hdata, __pointer, __name) 2010 | #define weechat_hdata_time(__hdata, __pointer, __name) \ 2011 | (weechat_plugin->hdata_time)(__hdata, __pointer, __name) 2012 | #define weechat_hdata_hashtable(__hdata, __pointer, __name) \ 2013 | (weechat_plugin->hdata_hashtable)(__hdata, __pointer, __name) 2014 | #define weechat_hdata_compare(__hdata, __pointer1, __pointer2, __name, \ 2015 | __case_sensitive) \ 2016 | (weechat_plugin->hdata_compare)(__hdata, __pointer1, __pointer2, \ 2017 | __name, __case_sensitive) 2018 | #define weechat_hdata_set(__hdata, __pointer, __name, __value) \ 2019 | (weechat_plugin->hdata_set)(__hdata, __pointer, __name, __value) 2020 | #define weechat_hdata_update(__hdata, __pointer, __hashtable) \ 2021 | (weechat_plugin->hdata_update)(__hdata, __pointer, __hashtable) 2022 | #define weechat_hdata_get_string(__hdata, __property) \ 2023 | (weechat_plugin->hdata_get_string)(__hdata, __property) 2024 | 2025 | /* upgrade */ 2026 | #define weechat_upgrade_new(__filename, __callback_read, \ 2027 | __callback_read_pointer, \ 2028 | __callback_read_data) \ 2029 | (weechat_plugin->upgrade_new)(__filename, __callback_read, \ 2030 | __callback_read_pointer, \ 2031 | __callback_read_data) 2032 | #define weechat_upgrade_write_object(__upgrade_file, __object_id, \ 2033 | __infolist) \ 2034 | (weechat_plugin->upgrade_write_object)(__upgrade_file, __object_id, \ 2035 | __infolist) 2036 | #define weechat_upgrade_read(__upgrade_file) \ 2037 | (weechat_plugin->upgrade_read)(__upgrade_file) 2038 | #define weechat_upgrade_close(__upgrade_file) \ 2039 | (weechat_plugin->upgrade_close)(__upgrade_file) 2040 | 2041 | #ifdef __cplusplus 2042 | } 2043 | #endif /* __cplusplus */ 2044 | 2045 | #endif /* WEECHAT_WEECHAT_PLUGIN_H */ 2046 | -------------------------------------------------------------------------------- /default.nix: -------------------------------------------------------------------------------- 1 | { mkDerivation, aeson, async, base, bytestring, conduit 2 | , conduit-combinators, conduit-extra, lens, monads-tf 3 | , mono-traversable, process, reactive-banana, rio, stdenv, stm 4 | , stm-conduit, text, transformers, typed-process 5 | , weechat 6 | , hie, apply-refact, brittany, hsimport 7 | }: 8 | mkDerivation { 9 | pname = "keywee"; 10 | version = "0.0.1.0"; 11 | src = ./.; 12 | libraryHaskellDepends = [ 13 | aeson async base bytestring conduit conduit-combinators 14 | conduit-extra lens monads-tf mono-traversable process 15 | reactive-banana rio stm stm-conduit text transformers typed-process 16 | ]; 17 | buildTools = [ hie apply-refact hsimport ]; 18 | homepage = "http://github.com/jkopanski/keywee#readme"; 19 | description = "Keybase chat plugin for WeeChat"; 20 | license = stdenv.lib.licenses.gpl3; 21 | } 22 | -------------------------------------------------------------------------------- /keywee.cabal: -------------------------------------------------------------------------------- 1 | name: keywee 2 | version: 0.0.1.0 3 | synopsis: Keybase chat plugin for WeeChat 4 | description: Please see README.md 5 | homepage: http://github.com/jkopanski/keywee#readme 6 | license: GPL-3 7 | license-file: LICENSE 8 | author: Jakub Kopański 9 | maintainer: jkopansk@gmail.com 10 | copyright: Copyright (c) 2017 Jakub Kopński 11 | category: IRC Client, Network, Plugin 12 | build-type: Simple 13 | cabal-version: >=1.10 14 | 15 | library 16 | hs-source-dirs: src 17 | exposed-modules: 18 | Keybase 19 | Keybase.Chat 20 | Keybase.Chat.Monad 21 | Keybase.Chat.Request 22 | Keybase.Chat.Types 23 | other-modules: 24 | Data.Conduit.Process.Typed.Flush 25 | default-language: Haskell2010 26 | default-extensions: 27 | BangPatterns 28 | , DeriveGeneric 29 | , LambdaCase 30 | , NoImplicitPrelude 31 | , OverloadedStrings 32 | build-depends: 33 | base >= 4.7 && < 5 34 | , aeson 35 | , async >= 2.1 && < 2.3 36 | , bytestring >= 0.10 && < 0.11 37 | , conduit >= 1.2 && < 1.4 38 | , conduit-combinators 39 | , conduit-extra >= 1.1 && < 1.4 40 | , lens 41 | , monads-tf >= 0.1 && < 0.2 42 | , mono-traversable >= 1.0 && < 1.1 43 | , process >= 1.4 && < 1.7 44 | , rio 45 | , stm >= 2.4 && < 2.6 46 | , stm-conduit 47 | , text >= 1.2 && < 1.3 48 | , transformers >= 0.5 && < 0.6 49 | , typed-process 50 | , reactive-banana 51 | 52 | foreign-library keywee 53 | type: native-shared 54 | lib-version-info: 0:0:1 55 | hs-source-dirs: plugin 56 | other-modules: 57 | FRP 58 | Plugin 59 | WeeChat.Buffer 60 | WeeChat.FFI 61 | WeeChat.Types 62 | c-sources: cbits/keywee.c 63 | include-dirs: cbits/ 64 | default-language: Haskell2010 65 | default-extensions: 66 | OverloadedStrings 67 | ghc-options: 68 | -threaded 69 | -dynamic 70 | build-depends: 71 | base >= 4.7 && < 5 72 | , aeson 73 | , async 74 | , bytestring >= 0.10 && < 0.11 75 | , containers 76 | , keywee 77 | , lens 78 | , monads-tf >= 0.1 && < 0.2 79 | , rio 80 | , stm >= 2.4 && < 2.6 81 | , text >= 1.2 && < 1.3 82 | , transformers >= 0.5 && < 0.6 83 | , reactive-banana 84 | 85 | executable pipe 86 | hs-source-dirs: plugin 87 | main-is: Main.hs 88 | default-language: Haskell2010 89 | include-dirs: cbits/ 90 | other-modules: 91 | FRP 92 | WeeChat.Buffer 93 | WeeChat.FFI 94 | WeeChat.Types 95 | ghc-options: 96 | -threaded 97 | -debug 98 | default-extensions: 99 | DeriveGeneric 100 | , OverloadedStrings 101 | build-depends: 102 | base >= 4.7 && < 5 103 | , aeson 104 | , async >= 2.1 && < 2.3 105 | , bytestring >= 0.10 && < 0.11 106 | , conduit >= 1.2 && < 1.4 107 | , conduit-extra >= 1.1 && < 1.4 108 | , containers 109 | , keywee 110 | , lens 111 | , monads-tf >= 0.1 && < 0.2 112 | , mono-traversable >= 1.0 && < 1.1 113 | , process >= 1.4 && < 1.7 114 | , rio 115 | , stm >= 2.4 && < 2.6 116 | , text >= 1.2 && < 1.3 117 | , transformers >= 0.5 && < 0.6 118 | , reactive-banana 119 | 120 | 121 | -- test-suite keywee-tests 122 | -- type: exitcode-stdio-1.0 123 | -- hs-source-dirs: test 124 | -- main-is: Test.hs 125 | -- default-language: Haskell2010 126 | -- default-extensions: OverloadedStrings 127 | -- build-depends: 128 | -- base >= 4.7 && < 5 129 | -- , QuickCheck >= 2.8 && < 2.9 130 | -- , smallcheck >= 1.1 && < 1.2 131 | -- , tasty >= 0.11 && < 0.12 132 | -- , tasty-hunit >= 0.9 && < 0.10 133 | -- , tasty-quickcheck >= 0.8 && < 0.9 134 | -- , tasty-smallcheck >= 0.8 && < 0.9 135 | -- , test-invariant >= 0.4 && < 0.5 136 | -- , transformers >= 0.4 && < 0.5 137 | -- ghc-options: -threaded 138 | -------------------------------------------------------------------------------- /keywee.scm: -------------------------------------------------------------------------------- 1 | (use-modules (guix) 2 | (guix build-system haskell) 3 | (guix licenses) 4 | (guix packages) 5 | (gnu packages haskell) 6 | (nat guix packages haskell)) 7 | 8 | (package (inherit haskell-project) 9 | (name "ghc-keywee") 10 | (version "0.0.1.0") 11 | (source (local-file "./.")) 12 | (build-system haskell-build-system) 13 | (inputs 14 | `(("ghc-aeson" ,ghc-aeson) 15 | ("ghc-async" ,ghc-async) 16 | ("ghc-conduit" ,ghc-conduit) 17 | ("ghc-conduit-combinators" ,ghc-conduit-combinators) 18 | ("ghc-conduit-extra" ,ghc-conduit-extra) 19 | ("ghc-mono-traversable" ,ghc-mono-traversable) 20 | ("ghc-semigroups" ,ghc-semigroups) 21 | ("ghc-text" ,ghc-text) 22 | ("ghc-process" ,ghc-process) 23 | ("ghc-wires" ,ghc-wires))) 24 | (home-page 25 | "http://github.com/jkopanski/keywee#readme") 26 | (synopsis "Keybase chat plugin for WeeChat") 27 | (description "Please see README.md") 28 | (license gpl3)) 29 | -------------------------------------------------------------------------------- /plugin/FRP.hs: -------------------------------------------------------------------------------- 1 | {-# language 2 | DuplicateRecordFields 3 | , OverloadedStrings 4 | , RecursiveDo 5 | , ScopedTypeVariables #-} 6 | module FRP where 7 | 8 | import Prelude hiding (empty, id, lookup, read) 9 | import RIO ((.), ($), (<$), ($>), (>>=), (>=>) 10 | , RIO 11 | , asks, foldM, forever, runRIO, when 12 | ) 13 | import Control.Concurrent.Async (async) 14 | import Control.Concurrent.STM.TQueue (newTQueue, readTQueue, writeTQueue) 15 | import Control.Lens (view) 16 | import Control.Monad.STM (atomically) 17 | import Data.Aeson (toEncoding) 18 | import Data.Map 19 | import Data.Semigroup ((<>)) 20 | import Data.Text (Text, unpack) 21 | 22 | import Reactive.Banana hiding (empty) 23 | import Reactive.Banana.Frameworks 24 | import System.IO (IO, hClose, hPutStr, stderr) 25 | 26 | import Keybase.Chat 27 | import qualified WeeChat.Buffer as WC 28 | 29 | -- Program state 30 | type Id = Text 31 | type Buffers = Map Id WC.Buffer 32 | 33 | -- type Handler a = a -> IO () 34 | type EventSource a = (AddHandler a, a -> IO ()) 35 | 36 | addHandler :: EventSource a -> AddHandler a 37 | addHandler = fst 38 | 39 | fire :: EventSource a -> a -> IO () 40 | fire = snd 41 | 42 | registerApiResponse :: HasApi env => RIO env (AddHandler Response) 43 | registerApiResponse = do 44 | res <- asks (view response) 45 | (addHandler, fire) <- liftIO newAddHandler 46 | liftIO $ async $ forever (atomically (readTQueue res) >>= fire) 47 | pure addHandler 48 | 49 | -- TODO: How To pass API as RIO env? 50 | frpNetwork :: API -> EventSource Request -> MomentIO () 51 | frpNetwork api esreq = mdo 52 | -- obtain input events 53 | ereq <- fromAddHandler (addHandler esreq) 54 | eres <- liftIO (runRIO api registerApiResponse) >>= fromAddHandler 55 | 56 | let req = input api 57 | res = output api 58 | (eError, eResult) = splitResponse eres 59 | eInbox = let isInbox Inbox{} = True 60 | isInbox _ = False 61 | in filterE isInbox eResult 62 | eMsgs = let areMsgs Messages{} = True 63 | areMsgs _ = False 64 | in filterE areMsgs eResult 65 | 66 | -- split single Inbox event to separate Conversation events 67 | -- Inbox { conversations :: [Conversation] } 68 | (eConv, fireConv) <- newEvent 69 | reactimate $ (sequence_ . fmap fireConv) . conversations <$> eInbox 70 | 71 | -- filter out conversations that already have opened buffers 72 | let eNewConversation = filterApply ((\b c -> not $ member (id c) b) <$> bBuffers) eConv 73 | (eNewBuf, fireNewBuf) <- newEvent 74 | -- open new buffer for each conversation and fire appropriate action 75 | reactimate $ (makeBuffer >=> fireNewBuf) <$> eNewConversation 76 | 77 | -- kep tabs on opened buffers 78 | let insertBuffer :: WC.Buffer -> Buffers -> Buffers 79 | insertBuffer buf = insert (WC.id buf) buf 80 | (bBuffers :: Behavior Buffers) 81 | <- accumB empty $ insertBuffer <$> eNewBuf 82 | 83 | -- get messages for newly opened buffers 84 | let eFirstRead = read . WC.id <$> eNewBuf 85 | reactimate $ fire esreq <$> eFirstRead 86 | -- test msgs 87 | reactimate $ (hPutStr stderr . show . toEncoding) <$> eMsgs 88 | 89 | -- fire separate action for each conversation 90 | reactimate $ (atomically . writeTQueue req) <$> ereq 91 | reactimate $ hPutStr stderr . unpack <$> eError 92 | -- reactimate $ hPutStr stderr . show . toEncoding <$> ereq 93 | -- reactimate $ hPutStr stderr . show . toEncoding <$> eres 94 | 95 | splitResponse :: Event Response -> (Event Text, Event Result) 96 | splitResponse e = 97 | ( filterJust $ fromError <$> e 98 | , filterJust $ fromResult <$> e 99 | ) where fromError (Error err) = Just err 100 | fromError (Result _) = Nothing 101 | fromResult (Error _) = Nothing 102 | fromResult (Result res) = Just res 103 | 104 | makeBuffer :: MonadIO m => Conversation -> m WC.Buffer 105 | makeBuffer conv = do 106 | let chanName = name $ channel conv 107 | ident = id conv 108 | handle <- liftIO $ WC.newBuffer chanName 109 | pure $ WC.Buffer ident chanName handle 110 | -------------------------------------------------------------------------------- /plugin/Main.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import RIO ((.), ($), (<$), ($>), (>>=) 4 | , RIO 5 | , asks, forever, runRIO, when 6 | ) 7 | 8 | import Control.Concurrent (threadDelay) 9 | import Control.Concurrent.Async (async) 10 | import Control.Concurrent.STM.TQueue (newTQueue, readTQueue, writeTQueue) 11 | import Control.Lens (view) 12 | import Control.Monad.STM (atomically) 13 | import Reactive.Banana 14 | import Reactive.Banana.Frameworks 15 | import System.IO (IO, hClose) 16 | 17 | import FRP hiding (frpNetwork) 18 | import Keybase.Chat 19 | 20 | -- TODO: How To pass API as RIO env? 21 | frpNetwork :: API -> EventSource Request -> MomentIO () 22 | frpNetwork api esreq = do 23 | -- obtain input events 24 | ereq <- fromAddHandler (addHandler esreq) 25 | eres <- liftIO (runRIO api registerApiResponse) >>= fromAddHandler 26 | 27 | let req = input api 28 | res = output api 29 | 30 | reactimate $ (atomically . writeTQueue req) <$> ereq 31 | reactimate $ putStrLn . show <$> eres 32 | 33 | eventLoop :: EventSource Request -> IO () 34 | eventLoop esreq = do 35 | putStrLn "Enter keybase chat api commands." 36 | putStrLn "Enter \"exit\" to exit." 37 | 38 | loop 39 | where loop = do 40 | s <- getLine 41 | case s of 42 | "list" -> fire esreq (Request List Nothing) 43 | "exit" -> pure () 44 | 45 | when (s /= "exit") loop 46 | 47 | main :: IO () 48 | main = do 49 | -- setup commmunication queues 50 | req <- atomically newTQueue 51 | res <- atomically newTQueue 52 | let chatApi = API req res 53 | 54 | runRIO chatApi open 55 | putStrLn "connection opened" 56 | 57 | sources <- newAddHandler 58 | network <- compile (frpNetwork chatApi sources) 59 | actuate network 60 | eventLoop sources 61 | 62 | -------------------------------------------------------------------------------- /plugin/Plugin.hs: -------------------------------------------------------------------------------- 1 | {-# language 2 | ForeignFunctionInterface 3 | , OverloadedStrings #-} 4 | module Plugin where 5 | 6 | import Prelude hiding (init) 7 | import RIO (runRIO) 8 | import Control.Concurrent.STM.TQueue (newTQueue) 9 | import Control.Monad.STM (STM, atomically) 10 | import System.IO (IO) 11 | 12 | import Reactive.Banana 13 | import Reactive.Banana.Frameworks 14 | 15 | import FRP 16 | import Keybase.Chat 17 | import WeeChat.Buffer 18 | 19 | foreign export ccall keyweeInit :: IO () 20 | 21 | keyweeInit :: IO () 22 | keyweeInit = do 23 | req <- atomically newTQueue 24 | res <- atomically newTQueue 25 | let chatApi = API req res 26 | runRIO chatApi open 27 | 28 | sources <- newAddHandler 29 | network <- compile (frpNetwork chatApi sources) 30 | actuate network 31 | 32 | -- get conversations on init 33 | fire sources list 34 | pure () 35 | -------------------------------------------------------------------------------- /plugin/WeeChat/Buffer.hs: -------------------------------------------------------------------------------- 1 | module WeeChat.Buffer 2 | where 3 | 4 | import Prelude (($)) 5 | import Foreign.C.String 6 | import Foreign.Ptr 7 | import Data.Text (Text) 8 | import qualified Data.Text as T 9 | import System.IO (IO) 10 | 11 | import WeeChat.FFI 12 | 13 | data Buffer = Buffer 14 | { id :: Text 15 | , name :: Text 16 | , handle :: BufferHandle 17 | } 18 | 19 | -- mkInputCb :: 20 | newBuffer :: Text -> IO BufferHandle 21 | newBuffer name = withCString (T.unpack name) $ \cname -> kw_buffer_new cname my_input_cb nullPtr nullPtr my_close_cb nullPtr nullPtr 22 | 23 | bPrint :: Text -> BufferHandle -> IO () 24 | bPrint msg buf = withCString (T.unpack msg) $ \cmsg -> kw_buffer_printf buf cmsg 25 | -------------------------------------------------------------------------------- /plugin/WeeChat/FFI.hs: -------------------------------------------------------------------------------- 1 | {-# language 2 | CApiFFI 3 | , EmptyDataDecls 4 | , ForeignFunctionInterface #-} 5 | module WeeChat.FFI where 6 | 7 | import Prelude (IO) 8 | 9 | import Foreign.C.String 10 | import Foreign.C.Types 11 | import Foreign.Ptr 12 | 13 | import WeeChat.Types 14 | 15 | type InputBufferCb = Ptr () -> Ptr () -> BufferHandle -> CString -> IO RC 16 | type CloseBufferCb = Ptr () -> Ptr () -> BufferHandle -> IO RC 17 | 18 | type PluginHandle = Ptr Plugin 19 | type BufferHandle = Ptr Buffer 20 | 21 | -- foreign import ccall "kw_buffer_new" 22 | -- kw_buffer_new :: CString -> FunPtr InputBufferCb -> FunPtr CloseBufferCb -> IO BufferHandle 23 | 24 | foreign import capi "weechat/weechat-plugin.h weechat_buffer_new" 25 | kw_buffer_new :: CString 26 | -> FunPtr InputBufferCb -> Ptr () -> Ptr () 27 | -> FunPtr CloseBufferCb -> Ptr () -> Ptr () 28 | -> IO BufferHandle 29 | 30 | foreign import capi "keywee.h &my_input_cb" my_input_cb :: FunPtr InputBufferCb 31 | 32 | foreign import capi "keywee.h &my_close_cb" my_close_cb :: FunPtr CloseBufferCb 33 | 34 | foreign import capi "keywee.h value weechat_plugin" weechat_plugin :: PluginHandle 35 | 36 | -- foreign import ccall "wrapper kw_buffer_new" 37 | -- kw_buffer_new :: CString -> IO BufferHandle 38 | -------------------------------------------------------------------------------- /plugin/WeeChat/Monad.hs: -------------------------------------------------------------------------------- 1 | module WeeChat.Monad where 2 | 3 | import FRP 4 | 5 | import Control.Lens (Lens', lens) 6 | import Control.Concurrent.STM.TQueue (TQueue) 7 | 8 | import Keybase.Chat 9 | 10 | class HasEventSource env where 11 | eventSource :: Lens' env (EventSource Request) 12 | 13 | instance HasEventSource ES where 14 | eventSource = lens esreq (\a es -> a { esreq = es }) 15 | 16 | data ES = ES { esreq :: !(EventSource Request) } 17 | -------------------------------------------------------------------------------- /plugin/WeeChat/Types.hsc: -------------------------------------------------------------------------------- 1 | {-# language 2 | CApiFFI 3 | , EmptyDataDecls 4 | , ForeignFunctionInterface #-} 5 | module WeeChat.Types where 6 | 7 | import Foreign.C.Types 8 | import Foreign.Ptr (Ptr) 9 | 10 | #include 11 | 12 | newtype RC = RC { rc :: CInt } 13 | #{enum RC, RC 14 | , pluginOk = WEECHAT_RC_OK 15 | , pluginOkEat = WEECHAT_RC_OK_EAT 16 | , pluginError = WEECHAT_RC_ERROR 17 | } 18 | 19 | data {-# CTYPE "weechat/weechat-plugin.h" "struct t_gui_buffer" #-} Buffer 20 | data {-# CTYPE "weechat/weechat-plugin.h" "struct t_weechat_plugin" #-} Plugin 21 | -------------------------------------------------------------------------------- /release.nix: -------------------------------------------------------------------------------- 1 | { compiler ? "ghc863" }: 2 | 3 | let 4 | config = { 5 | packageOverrides = pkgs: rec { 6 | haskell = pkgs.haskell // { 7 | packages = pkgs.haskell.packages // { 8 | "${compiler}" = pkgs.haskell.packages."${compiler}".override { 9 | overrides = haskellPackagesNew: haskellPackagesOld: rec { 10 | hie = (import (fetchTarball { 11 | url = https://github.com/domenkozar/hie-nix/tarball/master/domenkozar-hie-nix-6794005.tar.gz; 12 | sha256 = "0pc90ns0xcsa6b630d8kkq5zg8yzszbgd7qmnylkqpa0l58zvnpn"; 13 | }) {}).hie86; 14 | keywee = pkgs.haskell.lib.dontHaddock 15 | ( 16 | haskellPackagesNew.callPackage ./default.nix { } 17 | ); 18 | reactive-banana = pkgs.haskell.lib.doJailbreak 19 | haskellPackagesOld.reactive-banana; 20 | brittany = pkgs.haskell.lib.doJailbreak 21 | haskellPackagesOld.brittany; 22 | multistate = pkgs.haskell.lib.doJailbreak 23 | haskellPackagesOld.multistate; 24 | hsimport = pkgs.haskell.lib.doJailbreak 25 | haskellPackagesOld.hsimport; 26 | }; 27 | }; 28 | }; 29 | }; 30 | }; 31 | }; 32 | 33 | pkgs = import { inherit config; }; 34 | 35 | in 36 | { keywee = pkgs.haskell.packages.${compiler}.keywee; 37 | } 38 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | (import ./release.nix {}).keywee.env 2 | -------------------------------------------------------------------------------- /src/Data/Conduit/Process/Typed/Flush.hs: -------------------------------------------------------------------------------- 1 | {-# language 2 | DataKinds 3 | , TypeFamilies #-} 4 | module Data.Conduit.Process.Typed.Flush 5 | ( sourceTQueue 6 | , sinkTQueue 7 | , createSinkFlush 8 | , flush 9 | ) where 10 | 11 | import Control.Concurrent.STM.TQueue (TQueue, readTQueue, writeTQueue) 12 | import Control.Monad (Monad, (>>=), fmap, forever) 13 | import Control.Monad.IO.Class (MonadIO, liftIO) 14 | import Control.Monad.STM (STM, atomically) 15 | 16 | import qualified Data.ByteString as S 17 | import Data.Conduit (ConduitM, yield) 18 | import qualified Data.Conduit as C 19 | import qualified Data.Conduit.Binary as CB 20 | import qualified Data.Conduit.Combinators as CC 21 | import qualified Data.Conduit.List as CL 22 | import Data.Conduit.Process.Typed (createPipe) 23 | import Data.Function ((.), ($)) 24 | import qualified Data.Sequences as Seq 25 | import Data.Void (Void) 26 | import System.Process.Typed (StreamSpec, StreamType (STInput)) 27 | import System.IO (hClose) 28 | 29 | -- | The 3 functions below were taken from stm-conduit which is BSD3 licensed 30 | -- | Copyright (c) Clark Gaebel 31 | -- | TODO: remove after version bump on stackage 32 | -- | A simple wrapper around a "TQueue". As data is pushed into the queue, the 33 | -- source will read it and pass it down the conduit pipeline. 34 | sourceTQueue :: MonadIO m => TQueue a -> ConduitM () a m () 35 | sourceTQueue q = forever $ liftSTM (readTQueue q) >>= yield 36 | 37 | sinkTQueue :: MonadIO m => TQueue a -> ConduitM a Void m () 38 | sinkTQueue q = CL.mapM_ (liftSTM . writeTQueue q) 39 | 40 | liftSTM :: MonadIO m => STM a -> m a 41 | liftSTM = liftIO . atomically 42 | 43 | -- | Alternative to default @createSink@ from @Data.Conduit.Process.Typed@ 44 | -- that creates sink that can be flushed 45 | createSinkFlush :: MonadIO m => StreamSpec 'STInput (ConduitM (C.Flush S.ByteString) o m ()) 46 | createSinkFlush = CB.sinkHandleFlush `fmap` createPipe 47 | 48 | flush :: Monad m => ConduitM (C.Flush a) (C.Flush a) m () 49 | flush = CC.concatMap (: (Seq.singleton C.Flush)) 50 | -------------------------------------------------------------------------------- /src/Keybase.hs: -------------------------------------------------------------------------------- 1 | module Keybase where 2 | 3 | import Data.Text (Text) 4 | import Data.Aeson (FromJSON (..), ToJSON (..), 5 | genericParseJSON, genericToEncoding, genericToJSON) 6 | import qualified Keybase.Chat as Chat 7 | 8 | -- data Response 9 | -- = Error { error :: Text } 10 | -- | Result { result :: Chat.Result } 11 | -- deriving (Generic, Eq) 12 | -- instance FromJSON Response where 13 | -- parseJSON = genericParseJSON Chat.options 14 | -- instance ToJSON Response where 15 | -- toJSON = genericToJSON Chat.options 16 | -- toEncoding = genericToEncoding Chat.options 17 | -------------------------------------------------------------------------------- /src/Keybase/Chat.hs: -------------------------------------------------------------------------------- 1 | module Keybase.Chat 2 | ( module Keybase.Chat.Monad 3 | , module Keybase.Chat.Request 4 | , module Keybase.Chat.Types 5 | , open 6 | ) where 7 | 8 | import Prelude ((.), ($), IO) 9 | import RIO (RIO, asks) 10 | 11 | import Control.Applicative (pure) 12 | import Control.Concurrent.Async (async, mapConcurrently_) 13 | import Control.Concurrent.STM.TQueue (TQueue, readTQueue) 14 | import Control.Lens (view) 15 | import Control.Monad.IO.Class (MonadIO, liftIO) 16 | 17 | import Data.Aeson (decode, encode) 18 | import Data.ByteString (ByteString) 19 | import qualified Data.ByteString.Char8 as S8 20 | import qualified Data.ByteString.Lazy as LBS 21 | import Data.Conduit (ConduitM, (.|), runConduit) 22 | import qualified Data.Conduit as C 23 | import qualified Data.Conduit.List as CL 24 | import Data.Conduit.Process.Typed (createSource, withProcess_) 25 | import Data.Maybe (Maybe) 26 | import Data.Void (Void) 27 | import System.Process.Typed (proc 28 | ,getStderr, getStdin, getStdout 29 | ,setStderr, setStdin, setStdout 30 | ) 31 | import System.IO (stderr) 32 | 33 | import Data.Conduit.Process.Typed.Flush 34 | import Keybase.Chat.Monad 35 | import Keybase.Chat.Request 36 | import Keybase.Chat.Types 37 | 38 | open :: HasApi env => RIO env () 39 | open = do 40 | let chat = setStdin createSinkFlush 41 | $ setStdout createSource 42 | $ setStderr createSource 43 | $ proc "keybase" ["chat", "api"] 44 | 45 | req <- asks (view command) 46 | res <- asks (view response) 47 | 48 | _ <- liftIO $ async $ 49 | withProcess_ chat $ \p -> 50 | let input :: ConduitM () Void IO () 51 | input = sourceTQueue req 52 | .| CL.map (C.Chunk . LBS.toStrict . encode) 53 | .| flush 54 | .| getStdin p 55 | 56 | output :: ConduitM () Void IO () 57 | output = getStdout p 58 | .| CL.map (decode . LBS.fromStrict :: ByteString -> Maybe Response) 59 | .| CL.catMaybes 60 | .| sinkTQueue res 61 | 62 | errput :: ConduitM () Void IO () 63 | errput = getStderr p 64 | .| CL.mapM_ (S8.hPutStr stderr) 65 | 66 | in mapConcurrently_ runConduit [input, output, errput] 67 | pure () 68 | -------------------------------------------------------------------------------- /src/Keybase/Chat/Monad.hs: -------------------------------------------------------------------------------- 1 | module Keybase.Chat.Monad where 2 | 3 | import Control.Lens (Lens', lens) 4 | import Control.Concurrent.STM.TQueue (TQueue) 5 | 6 | import Keybase.Chat.Types 7 | 8 | class HasCommand env where 9 | command :: Lens' env (TQueue Request) 10 | 11 | class HasResponse env where 12 | response :: Lens' env (TQueue Response) 13 | 14 | class (HasCommand env, HasResponse env) => HasApi env where 15 | api :: Lens' env API 16 | 17 | instance HasCommand API where 18 | command = lens input (\a cmd -> a { input = cmd }) 19 | 20 | instance HasResponse API where 21 | response = lens output (\a resp -> a { output = resp }) 22 | 23 | instance HasApi API where 24 | api a = a 25 | 26 | data API = API 27 | { input :: !(TQueue Request) 28 | , output :: !(TQueue Response) 29 | } 30 | -------------------------------------------------------------------------------- /src/Keybase/Chat/Request.hs: -------------------------------------------------------------------------------- 1 | module Keybase.Chat.Request where 2 | 3 | import Data.Maybe (Maybe (..)) 4 | 5 | import Keybase.Chat.Types 6 | 7 | list :: Request 8 | list = Request 9 | { method = List 10 | , params = Nothing 11 | } 12 | 13 | read :: ConversationId -> Request 14 | read conv = Request 15 | { method = Read 16 | , params = Just Params 17 | { options = Options { conversation_id = conv} } 18 | } 19 | -------------------------------------------------------------------------------- /src/Keybase/Chat/Types.hs: -------------------------------------------------------------------------------- 1 | {-# language 2 | DeriveGeneric #-} 3 | module Keybase.Chat.Types where 4 | 5 | import Prelude (Bool (..), Enum (..), Eq (..), Ord (..), Show (..), (.)) 6 | import Data.Int (Int) 7 | import Data.Maybe (Maybe, fromMaybe) 8 | import Data.Text (Text, pack, stripPrefix, toLower, unpack) 9 | import Data.Aeson (FromJSON (..), ToJSON (..), 10 | defaultOptions, 11 | genericParseJSON, genericToEncoding, genericToJSON) 12 | import Data.Aeson.Types (SumEncoding(ObjectWithSingleField, TaggedObject), 13 | contentsFieldName, tagFieldName) 14 | import qualified Data.Aeson.Types as A 15 | import qualified GHC.Generics as G 16 | 17 | encOptions :: A.Options 18 | encOptions = defaultOptions 19 | { A.constructorTagModifier = unpack . toLower . pack 20 | , A.omitNothingFields = True 21 | } 22 | 23 | data Existance = Active | Archived | Deleted 24 | deriving (G.Generic, Eq, Enum, Ord, Show) 25 | instance FromJSON Existance where 26 | parseJSON = genericParseJSON encOptions 27 | instance ToJSON Existance where 28 | toJSON = genericToJSON encOptions 29 | toEncoding = genericToEncoding encOptions 30 | 31 | data Members = KBFS | Team | ImpTeamNative | ImpTeamUpgrade 32 | deriving (G.Generic, Eq, Enum, Ord, Show) 33 | instance FromJSON Members where 34 | parseJSON = genericParseJSON encOptions 35 | instance ToJSON Members where 36 | toJSON = genericToJSON encOptions 37 | toEncoding = genericToEncoding encOptions 38 | 39 | data SyncInbox = Current | Incremental | Clear 40 | deriving (G.Generic, Eq, Enum, Ord, Show) 41 | instance FromJSON SyncInbox where 42 | parseJSON = genericParseJSON encOptions 43 | instance ToJSON SyncInbox where 44 | toJSON = genericToJSON encOptions 45 | toEncoding = genericToEncoding encOptions 46 | 47 | strip :: Text -> Text -> Text 48 | strip prefix txt = fromMaybe txt (stripPrefix prefix txt) 49 | 50 | topicOptions :: A.Options 51 | topicOptions = defaultOptions 52 | { A.constructorTagModifier = unpack . strip "topic" . toLower . pack } 53 | 54 | data Topic 55 | = TopicNone 56 | | TopicChat 57 | | TopicDev 58 | deriving (G.Generic, Eq, Enum, Ord, Show) 59 | instance FromJSON Topic where 60 | parseJSON = genericParseJSON topicOptions 61 | instance ToJSON Topic where 62 | toJSON = genericToJSON topicOptions 63 | toEncoding = genericToEncoding topicOptions 64 | 65 | teamOptions :: A.Options 66 | teamOptions = defaultOptions 67 | { A.constructorTagModifier = unpack . strip "team" . toLower . pack } 68 | 69 | data Team 70 | = TeamNone 71 | | TeamSimple 72 | | TeamComplex 73 | deriving (G.Generic, Eq, Enum, Ord, Show) 74 | instance FromJSON Team where 75 | parseJSON = genericParseJSON teamOptions 76 | instance ToJSON Team where 77 | toJSON = genericToJSON teamOptions 78 | toEncoding = genericToEncoding teamOptions 79 | 80 | data Notification = Generic | AtMention 81 | deriving (G.Generic, Eq, Enum, Ord, Show) 82 | instance FromJSON Notification where 83 | parseJSON = genericParseJSON encOptions 84 | instance ToJSON Notification where 85 | toJSON = genericToJSON encOptions 86 | toEncoding = genericToEncoding encOptions 87 | 88 | data Status 89 | = Unfiled 90 | | Favorite 91 | | Ignored 92 | | Blocked 93 | | Muted 94 | | Reported 95 | deriving (G.Generic, Eq, Enum, Ord, Show) 96 | instance FromJSON Status where 97 | parseJSON = genericParseJSON encOptions 98 | instance ToJSON Status where 99 | toJSON = genericToJSON encOptions 100 | toEncoding = genericToEncoding encOptions 101 | 102 | memberOptions :: A.Options 103 | memberOptions = defaultOptions 104 | { A.constructorTagModifier = unpack . strip "member" . toLower . pack } 105 | 106 | data MemberStatus 107 | = MemberActive 108 | | MemberRemoved 109 | | MemberLeft 110 | | MemberPreview 111 | | MemberReset 112 | deriving (G.Generic, Eq, Enum, Ord, Show) 113 | instance FromJSON MemberStatus where 114 | parseJSON = genericParseJSON memberOptions 115 | instance ToJSON MemberStatus where 116 | toJSON = genericToJSON memberOptions 117 | toEncoding = genericToEncoding memberOptions 118 | 119 | data Channel = Channel 120 | { name :: Text 121 | , public :: Bool 122 | , members_type :: Members 123 | , topic_type :: Topic 124 | , topic_name :: Maybe Text 125 | } deriving (G.Generic, Eq, Show) 126 | instance FromJSON Channel 127 | instance ToJSON Channel where 128 | toEncoding = genericToEncoding defaultOptions 129 | 130 | type ConversationId = Text 131 | data Conversation = Conversation 132 | { id :: ConversationId 133 | , channel :: Channel 134 | , unread :: Bool 135 | , active_at :: Int 136 | , active_at_ms :: Int 137 | } deriving (G.Generic, Eq, Show) 138 | instance FromJSON Conversation 139 | instance ToJSON Conversation where 140 | toEncoding = genericToEncoding defaultOptions 141 | 142 | requestOptions :: A.Options 143 | requestOptions = defaultOptions 144 | { A.constructorTagModifier = unpack . strip "member" . toLower . pack 145 | , A.sumEncoding = TaggedObject { contentsFieldName = "params" 146 | , tagFieldName = "method" 147 | } 148 | } 149 | 150 | data Method = Attach 151 | | Delete 152 | | Download 153 | | Edit 154 | | List 155 | | Read 156 | | Send 157 | deriving (G.Generic, Eq, Show) 158 | instance FromJSON Method where 159 | parseJSON = genericParseJSON requestOptions 160 | instance ToJSON Method where 161 | toJSON = genericToJSON encOptions 162 | toEncoding = genericToEncoding requestOptions 163 | 164 | data Options = Options 165 | { conversation_id :: Text } 166 | deriving (G.Generic, Eq, Show) 167 | instance FromJSON Options where 168 | parseJSON = genericParseJSON encOptions 169 | instance ToJSON Options where 170 | toJSON = genericToJSON encOptions 171 | toEncoding = genericToEncoding encOptions 172 | 173 | data Params = Params 174 | { options :: Options } 175 | deriving (G.Generic, Eq, Show) 176 | instance FromJSON Params where 177 | parseJSON = genericParseJSON encOptions 178 | instance ToJSON Params where 179 | toJSON = genericToJSON encOptions 180 | toEncoding = genericToEncoding encOptions 181 | 182 | data Request = Request 183 | { method :: Method 184 | , params :: Maybe Params 185 | } deriving (G.Generic, Eq, Show) 186 | instance FromJSON Request where 187 | parseJSON = genericParseJSON encOptions 188 | instance ToJSON Request where 189 | toJSON = genericToJSON encOptions 190 | toEncoding = genericToEncoding encOptions 191 | 192 | data RateLimit = RateLimit 193 | { tank :: Text 194 | , capacity :: Int 195 | , reset :: Int 196 | , gas :: Int 197 | } deriving (G.Generic, Eq, Show) 198 | instance FromJSON RateLimit where 199 | parseJSON = genericParseJSON encOptions 200 | instance ToJSON RateLimit where 201 | toJSON = genericToJSON encOptions 202 | toEncoding = genericToEncoding encOptions 203 | 204 | data Pagination = Pagination 205 | { next :: Text 206 | , previous :: Text 207 | , num :: Int 208 | , last :: Bool 209 | } deriving (G.Generic, Eq, Show) 210 | instance FromJSON Pagination where 211 | parseJSON = genericParseJSON encOptions 212 | instance ToJSON Pagination where 213 | toJSON = genericToJSON encOptions 214 | toEncoding = genericToEncoding encOptions 215 | 216 | type UserId = Text 217 | type DeviceId = Text 218 | data Sender = Sender 219 | { uid :: UserId 220 | , username :: Text 221 | , device_id :: DeviceId 222 | , device_name :: Text 223 | } deriving (G.Generic, Eq, Show) 224 | instance FromJSON Sender where 225 | parseJSON = genericParseJSON encOptions 226 | instance ToJSON Sender where 227 | toJSON = genericToJSON encOptions 228 | toEncoding = genericToEncoding encOptions 229 | 230 | msgOptions :: A.Options 231 | msgOptions = defaultOptions 232 | { A.constructorTagModifier = unpack . toLower . pack 233 | , A.fieldLabelModifier = unpack . strip "msg" . toLower . pack} 234 | 235 | type MessageId = Int 236 | data Message = Message 237 | { msgId :: MessageId 238 | , msgChannel :: Channel 239 | , msgSender :: Sender 240 | , msgSent_at :: Int 241 | , msgSent_at_ms :: Int 242 | , msgContent :: MessageContent 243 | , msgPrev :: [MessagePrev] 244 | , msgUnread :: Bool 245 | } deriving (G.Generic, Eq, Show) 246 | instance FromJSON Message where 247 | parseJSON = genericParseJSON msgOptions 248 | instance ToJSON Message where 249 | toJSON = genericToJSON msgOptions 250 | toEncoding = genericToEncoding msgOptions 251 | 252 | data Msg = Msg 253 | { msg :: Message } 254 | deriving (G.Generic, Eq, Show) 255 | 256 | instance FromJSON Msg where 257 | parseJSON = genericParseJSON encOptions 258 | instance ToJSON Msg where 259 | toJSON = genericToJSON encOptions 260 | toEncoding = genericToEncoding encOptions 261 | 262 | data MessageText = MessageText 263 | { body :: Text } 264 | deriving (G.Generic, Eq, Show) 265 | instance FromJSON MessageText where 266 | parseJSON = genericParseJSON encOptions 267 | instance ToJSON MessageText where 268 | toJSON = genericToJSON encOptions 269 | toEncoding = genericToEncoding encOptions 270 | 271 | data MessageAttachementUploaded = MessageAttachementUploaded 272 | { messageID :: Int } 273 | deriving (G.Generic, Eq, Show) 274 | instance FromJSON MessageAttachementUploaded where 275 | parseJSON = genericParseJSON encOptions 276 | instance ToJSON MessageAttachementUploaded where 277 | toJSON = genericToJSON encOptions 278 | toEncoding = genericToEncoding encOptions 279 | 280 | data MessageContent 281 | = MsgNone 282 | | MsgText { text :: MessageText } 283 | | MsgAttachementUploaded { attachement_uploaded :: MessageAttachementUploaded } 284 | -- | MsgEdit 285 | -- | MsgDelete 286 | -- | MsgMetadata 287 | -- | MsgTLFName 288 | -- | MsgHeadline 289 | -- | MsgAttachement 290 | -- | MsgJoin 291 | -- | MsgLeave 292 | -- | MsgSystem 293 | deriving (G.Generic, Eq, Show) 294 | instance FromJSON MessageContent where 295 | parseJSON = genericParseJSON contentOptions 296 | instance ToJSON MessageContent where 297 | toJSON = genericToJSON contentOptions 298 | toEncoding = genericToEncoding contentOptions 299 | 300 | contentOptions :: A.Options 301 | contentOptions = defaultOptions 302 | { A.unwrapUnaryRecords = True 303 | , A.sumEncoding = TaggedObject { tagFieldName = "type" 304 | , contentsFieldName = "" 305 | } 306 | , A.constructorTagModifier = unpack . strip "msg" . toLower . pack 307 | } 308 | 309 | prevOptions :: A.Options 310 | prevOptions = defaultOptions 311 | { A.constructorTagModifier = unpack . toLower . pack 312 | , A.fieldLabelModifier = unpack . strip "prev" . toLower . pack} 313 | 314 | data MessagePrev = MessagePrev 315 | { prevId :: Int 316 | , prevHash :: Text 317 | } deriving (G.Generic, Eq, Show) 318 | instance FromJSON MessagePrev where 319 | parseJSON = genericParseJSON prevOptions 320 | instance ToJSON MessagePrev where 321 | toJSON = genericToJSON prevOptions 322 | toEncoding = genericToEncoding prevOptions 323 | 324 | resultOptions :: A.Options 325 | resultOptions = defaultOptions 326 | { A.sumEncoding = A.UntaggedValue } 327 | 328 | data Result 329 | = Inbox { conversations :: [Conversation] 330 | , offline :: Bool 331 | } 332 | | Messages { messages :: [Msg] 333 | , pagination :: Pagination 334 | , ratelimits :: [RateLimit] 335 | } 336 | deriving (G.Generic, Eq, Show) 337 | instance FromJSON Result where 338 | parseJSON = genericParseJSON resultOptions 339 | instance ToJSON Result where 340 | toJSON = genericToJSON resultOptions 341 | toEncoding = genericToEncoding resultOptions 342 | 343 | responseOptions :: A.Options 344 | responseOptions = defaultOptions 345 | { A.constructorTagModifier = unpack . strip "member" . toLower . pack 346 | , A.sumEncoding = ObjectWithSingleField 347 | } 348 | 349 | data Response 350 | = Error { error :: Text } 351 | | Result Result 352 | deriving (G.Generic, Eq, Show) 353 | instance FromJSON Response where 354 | parseJSON = genericParseJSON responseOptions 355 | instance ToJSON Response where 356 | toJSON = genericToJSON responseOptions 357 | toEncoding = genericToEncoding responseOptions 358 | --------------------------------------------------------------------------------