├── .gitignore ├── .gitmodules ├── COPYING ├── Couria.h ├── Couria.plist ├── CouriaPreferences.plist ├── CouriaUI.plist ├── LICENSE ├── Makefile ├── README.md ├── control ├── loc └── strings.txt ├── res ├── Couria@2x.png ├── Couria@3x.png ├── Github@2x.png ├── Github@3x.png ├── Info.plist ├── Languages@2x.png ├── Languages@3x.png ├── PayPal@2x.png ├── PayPal@3x.png ├── Twitter@2x.png ├── Twitter@3x.png └── glyph.pdf └── src ├── Couria ├── Couria.m ├── Extras.m ├── Gestures.m ├── Notifications.m └── Service.m ├── CouriaUI ├── AddressBook.m ├── ContactsView.m ├── ConversationView.m ├── CouriaUI.m ├── MobileSMSApp.m ├── PhotosView.m ├── SearchAgent.m ├── ThirdPartyApp.m └── ViewService.m ├── Headers.h └── Preferences └── Preferences.m /.gitignore: -------------------------------------------------------------------------------- 1 | .theos 2 | .DS_Store 3 | *.swp 4 | *.deb 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "external/Color-Picker-for-iOS"] 2 | path = external/Color-Picker-for-iOS 3 | url = https://github.com/hayashi311/Color-Picker-for-iOS 4 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /Couria.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @class BBBulletin; 5 | 6 | @protocol CouriaMessage 7 | 8 | @required 9 | - (id)content; // The class of returned object must be: NSString for text messages, NSURL for images and any other attachments. 10 | - (BOOL)outgoing; 11 | 12 | @optional 13 | - (NSDate *)timestamp; 14 | 15 | @end 16 | 17 | @protocol CouriaExtension 18 | 19 | @required 20 | - (NSString *)getUserIdentifier:(BBBulletin *)bulletin; // UserIdentifier is used to uniquely identify each contact, which usually can be found in bulletins of that application. Return nil if this bulletin should not be handled by Couria. 21 | @optional 22 | - (NSString *)getNickname:(NSString *)userIdentifier; // Nickname will be displayed in user interface. The default value is userIdentifier. 23 | - (NSArray *)getMessages:(NSString *)userIdentifier; // Some previous messages sorted in ascending order by date. Objects in the returned NSArray must conform to CouriaMessage protocol. The default value is nil. 24 | - (UIImage *)getAvatar:(NSString *)userIdentifier; // Avatar will be displayed in user interface. The default value is nil. 25 | - (NSArray *)getContacts:(NSString *)keyword; // Search results of contacts by keyword. A non-nil NSArray of userIdentifiers should be returned when quick compose feature should be available currently. The default value is nil. 26 | 27 | @required 28 | - (void)sendMessage:(id)message toUser:(NSString *)userIdentifier; // Send a message to a user identified by userIdentifier. 29 | @optional 30 | - (void)markRead:(NSString *)userIdentifier; // Mark all messages of a user identified by userIdentifier as read. The default implementation does nothing. 31 | 32 | @optional 33 | - (BOOL)canSendPhotos; // Whether photo messages are supported. The default value is NO. 34 | - (BOOL)shouldClearNotifications; // If YES, when messages of a user are marked as read, the corresponding notifications will be cleared and the badge number will be decreased accordingly. If NO, nothing will be done automatically. If automatic clearing notifications does not work correctly, you should return NO and do it yourself. The default value is YES. 35 | 36 | @end 37 | 38 | @interface Couria : NSObject // This class is only available in SpringBoard by using NSClassFromString(@"Couria") 39 | 40 | + (instancetype)sharedInstance; // You should always use this shared instance when needed. 41 | - (void)registerExtension:(id)extension forApplication:(NSString *)applicationIdentifier; // Register your extension for an application. 42 | - (void)unregisterExtensionForApplication:(NSString *)applicationIdentifier; // Unregister your extension for an application. 43 | - (void)presentControllerForApplication:(NSString *)applicationIdentifier user:(NSString *)userIdentifier; // Manually present a quick compose view controller. If applicationIdentifier has not been registered, nothing will happen. If userIdentifier is nil and getContacts: has been implemented in the data source, contacts search view will be showed. 44 | - (void)handleBulletin:(BBBulletin *)bulletin; // Manually activate action of a bulletin. You may find useful if you are making some notifications tweaks. 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /Couria.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.springboard" ); }; } 2 | -------------------------------------------------------------------------------- /CouriaPreferences.plist: -------------------------------------------------------------------------------- 1 | { 2 | entry = { 3 | bundle = CouriaPreferences; 4 | label = Couria; 5 | icon = Couria.png; 6 | cell = PSLinkCell; 7 | isController = 1; 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /CouriaUI.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.apple.mobilesms.notification" ); }; } 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Couria, Centralized and Customizable Quick Reply and Quick Compose System for iOS 2 | Copyright (c) 2013 Bang Lee (Qusic) 3 | 4 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 5 | 6 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 7 | 8 | You should have received a copy of the GNU General Public License along with this program. If not, see . -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | TWEAK_NAME = Couria CouriaUI 2 | BUNDLE_NAME = CouriaPreferences 3 | 4 | Couria_FILES = $(wildcard src/Couria/*.m) 5 | Couria_FRAMEWORKS = UIKit 6 | Couria_PRIVATE_FRAMEWORKS = BulletinBoard AppSupport ChatKit 7 | Couria_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries 8 | 9 | CouriaUI_FILES = $(wildcard src/CouriaUI/*.m) 10 | CouriaUI_FRAMEWORKS = UIKit CoreGraphics AddressBook AssetsLibrary MobileCoreServices 11 | CouriaUI_PRIVATE_FRAMEWORKS = ChatKit AppSupport IMCore AssetsLibraryServices Search 12 | CouriaUI_LIBRARIES = substrate 13 | CouriaUI_LDFLAGS = -weak_framework Contacts -weak_framework ContactsUI -weak_framework Photos 14 | CouriaUI_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries 15 | 16 | CouriaPreferences_FILES = $(wildcard src/Preferences/*.m) 17 | CouriaPreferences_RESOURCE_DIRS = res 18 | CouriaPreferences_FRAMEWORKS = UIKit CoreGraphics QuartzCore Social 19 | CouriaPreferences_PRIVATE_FRAMEWORKS = Preferences AppSupport ChatKit 20 | CouriaPreferences_INSTALL_PATH = /Library/PreferenceBundles 21 | 22 | Color-Picker-for-iOS_FILES = $(wildcard external/Color-Picker-for-iOS/ColorPicker/*.m) 23 | Color-Picker-for-iOS_CFLAGS = -include external/Color-Picker-for-iOS/Project/Hayashi311ColorPickerSample/Hayashi311ColorPickerSample-Prefix.pch 24 | CouriaPreferences_FILES += $(Color-Picker-for-iOS_FILES) 25 | $(foreach file, $(Color-Picker-for-iOS_FILES), $(eval $(file)_CFLAGS = $(Color-Picker-for-iOS_CFLAGS))) 26 | 27 | export TARGET = iphone:clang:9.2 28 | export ARCHS = armv7 arm64 29 | export TARGET_IPHONEOS_DEPLOYMENT_VERSION = 8.0 30 | export ADDITIONAL_OBJCFLAGS = -fobjc-arc -fvisibility=hidden 31 | export INSTALL_TARGET_PROCESSES = SpringBoard MessagesNotificationViewService 32 | 33 | include $(THEOS)/makefiles/common.mk 34 | include $(THEOS_MAKE_PATH)/tweak.mk 35 | include $(THEOS_MAKE_PATH)/bundle.mk 36 | 37 | internal-stage:: 38 | $(ECHO_NOTHING)pref="$(THEOS_STAGING_DIR)/Library/PreferenceLoader/Preferences"; mkdir -p "$$pref"; cp CouriaPreferences.plist "$$pref/Couria.plist"$(ECHO_END) 39 | @(echo "Generating localization resources..."; twine generate-all-string-files loc/strings.txt "$(THEOS_STAGING_DIR)/$(CouriaPreferences_INSTALL_PATH)/CouriaPreferences.bundle" --create-folders --format apple) 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Couria 2 | Centralized and Customizable Quick Reply and Quick Compose System for iOS 3 | 4 | * [API Header](https://github.com/Qusic/Couria/blob/ios8/Couria.h) 5 | -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: me.qusic.couriaios8 2 | Name: Couria (iOS 8 & 9) 3 | Version: 0.9.5 4 | Description: Centralized Quick Reply System 5 | Section: Tweaks 6 | Depends: firmware (>= 8.0), mobilesubstrate, preferenceloader 7 | Priority: optional 8 | Architecture: iphoneos-arm 9 | Author: Qusic 10 | Maintainer: Qusic 11 | Sponsor: Qusic 12 | Icon: file:///Library/PreferenceBundles/CouriaPreferences.bundle/Couria.png 13 | Homepage: http://qusic.me/ 14 | Tag: purpose::extension 15 | -------------------------------------------------------------------------------- /loc/strings.txt: -------------------------------------------------------------------------------- 1 | [[PreferenceSections]] 2 | [EXTENSIONS] 3 | en = Extensions 4 | ar = إضافات 5 | da = Udvidelser 6 | de = Erweiterungen 7 | es = Extensiones 8 | fr = Extensions 9 | it = Estensioni 10 | ja = 拡張機能 11 | ko = 확장 12 | nl = Extensies 13 | ru = Расширения 14 | sv = Tillägg 15 | tr = Eklentiler 16 | zh_CN = 插件 17 | zh_TW = 外掛 18 | [ABOUT] 19 | en = About 20 | ar = عن المطور 21 | da = Om 22 | de = Über 23 | es = Acerca de 24 | fr = À Propos 25 | it = Info 26 | ja = 詳細 27 | ko = About 28 | nl = Over 29 | ru = О дополнении 30 | sv = Om 31 | tr = Hakkında 32 | zh_CN = 关于 33 | zh_TW = 關於 34 | [[ExtensionSection]] 35 | [ENABLED] 36 | en = Enabled 37 | ar = تمكين 38 | da = Aktiveret 39 | de = Aktiviert 40 | es = Habilitado 41 | fr = Activé 42 | it = Abilitato 43 | ja = 有効 44 | ko = 활성화 45 | nl = Ingeschakeld 46 | ru = Включено 47 | sv = Aktiverad 48 | tr = Aktif 49 | zh_CN = 启用 50 | zh_TW = 啟用 51 | [AUTHENTICATION_REQUIRED] 52 | en = Authentication Required 53 | zh_CN = 需要认证 54 | [DISMISS_ON_SEND] 55 | en = Dismiss On Send 56 | zh_CN = 发送后关闭 57 | [BUBBLE_THEME] 58 | en = Bubble Theme 59 | zh_CN = 气泡主题 60 | [BUBBLE_THEME_ORIGINAL] 61 | en = Original 62 | zh_CN = 原始 63 | [BUBBLE_THEME_OUTLINE] 64 | en = Outline 65 | zh_CN = 轮廓 66 | [BUBBLE_THEME_CUSTOM] 67 | en = Custom 68 | zh_CN = 自定义 69 | [MY_BUBBLE_COLOR] 70 | en = My Bubble Color 71 | zh_CN = 我的气泡颜色 72 | [MY_BUBBLE_TEXT_COLOR] 73 | en = My Bubble Text Color 74 | zh_CN = 我的气泡字体颜色 75 | [OTHERS_BUBBLE_COLOR] 76 | en = Others' Bubble Color 77 | zh_CN = 对方的气泡颜色 78 | [OTHERS_BUBBLE_TEXT_COLOR] 79 | en = Others' Bubble Text Color 80 | zh_CN = 对方的气泡字体颜色 81 | [[AboutSection]] 82 | [DONATE] 83 | en = Donate 84 | ar = تبرع 85 | da = Donér 86 | de = Spenden 87 | es = Donar 88 | fr = Contribuer 89 | it = Dona 90 | ja = 寄付 91 | ko = 기부 92 | nl = Doneer 93 | ru = Пожертвовать 94 | sv = Donera 95 | tr = Bağış Yap 96 | zh_CN = 捐赠 97 | zh_TW = 捐赠 98 | [TRANSLATION_CREDITS] 99 | en = Translation Credits 100 | ar = حقوق الترجمة 101 | da = Oversættelser 102 | de = Übersetzer 103 | es = Créditos de Traducción 104 | fr = Crédits de traduction 105 | it = Crediti per la Traduzione 106 | ja = 翻訳者 107 | ko = 번역 108 | nl = Vertalingscredits 109 | ru = Переводчики 110 | sv = Översättningar 111 | tr = Çeviriler için Teşekkürler 112 | zh_CN = 翻译致谢名单 113 | zh_TW = 翻譯感謝名單 114 | [[Messages]] 115 | [NO_INSTALLED_ITEMS] 116 | en = No Installed Items 117 | ar = لا توجد عناصر مثبتة 118 | da = Ingen installerede artikler 119 | de = Keine installierten Gegenstände 120 | es = Elementos no instalados 121 | fr = Rien d'installé 122 | it = Non ci sono elementi installati 123 | ja = アイテムがインストールされていません 124 | ko = 설치된 항목 없음 125 | nl = Geen items ge?nsttalleerd 126 | ru = Нет установленных расширений 127 | sv = Inga installerade artiklar 128 | tr = Yüklenmiş Program Yok 129 | zh_CN = 没有已安装的项目 130 | zh_TW = 沒有已安裝的項目 131 | [NO_ACCESS_TO_PHOTOS] 132 | en = No Access to Photos 133 | zh_CN = 没有访问相册的权限 134 | [NO_ACCESS_TO_CONTACTS] 135 | en = No Access to Contacts 136 | zh_CN = 没有访问通讯录的权限 137 | [ACTIVATOR_LISTENER_DESCRIPTION] 138 | en = Launch Couria message composer 139 | ar = Launch Couria message composer 140 | da = Åben Couria besked vindue 141 | de = Launch Couria message composer 142 | es = Abrir el redactor de mensajes Couria 143 | fr = Lancer le composeur de message Couria 144 | it = Launch Couria message composer 145 | ja = Couria message composerを起動 146 | ko = Launch Couria message composer 147 | nl = Start Couria berichtencomposer 148 | ru = Вызвать редактор Couria 149 | sv = Starta Couria meddelandeskapare 150 | tr = Couria mesaj yazıcısını Aç 151 | zh_CN = 启动 Couria 消息编写器 152 | zh_TW = 啟動 Couria 以編寫訊息 153 | [SHARE_TEXT] 154 | en = I'm Loving #Couria, which brings a Centralized and Customizable Quick Reply and Quick Compose System to iOS. 155 | ar = انا استخدم اداة #Couria التى تعطيني القدرة على الرد السريع و الكتابة بشكل سريع للرسائل لنظام iOS 156 | da = Jeg elsker #Couria, som tilføjer et centralt og hurtigt besked system til iOS, til kan tilpasses med udvidelser. 157 | de = Ich liebe #Couria, welches ein aufgeräumtes und veränderbares schnell-Antworten und schnell-Verfassen System zu iOS hinzufügt. 158 | es = Me Encanta #Couria, me ofrece un sistema de respuesta y redacción rápida, centralizada y personalizada en iOS. 159 | fr = I'm Loving #Couria, which brings a Centralized and Customizable Quick Reply and Quick Compose System to iOS. 160 | it = Mi sta piacendo #Couria, che porta Risposta e Composizione Veloce Centralizzate e Personalizzabili su iOS. 161 | ja = I'm Loving #Couria, which brings a Centralized and Customizable Quick Reply and Quick Compose System to iOS. 162 | ko = I'm Loving #Couria, which brings a Centralized and Customizable Quick Reply and Quick Compose System to iOS. 163 | nl = Ik hou van #Couria, het brengt een gecentraliseerd en aanpasbaar Quick Reply en Quick Compose-systeem naar iOS. 164 | ru = Я использую #Couria, централизованную систему быстрого ответа и отправки сообщений для iOS. 165 | sv = Jag älskar #Couria som är ett centraliserat och personifierbart snabbsvars- och snabbskrivsystem till iOS. 166 | tr = ` #Couria'yı seviyorum, çünkü iOS'de benim Mesajlara hızlı cevap vermemi ve isteğim yerde mesaj yazabilmemi sağlıyor.` 167 | zh_CN = 我很喜欢 #Couria# 。它为 iOS 带来了一个集中的可定制的消息快捷回复和快捷编写的平台。 168 | zh_TW = 我很喜歡 #Couria# 。他為 iOS 帶來了一個集中且可客製快速回覆與快速編寫訊息的平台。 169 | -------------------------------------------------------------------------------- /res/Couria@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/Couria@2x.png -------------------------------------------------------------------------------- /res/Couria@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/Couria@3x.png -------------------------------------------------------------------------------- /res/Github@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/Github@2x.png -------------------------------------------------------------------------------- /res/Github@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/Github@3x.png -------------------------------------------------------------------------------- /res/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | CouriaPreferences 9 | CFBundleIdentifier 10 | me.qusic.couria.preferences 11 | CFBundleDisplayName 12 | CouriaPreferences 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | DTPlatformName 24 | iphoneos 25 | MinimumOSVersion 26 | 8.0 27 | NSPrincipalClass 28 | CouriaPreferencesController 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /res/Languages@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/Languages@2x.png -------------------------------------------------------------------------------- /res/Languages@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/Languages@3x.png -------------------------------------------------------------------------------- /res/PayPal@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/PayPal@2x.png -------------------------------------------------------------------------------- /res/PayPal@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/PayPal@3x.png -------------------------------------------------------------------------------- /res/Twitter@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/Twitter@2x.png -------------------------------------------------------------------------------- /res/Twitter@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/Twitter@3x.png -------------------------------------------------------------------------------- /res/glyph.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Qusic/Couria/9e4a232b06041e2691c95037062d820429157d94/res/glyph.pdf -------------------------------------------------------------------------------- /src/Couria/Couria.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | static NSMutableDictionary *extensions; 4 | static NSUserDefaults *preferences; 5 | 6 | CHDeclareClass(SBApplicationController) 7 | CHDeclareClass(SBIconController) 8 | CHDeclareClass(SBIconViewMap) 9 | CHDeclareClass(SBBulletinBannerController) 10 | CHDeclareClass(SBBannerController) 11 | 12 | NSDictionary *CouriaExtensions(void) { 13 | return extensions; 14 | } 15 | 16 | NSUserDefaults *CouriaPreferences(void) { 17 | return preferences; 18 | } 19 | 20 | id CouriaExtension(NSString *application) { 21 | return extensions[application]; 22 | } 23 | 24 | BOOL CouriaEnabled(NSString *application) { 25 | return ([application isEqualToString:MobileSMSIdentifier] || CouriaExtension(application)) && [preferences boolForKey:[application stringByAppendingString:EnabledSetting]]; 26 | } 27 | 28 | NSString *CouriaApplicationName(NSString *applicationIdentifier) { 29 | SBApplication *application = [CHSharedInstance(SBApplicationController) applicationWithBundleIdentifier:applicationIdentifier]; 30 | return application.displayName; 31 | } 32 | 33 | UIImage *CouriaApplicationIcon(NSString *applicationIdentifier, BOOL small) { 34 | SBIconViewMap *iconViewMap = nil; 35 | if ([CHClass(SBIconController) instancesRespondToSelector:@selector(homescreenIconViewMap)]) { 36 | iconViewMap = CHSharedInstance(SBIconController).homescreenIconViewMap; 37 | } else if ([CHClass(SBIconViewMap) respondsToSelector:@selector(homescreenMap)]) { 38 | iconViewMap = [CHClass(SBIconViewMap) homescreenMap]; 39 | } 40 | SBApplicationIcon *icon = [iconViewMap.iconModel applicationIconForBundleIdentifier:applicationIdentifier]; 41 | return [icon getIconImage:small ? 0 : 2]; 42 | } 43 | 44 | static NSString *chatKitLocalizedString(NSArray *keys) { 45 | NSString *result = nil; 46 | for (NSString *key in keys) { 47 | result = [CKFrameworkBundle() localizedStringForKey:key value:nil table:@"ChatKit"]; 48 | if (![result isEqualToString:key]) { 49 | break; 50 | } 51 | } 52 | return result; 53 | } 54 | 55 | void CouriaUpdateBulletinRequest(BBBulletinRequest *bulletinRequest) { 56 | NSString *applicationIdentifier = bulletinRequest.sectionID; 57 | if (CouriaEnabled(applicationIdentifier)) { 58 | id extension = CouriaExtension(applicationIdentifier); 59 | [bulletinRequest setContextValue:applicationIdentifier forKey:CouriaIdentifier ApplicationDomain]; 60 | [bulletinRequest setContextValue:[extension getUserIdentifier:bulletinRequest] forKey:CouriaIdentifier UserDomain]; 61 | [bulletinRequest setContextValue:@{ 62 | CanSendPhotosOption: @([extension respondsToSelector:@selector(canSendPhotos)] ? extension.canSendPhotos : NO) 63 | } forKey:CouriaIdentifier OptionsDomain]; 64 | if ([applicationIdentifier isEqualToString:MobileSMSIdentifier]) { 65 | [bulletinRequest._allActions enumerateObjectsUsingBlock:^(BBAction *action, NSUInteger index, BOOL *stop) { 66 | if ([action.remoteServiceBundleIdentifier isEqualToString:MessagesNotificationViewServiceIdentifier] && [action.remoteViewControllerClassName isEqualToString:@"CKInlineReplyViewController"]) { 67 | action.remoteViewControllerClassName = @"CouriaInlineReplyViewController_MobileSMSApp"; 68 | action.authenticationRequired = [preferences boolForKey:[applicationIdentifier stringByAppendingString:AuthenticationRequiredSetting]]; 69 | } 70 | }]; 71 | if (bulletinRequest._allSupplementaryActions.count == 0) { 72 | BBAction *action = [BBAction actionWithIdentifier:CouriaIdentifier ActionDomain]; 73 | action.actionType = 7; 74 | action.appearance = [BBAppearance appearanceWithTitle:chatKitLocalizedString(@[@"REPLY", @"REPLY_NOTIFICATION_ACTION"])]; 75 | action.remoteServiceBundleIdentifier = MessagesNotificationViewServiceIdentifier; 76 | action.remoteViewControllerClassName = @"CouriaInlineReplyViewController_MobileSMSApp"; 77 | action.authenticationRequired = [preferences boolForKey:[applicationIdentifier stringByAppendingString:AuthenticationRequiredSetting]]; 78 | action.activationMode = 1; 79 | [bulletinRequest setSupplementaryActions:@[action]]; 80 | } 81 | } else { 82 | [bulletinRequest.supplementaryActionsByLayout.allKeys enumerateObjectsUsingBlock:^(NSNumber *layout, NSUInteger index, BOOL *stop) { 83 | [bulletinRequest setSupplementaryActions:nil forLayout:layout.integerValue]; 84 | }]; 85 | BBAction *action = [BBAction actionWithIdentifier:CouriaIdentifier ActionDomain]; 86 | action.actionType = 7; 87 | action.appearance = [BBAppearance appearanceWithTitle:chatKitLocalizedString(@[@"REPLY", @"REPLY_NOTIFICATION_ACTION"])]; 88 | action.remoteServiceBundleIdentifier = MessagesNotificationViewServiceIdentifier; 89 | action.remoteViewControllerClassName = @"CouriaInlineReplyViewController_ThirdPartyApp"; 90 | action.authenticationRequired = [preferences boolForKey:[applicationIdentifier stringByAppendingString:AuthenticationRequiredSetting]]; 91 | action.activationMode = 1; 92 | [bulletinRequest setSupplementaryActions:@[action]]; 93 | } 94 | } 95 | } 96 | 97 | void CouriaPresentViewController(NSString *application, NSString *user) { 98 | if (CouriaEnabled(application) && CHSharedInstance(SBBannerController)._bannerContext == nil) { 99 | BBBulletinRequest *bulletin = [[BBBulletinRequest alloc]init]; 100 | [bulletin generateNewBulletinID]; 101 | bulletin.sectionID = application; 102 | bulletin.title = chatKitLocalizedString(@[@"NEW_MESSAGE"]); 103 | bulletin.defaultAction = [BBAction actionWithLaunchBundleID:application]; 104 | CouriaUpdateBulletinRequest(bulletin); 105 | [bulletin setContextValue:user forKey:[application isEqualToString:MobileSMSIdentifier] ? CKBBUserInfoKeyChatIdentifierKey : CouriaIdentifier UserDomain]; 106 | BBAction *action = bulletin.supplementaryActions.firstObject; 107 | dispatch_async(dispatch_get_main_queue(), ^{ 108 | [CHSharedInstance(SBBulletinBannerController) modallyPresentBannerForBulletin:bulletin action:action]; 109 | }); 110 | } 111 | } 112 | 113 | void CouriaDismissViewController(void) { 114 | SBBannerController *bannerController = CHSharedInstance(SBBannerController); 115 | if (bannerController._bannerContext != nil) { 116 | dispatch_async(dispatch_get_main_queue(), ^{ 117 | [bannerController dismissBannerWithAnimation:YES reason:1]; 118 | }); 119 | } 120 | } 121 | 122 | @implementation Couria 123 | 124 | + (instancetype)sharedInstance { 125 | static id sharedInstance; 126 | static dispatch_once_t onceToken; 127 | dispatch_once(&onceToken, ^{ 128 | sharedInstance = [[self alloc]init]; 129 | extensions = [NSMutableDictionary dictionary]; 130 | preferences = [[NSUserDefaults alloc]initWithSuiteName:CouriaIdentifier]; 131 | CouriaRegisterDefaults(preferences, MobileSMSIdentifier); 132 | CHLoadLateClass(SBApplicationController); 133 | CHLoadLateClass(SBIconController); 134 | CHLoadLateClass(SBIconViewMap); 135 | CHLoadLateClass(SBBulletinBannerController); 136 | CHLoadLateClass(SBBannerController); 137 | }); 138 | return sharedInstance; 139 | } 140 | 141 | - (void)registerExtension:(id)extension forApplication:(NSString *)applicationIdentifier { 142 | if (extension != nil && applicationIdentifier != nil && ![applicationIdentifier isEqualToString:MobileSMSIdentifier]) { 143 | [extensions setObject:extension forKey:applicationIdentifier]; 144 | [[CouriaExtras sharedInstance]registerExtrasForApplication:applicationIdentifier]; 145 | CouriaRegisterDefaults(preferences, applicationIdentifier); 146 | } 147 | } 148 | 149 | - (void)unregisterExtensionForApplication:(NSString *)applicationIdentifier { 150 | if (applicationIdentifier != nil && ![applicationIdentifier isEqualToString:MobileSMSIdentifier]) { 151 | [extensions removeObjectForKey:applicationIdentifier]; 152 | [[CouriaExtras sharedInstance]unregisterExtrasForApplication:applicationIdentifier]; 153 | } 154 | } 155 | 156 | - (void)presentControllerForApplication:(NSString *)applicationIdentifier user:(NSString *)userIdentifier { 157 | CouriaPresentViewController(applicationIdentifier, userIdentifier); 158 | } 159 | 160 | - (void)handleBulletin:(BBBulletin *)bulletin { 161 | CouriaPresentViewController(bulletin.sectionID, [CouriaExtension(bulletin.sectionID) getUserIdentifier:bulletin]); 162 | } 163 | 164 | @end 165 | 166 | @implementation CouriaMessage 167 | @end 168 | 169 | CHConstructor { 170 | @autoreleasepool { 171 | [Couria sharedInstance]; 172 | [[CouriaService sharedInstance]run]; 173 | [[CouriaExtras sharedInstance]registerExtrasForApplication:MobileSMSIdentifier]; 174 | CouriaNotificationsInit(); 175 | CouriaGesturesInit(); 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /src/Couria/Extras.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | static LAActivator *activator; 4 | static FSSwitchPanel *flipswitch; 5 | 6 | static NSString *getApplicationIdentifier(NSString *externalIdentifier) { 7 | return [externalIdentifier substringFromIndex:16]; 8 | } 9 | 10 | static NSString *getExternalIdentifier(NSString *applicationIdentifier) { 11 | return [NSString stringWithFormat:CouriaIdentifier".%@", applicationIdentifier]; 12 | } 13 | 14 | @implementation CouriaExtras 15 | 16 | + (instancetype)sharedInstance { 17 | static id sharedInstance; 18 | static dispatch_once_t onceToken; 19 | dispatch_once(&onceToken, ^{ 20 | sharedInstance = [[self alloc]init]; 21 | dlopen("/Library/MobileSubstrate/DynamicLibraries/Activator.dylib", RTLD_LAZY); 22 | dlopen("/Library/MobileSubstrate/DynamicLibraries/Flipswitch.dylib", RTLD_LAZY); 23 | activator = (LAActivator *)[NSClassFromString(@"LAActivator") sharedInstance]; 24 | flipswitch = (FSSwitchPanel *)[NSClassFromString(@"FSSwitchPanel") sharedPanel]; 25 | }); 26 | return sharedInstance; 27 | } 28 | 29 | - (void)registerExtrasForApplication:(NSString *)applicationIdentifier { 30 | NSString *externalIdentifier = getExternalIdentifier(applicationIdentifier); 31 | [activator registerListener:self forName:externalIdentifier]; 32 | [flipswitch registerDataSource:self forSwitchIdentifier:externalIdentifier]; 33 | } 34 | 35 | - (void)unregisterExtrasForApplication:(NSString *)applicationIdentifier { 36 | NSString *externalIdentifier = getExternalIdentifier(applicationIdentifier); 37 | [activator unregisterListenerWithName:externalIdentifier]; 38 | [flipswitch unregisterSwitchIdentifier:externalIdentifier]; 39 | } 40 | 41 | - (void)activator:(LAActivator *)activator receiveEvent:(LAEvent *)event forListenerName:(NSString *)listenerName { 42 | NSString *applicationIdentifier = getApplicationIdentifier(listenerName); 43 | CouriaPresentViewController(applicationIdentifier, nil); 44 | [event setHandled:YES]; 45 | } 46 | 47 | - (void)activator:(LAActivator *)activator abortEvent:(LAEvent *)event forListenerName:(NSString *)listenerName { 48 | CouriaDismissViewController(); 49 | } 50 | 51 | - (NSString *)activator:(LAActivator *)activator requiresLocalizedGroupForListenerName:(NSString *)listenerName { 52 | return @"Couria"; 53 | } 54 | 55 | - (NSString *)activator:(LAActivator *)activator requiresLocalizedTitleForListenerName:(NSString *)listenerName { 56 | NSString *applicationIdentifier = getApplicationIdentifier(listenerName); 57 | return [NSString stringWithFormat:@"Couria/%@", CouriaApplicationName(applicationIdentifier)]; 58 | } 59 | 60 | - (NSString *)activator:(LAActivator *)activator requiresLocalizedDescriptionForListenerName:(NSString *)listenerName { 61 | return CouriaLocalizedString(@"ACTIVATOR_LISTENER_DESCRIPTION"); 62 | } 63 | 64 | - (UIImage *)activator:(LAActivator *)activator requiresIconForListenerName:(NSString *)listenerName scale:(CGFloat)scale { 65 | NSString *applicationIdentifier = getApplicationIdentifier(listenerName); 66 | return CouriaApplicationIcon(applicationIdentifier, NO); 67 | } 68 | 69 | - (UIImage *)activator:(LAActivator *)activator requiresSmallIconForListenerName:(NSString *)listenerName scale:(CGFloat)scale { 70 | NSString *applicationIdentifier = getApplicationIdentifier(listenerName); 71 | return CouriaApplicationIcon(applicationIdentifier, YES); 72 | } 73 | 74 | - (void)applyActionForSwitchIdentifier:(NSString *)switchIdentifier { 75 | NSString *applicationIdentifier = getApplicationIdentifier(switchIdentifier); 76 | CouriaPresentViewController(applicationIdentifier, nil); 77 | } 78 | 79 | - (NSString *)titleForSwitchIdentifier:(NSString *)switchIdentifier { 80 | NSString *applicationIdentifier = getApplicationIdentifier(switchIdentifier); 81 | return [NSString stringWithFormat:@"Couria/%@", CouriaApplicationName(applicationIdentifier)]; 82 | } 83 | 84 | - (NSBundle *)bundleForSwitchIdentifier:(NSString *)switchIdentifier { 85 | return CouriaResourcesBundle(); 86 | } 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /src/Couria/Gestures.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | CHDeclareClass(SBBannerController) 4 | 5 | CHOptimizedMethod(4, self, void, SBBannerController, _handleGestureState, NSInteger, state, location, CGPoint, location, displacement, CGFloat, displacement, velocity, CGFloat, velocity) { 6 | if (!self.isShowingModalBanner || CHIvar(self, _activeGestureType, NSInteger) != 2) { 7 | CHSuper(4, SBBannerController, _handleGestureState, state, location, location, displacement, displacement, velocity, velocity); 8 | } 9 | } 10 | 11 | void CouriaGesturesInit(void) { 12 | CHLoadLateClass(SBBannerController); 13 | CHHook(4, SBBannerController, _handleGestureState, location, displacement, velocity); 14 | } 15 | -------------------------------------------------------------------------------- /src/Couria/Notifications.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | static BBServer *bbServer; 4 | 5 | CHDeclareClass(BBServer) 6 | 7 | CHOptimizedClassMethod(0, new, id, BBServer, sharedInstance) { 8 | return bbServer; 9 | } 10 | 11 | CHOptimizedMethod(0, self, id, BBServer, init) { 12 | self = bbServer = CHSuper(0, BBServer, init); 13 | return self; 14 | } 15 | 16 | CHOptimizedMethod(4, self, void, BBServer, _publishBulletinRequest, BBBulletinRequest *, bulletinRequest, forSectionID, NSString *, sectionID, forDestinations, NSUInteger, destinations, alwaysToLockScreen, BOOL, alwaysToLockScreen) { 17 | CouriaUpdateBulletinRequest(bulletinRequest); 18 | CHSuper(4, BBServer, _publishBulletinRequest, bulletinRequest, forSectionID, sectionID, forDestinations, destinations, alwaysToLockScreen, alwaysToLockScreen); 19 | } 20 | 21 | CHOptimizedMethod(3, self, void, BBServer, publishBulletinRequest, BBBulletinRequest *, bulletinRequest, destinations, NSUInteger, destinations, alwaysToLockScreen, BOOL, alwaysToLockScreen) { 22 | CouriaUpdateBulletinRequest(bulletinRequest); 23 | CHSuper(3, BBServer, publishBulletinRequest, bulletinRequest, destinations, destinations, alwaysToLockScreen, alwaysToLockScreen); 24 | } 25 | 26 | void CouriaNotificationsInit(void) { 27 | CHLoadClass(BBServer); 28 | CHHook(0, BBServer, sharedInstance); 29 | CHHook(0, BBServer, init); 30 | CHHook(4, BBServer, _publishBulletinRequest, forSectionID, forDestinations, alwaysToLockScreen); 31 | CHHook(3, BBServer, publishBulletinRequest, destinations, alwaysToLockScreen); 32 | } 33 | -------------------------------------------------------------------------------- /src/Couria/Service.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | static CPDistributedMessagingCenter *messagingCenter; 4 | 5 | CHDeclareClass(SBBannerController) 6 | CHDeclareClass(BBServer) 7 | 8 | @implementation CouriaService 9 | 10 | + (instancetype)sharedInstance { 11 | static id sharedInstance; 12 | static dispatch_once_t onceToken; 13 | dispatch_once(&onceToken, ^{ 14 | sharedInstance = [[self alloc]init]; 15 | messagingCenter = [CPDistributedMessagingCenter centerNamed:CouriaIdentifier]; 16 | CHLoadLateClass(SBBannerController); 17 | CHLoadClass(BBServer); 18 | }); 19 | return sharedInstance; 20 | } 21 | 22 | - (void)run { 23 | [messagingCenter runServerOnCurrentThread]; 24 | [messagingCenter registerForMessageName:GetMessagesMessage target:self selector:@selector(processExtensionRequest:data:)]; 25 | [messagingCenter registerForMessageName:GetContactsMessage target:self selector:@selector(processExtensionRequest:data:)]; 26 | [messagingCenter registerForMessageName:SendMessageMessage target:self selector:@selector(processExtensionRequest:data:)]; 27 | [messagingCenter registerForMessageName:MarkReadMessage target:self selector:@selector(processExtensionRequest:data:)]; 28 | [messagingCenter registerForMessageName:ListExtensionsMessage target:self selector:@selector(processMiscellaneousRequest:data:)]; 29 | [messagingCenter registerForMessageName:UpdateBannerMessage target:self selector:@selector(processMiscellaneousRequest:data:)]; 30 | } 31 | 32 | - (NSDictionary *)processExtensionRequest:(NSString *)request data:(NSDictionary *)data { 33 | id extension; NSString *application; NSString *user; NSDictionary *response; 34 | for (BOOL _valid = ({ 35 | BOOL valid = NO; 36 | if (CouriaEnabled(application = data[ApplicationKey])) { 37 | extension = CouriaExtension(application); 38 | user = data[UserKey]; 39 | valid = YES; 40 | } 41 | valid; 42 | }); _valid; _valid = NO) { 43 | if ([request isEqualToString:GetMessagesMessage]) { 44 | if ([extension respondsToSelector:@selector(getMessages:)]) { 45 | NSMutableArray *result = [NSMutableArray array]; 46 | [[extension getMessages:user]enumerateObjectsUsingBlock:^(id message, NSUInteger idx, BOOL *stop) { 47 | NSMutableDictionary *messageDictionary = [NSMutableDictionary dictionary]; 48 | id content = message.content; 49 | BOOL outgoing = message.outgoing; 50 | NSDate *timestamp = [message respondsToSelector:@selector(timestamp)] ? message.timestamp : nil; 51 | messageDictionary[OutgoingKey] = @(outgoing); 52 | if ([timestamp isKindOfClass:NSDate.class]) { 53 | messageDictionary[TimestampKey] = timestamp; 54 | } 55 | if ([content isKindOfClass:NSString.class] || [content isKindOfClass:NSURL.class]) { 56 | messageDictionary[ContentKey] = content; 57 | [result addObject:messageDictionary]; 58 | } 59 | }]; 60 | response = @{MessagesKey: [NSKeyedArchiver archivedDataWithRootObject:result]}; 61 | } 62 | } else if ([request isEqualToString:GetContactsMessage]) { 63 | if ([extension respondsToSelector:@selector(getContacts:)]) { 64 | NSMutableArray *result = [NSMutableArray array]; 65 | [[extension getContacts:data[KeywordKey]]enumerateObjectsUsingBlock:^(NSString *contact, NSUInteger idx, BOOL *stop) { 66 | NSMutableDictionary *contactDictionary = [NSMutableDictionary dictionary]; 67 | NSString *nickname = [extension respondsToSelector:@selector(getNickname:)] ? [extension getNickname:contact] : contact; 68 | UIImage *avatar = [extension respondsToSelector:@selector(getAvatar:)] ? [extension getAvatar:contact] : nil; 69 | if ([nickname isKindOfClass:NSString.class]) { 70 | contactDictionary[NicknameKey] = nickname; 71 | } 72 | if ([avatar isKindOfClass:UIImage.class]) { 73 | contactDictionary[AvatarKey] = avatar; 74 | } 75 | if ([contact isKindOfClass:NSString.class]) { 76 | contactDictionary[IdentifierKey] = contact; 77 | [result addObject:contactDictionary]; 78 | } 79 | }]; 80 | response = @{ContactsKey: [NSKeyedArchiver archivedDataWithRootObject:result]}; 81 | } 82 | } else if ([request isEqualToString:SendMessageMessage]) { 83 | CouriaMessage *message = [[CouriaMessage alloc]init]; 84 | message.outgoing = YES; 85 | message.timestamp = [NSDate date]; 86 | id content = [NSKeyedUnarchiver unarchiveObjectWithData:data[ContentKey]]; 87 | if ([content isKindOfClass:NSString.class] || [content isKindOfClass:NSURL.class]) { 88 | message.content = content; 89 | [extension sendMessage:message toUser:user]; 90 | } 91 | } else if ([request isEqualToString:MarkReadMessage]) { 92 | if ([extension respondsToSelector:@selector(markRead:)]) { 93 | [extension markRead:user]; 94 | } 95 | if ([extension respondsToSelector:@selector(shouldClearNotifications)] ? extension.shouldClearNotifications : NO) { 96 | dispatch_sync(__BBServerQueue, ^{ 97 | BBServer *bbServer = CHSharedInstance(BBServer); 98 | BBDataProvider *dataProvider = [bbServer dataProviderForSectionID:application]; 99 | NSSet *bulletins = [bbServer bulletinsRequestsForBulletinIDs:[bbServer allBulletinIDsForSectionID:application]]; 100 | NSInteger remainingCount = 0; 101 | for (BBBulletinRequest *bulletin in bulletins) { 102 | if ([[extension getUserIdentifier:bulletin]isEqualToString:user]) { 103 | BBDataProviderWithdrawBulletinWithPublisherBulletinID(dataProvider, bulletin.publisherBulletinID); 104 | } else { 105 | remainingCount++; 106 | } 107 | } 108 | BBDataProviderSetApplicationBadge(dataProvider, remainingCount); 109 | }); 110 | } 111 | } 112 | } 113 | return response; 114 | } 115 | 116 | - (NSDictionary *)processMiscellaneousRequest:(NSString *)request data:(NSDictionary *)data { 117 | NSDictionary *response; 118 | if ([request isEqualToString:ListExtensionsMessage]) { 119 | NSMutableArray *result = [NSMutableArray array]; 120 | NSMutableArray *applicationIdentifiers = [NSMutableArray arrayWithObject:MobileSMSIdentifier]; 121 | [applicationIdentifiers addObjectsFromArray:CouriaExtensions().allKeys]; 122 | [applicationIdentifiers enumerateObjectsUsingBlock:^(NSString *applicationIdentifier, NSUInteger index, BOOL *stop) { 123 | [result addObject:@{ 124 | IdentifierKey: applicationIdentifier, 125 | NameKey: CouriaApplicationName(applicationIdentifier), 126 | IconKey: CouriaApplicationIcon(applicationIdentifier, YES) 127 | }]; 128 | }]; 129 | response = @{ExtensionsKey: [NSKeyedArchiver archivedDataWithRootObject:result]}; 130 | } else if ([request isEqualToString:UpdateBannerMessage]) { 131 | SBBannerContextView *bannerView = CHSharedInstance(SBBannerController)._bannerView; 132 | if (bannerView != nil) { 133 | SBDefaultBannerView * const *contentViewRef = CHIvarRef(bannerView, _contentView, SBDefaultBannerView * const); 134 | if (contentViewRef != NULL && *contentViewRef != nil) { 135 | SBDefaultBannerTextView * const *textViewRef = CHIvarRef(*contentViewRef, _textView, SBDefaultBannerTextView * const); 136 | if (textViewRef != NULL && *textViewRef != nil) { 137 | SBDefaultBannerTextView *textView = *textViewRef; 138 | textView.primaryText = data[PrimaryTextKey] ?: textView.primaryText; 139 | textView.secondaryText = data[SecondaryTextKey] ?: textView.secondaryText; 140 | [textView setNeedsLayout]; 141 | [textView layoutIfNeeded]; 142 | } 143 | } 144 | } 145 | } 146 | return response; 147 | } 148 | 149 | @end 150 | -------------------------------------------------------------------------------- /src/CouriaUI/AddressBook.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | @implementation CouriaAddressBook { 4 | ABAddressBookRef addressBook; 5 | CNContactStore *contactStore; 6 | } 7 | 8 | - (instancetype)init { 9 | self = [super init]; 10 | if (self) { 11 | addressBook = ABAddressBookCreateWithOptions(NULL, NULL); 12 | contactStore = [[CNContactStore alloc]init]; 13 | } 14 | return self; 15 | } 16 | 17 | - (BOOL)accessGranted { 18 | return ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized; 19 | } 20 | 21 | - (void)requestAccess { 22 | if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) { 23 | dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); 24 | ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { 25 | dispatch_semaphore_signal(semaphore); 26 | }); 27 | dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); 28 | } 29 | } 30 | 31 | - (NSArray *)processSearchResults:(NSArray *)searchResults withBlock:(id (^)(NSString *identifier, NSString *nickname, UIImage *avatar))block { 32 | NSMutableArray *results = [NSMutableArray array]; 33 | if (CNContact.class) { 34 | NSMutableArray *identifiers = [NSMutableArray array]; 35 | [searchResults enumerateObjectsUsingBlock:^(SPSearchResult *searchResult, NSUInteger index, BOOL *stop) { 36 | [identifiers addObject:searchResult.externalIdentifier]; 37 | }]; 38 | [[contactStore unifiedContactsMatchingPredicate:[CNContact predicateForContactsWithIdentifiers:identifiers] keysToFetch:@[[CNContactFormatter descriptorForRequiredKeysForStyle:CNContactFormatterStyleFullName], [CNAvatarView descriptorForRequiredKeys], CNContactPhoneNumbersKey, CNContactEmailAddressesKey] error:NULL]enumerateObjectsUsingBlock:^(CNContact *contact, NSUInteger index, BOOL *stop) { 39 | NSString *name = [CNContactFormatter stringFromContact:contact style:CNContactFormatterStyleFullName]; 40 | UIImage *avatar = [self avatarImageForContacts:@[contact]]; 41 | void (^ processLabeledValue)(NSString *, NSString *) = ^(NSString *label, NSString *value) { 42 | if (value.length > 0) { 43 | NSString *nickname = label.length > 0 ? [NSString stringWithFormat:@"%@ (%@)", name, [CNLabeledValue localizedStringForLabel:label]] : [NSString stringWithFormat:@"%@", name]; 44 | NSString *identifier = IMStripFormattingFromAddress(value); 45 | [results addObject:block(identifier, nickname, avatar)]; 46 | } 47 | }; 48 | [contact.phoneNumbers enumerateObjectsUsingBlock:^(CNLabeledValue *labeledValue, NSUInteger index, BOOL *stop) { 49 | processLabeledValue(labeledValue.label, labeledValue.value.stringValue); 50 | }]; 51 | [contact.emailAddresses enumerateObjectsUsingBlock:^(CNLabeledValue *labeledValue, NSUInteger index, BOOL *stop) { 52 | processLabeledValue(labeledValue.label, labeledValue.value); 53 | }]; 54 | }]; 55 | } else { 56 | [searchResults enumerateObjectsUsingBlock:^(SPSearchResult *searchResult, NSUInteger index, BOOL *stop) { 57 | ABRecordID recordID = (ABRecordID)searchResult.identifier; 58 | ABRecordRef record = ABAddressBookGetPersonWithRecordID(addressBook, recordID); 59 | if (record != NULL) { 60 | NSString *name = CFBridgingRelease(ABRecordCopyCompositeName(record)); 61 | UIImage *avatar = [CKAddressBook transcriptContactImageOfDiameter:[CKUIBehavior sharedBehaviors].transcriptContactImageDiameter forRecordID:recordID]; 62 | void (^ processMultiValueProperty)(ABPropertyID) = ^(ABPropertyID property) { 63 | ABMultiValueRef multiValue = ABRecordCopyValue(record, property); 64 | for (CFIndex index = 0, count = ABMultiValueGetCount(multiValue); index < count; index++) { 65 | NSString *label = CFBridgingRelease(ABMultiValueCopyLabelAtIndex(multiValue, index)); 66 | NSString *value = CFBridgingRelease(ABMultiValueCopyValueAtIndex(multiValue, index)); 67 | if (value.length > 0) { 68 | NSString *identifier = IMStripFormattingFromAddress(value); 69 | NSString *nickname = label ? [NSString stringWithFormat:@"%@ (%@)", name, CFBridgingRelease(ABAddressBookCopyLocalizedLabel((__bridge CFStringRef)label))] : [NSString stringWithFormat:@"%@", name]; 70 | [results addObject:block(identifier, nickname, avatar)]; 71 | } 72 | } 73 | CFRelease(multiValue); 74 | }; 75 | processMultiValueProperty(kABPersonPhoneProperty); 76 | processMultiValueProperty(kABPersonEmailProperty); 77 | } 78 | }]; 79 | } 80 | return results; 81 | } 82 | 83 | - (UIImage *)avatarImageForContacts:(NSArray *)contacts { 84 | static CNAvatarView *avatarView; 85 | static dispatch_once_t onceToken; 86 | dispatch_once(&onceToken, ^{ 87 | CGFloat size = [CKUIBehavior sharedBehaviors].transcriptContactImageDiameter; 88 | avatarView = [[CNAvatarView alloc]initWithFrame:CGRectMake(0, 0, size, size)]; 89 | }); 90 | avatarView.contacts = contacts; 91 | [avatarView _updateAvatarView]; 92 | return avatarView.contentImage; 93 | } 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /src/CouriaUI/ContactsView.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | @implementation CouriaContactsViewController 4 | 5 | - (void)viewDidLoad { 6 | [super viewDidLoad]; 7 | self.view.backgroundColor = [UIColor clearColor]; 8 | self.tableView.separatorColor = [[UIColor whiteColor]colorWithAlphaComponent:0.1]; 9 | self.searchBar = [[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 44)]; 10 | self.searchBar.barStyle = UIBarStyleBlack; 11 | self.searchBar.translucent = YES; 12 | self.searchBar.delegate = self; 13 | self.searchBar.keyboardAppearance = UIKeyboardAppearanceDark; 14 | self.searchBar.tintColor = [[UIColor whiteColor]colorWithAlphaComponent:0.4]; 15 | self.searchBar._backgroundView.alpha = 0; 16 | self.tableView.tableHeaderView = self.searchBar; 17 | } 18 | 19 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 20 | return self.contacts.count; 21 | } 22 | 23 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 24 | NSDictionary *contact = indexPath.row < self.contacts.count ? self.contacts[indexPath.row] : nil; 25 | static NSString * const cellReuseIdentifier = @"CouriaContactCell"; 26 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellReuseIdentifier]; 27 | if (cell == nil) { 28 | cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellReuseIdentifier]; 29 | cell.backgroundColor = [UIColor clearColor]; 30 | cell.selectedBackgroundView = [[UIView alloc]initWithFrame:CGRectZero]; 31 | cell.selectedBackgroundView.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0.1]; 32 | cell.textLabel.textColor = [[UIColor whiteColor]colorWithAlphaComponent:0.6]; 33 | cell.detailTextLabel.textColor = [[UIColor whiteColor]colorWithAlphaComponent:0.3]; 34 | } 35 | cell.textLabel.text = contact[NicknameKey]; 36 | cell.detailTextLabel.text = contact[IdentifierKey]; 37 | cell.imageView.image = contact[AvatarKey]; 38 | return cell; 39 | } 40 | 41 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 42 | NSDictionary *contact = self.contacts[indexPath.row]; 43 | [tableView deselectRowAtIndexPath:indexPath animated:YES]; 44 | if (self.selectionHandler) { 45 | dispatch_async(dispatch_get_main_queue(), ^{ 46 | self.selectionHandler(contact); 47 | }); 48 | } 49 | } 50 | 51 | - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { 52 | if (self.keywordHandler) { 53 | dispatch_async(dispatch_get_main_queue(), ^{ 54 | self.keywordHandler(searchText); 55 | }); 56 | } 57 | } 58 | 59 | - (void)refreshData { 60 | dispatch_async(dispatch_get_main_queue(), ^{ 61 | [self.tableView reloadData]; 62 | [self.tableView __ck_scrollToTop:NO]; 63 | }); 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /src/CouriaUI/ConversationView.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | @implementation CouriaConversationViewController 4 | 5 | - (instancetype)initWithConversation:(CKConversation *)conversation transcriptWidth:(CGFloat)transcriptWidth entryContentViewWidth:(CGFloat)entryContentViewWidth { 6 | CKUIBehavior *uiBehavior = [CKUIBehavior sharedBehaviors]; 7 | if ([self respondsToSelector:@selector(initWithConversation:balloonMaxWidth:marginInsets:)]) { 8 | UIEdgeInsets marginInsets = UIEdgeInsetsMake(0, 20, 0, 20); 9 | CGFloat balloonMaxWidth = [uiBehavior balloonMaxWidthForTranscriptWidth:transcriptWidth marginInsets:marginInsets shouldShowPhotoButton:YES shouldShowCharacterCount:NO]; 10 | self = [super initWithConversation:nil balloonMaxWidth:balloonMaxWidth marginInsets:marginInsets]; 11 | } else if ([self respondsToSelector:@selector(initWithConversation:rightBalloonMaxWidth:leftBalloonMaxWidth:)]) { 12 | UIEdgeInsets marginInsets = uiBehavior.transcriptMarginInsets; 13 | CGFloat rightBalloonMaxWidth = [uiBehavior rightBalloonMaxWidthForEntryContentViewWidth:entryContentViewWidth]; 14 | CGFloat leftBalloonMaxWidth = [uiBehavior leftBalloonMaxWidthForTranscriptWidth:transcriptWidth marginInsets:marginInsets]; 15 | self = [super initWithConversation:nil rightBalloonMaxWidth:rightBalloonMaxWidth leftBalloonMaxWidth:leftBalloonMaxWidth]; 16 | } 17 | return self; 18 | } 19 | 20 | - (void)setConversation:(CKConversation *)conversation { 21 | [super setConversation:conversation]; 22 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 23 | [notificationCenter removeObserver:self name:IMChatItemsDidChangeNotification object:nil]; 24 | if (conversation.chat) { 25 | [notificationCenter addObserver:self selector:@selector(chatItemsDidChange:) name:IMChatItemsDidChangeNotification object:conversation.chat]; 26 | } else { 27 | //TODO: refresh conversation for third party extensions 28 | } 29 | } 30 | 31 | - (void)configureCell:(CKTranscriptCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { 32 | [super configureCell:cell forItemAtIndexPath:indexPath]; 33 | if ([cell isKindOfClass:CKTranscriptMessageCell.class]) { 34 | CKTranscriptMessageCell *messageCell = (CKTranscriptMessageCell *)cell; 35 | if (self.conversation == nil) { 36 | messageCell.wantsContactImageLayout = NO; 37 | if ([messageCell respondsToSelector:@selector(setShowAvatarView:withContact:preferredHandle:avatarViewDelegate:)]) { 38 | [(CKPhoneTranscriptMessageCell *)messageCell setShowAvatarView:NO withContact:nil preferredHandle:nil avatarViewDelegate:nil]; 39 | } else if ([messageCell respondsToSelector:@selector(setContactImage:)]) { 40 | messageCell.contactImage = nil; 41 | } 42 | } 43 | if ([messageCell isKindOfClass:CKTranscriptBalloonCell.class]) { 44 | CKTranscriptBalloonCell *balloonCell = (CKTranscriptBalloonCell *)cell; 45 | CKBalloonView *balloonView = balloonCell.balloonView; 46 | balloonView.filled = self.bubbleTheme != CouriaBubbleThemeOutline; 47 | if ([balloonView isKindOfClass:CKColoredBalloonView.class]) { 48 | CKColoredBalloonView *coloredBalloonView = (CKColoredBalloonView *)balloonView; 49 | CKBalloonColor originalColor = ((CKMessagePartChatItem *)self.chatItems[indexPath.item]).color; 50 | CKUIBehavior *uiBehavior = [CKUIBehavior sharedBehaviors]; 51 | switch (self.bubbleTheme) { 52 | case CouriaBubbleThemeOutline: 53 | coloredBalloonView.color = CKBalloonColorWhite; 54 | break; 55 | case CouriaBubbleThemeCustom: 56 | coloredBalloonView.color = [uiBehavior colorTypeForColor:coloredBalloonView.orientation == CKBalloonOrientationRight ? self.bubbleColors[0] : self.bubbleColors[2]]; 57 | break; 58 | default: 59 | coloredBalloonView.color = originalColor; 60 | break; 61 | } 62 | if ([balloonView isKindOfClass:CKTextBalloonView.class]) { 63 | CKTextBalloonView *textBalloonView = (CKTextBalloonView *)coloredBalloonView; 64 | NSMutableAttributedString *text = textBalloonView.attributedText.mutableCopy; 65 | switch (self.bubbleTheme) { 66 | case CouriaBubbleThemeOutline: 67 | [text addAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]} range:NSMakeRange(0, text.length)]; 68 | break; 69 | case CouriaBubbleThemeCustom: 70 | [text addAttributes:@{NSForegroundColorAttributeName: coloredBalloonView.orientation == CKBalloonOrientationRight ? self.bubbleColors[1] : self.bubbleColors[3]} range:NSMakeRange(0, text.length)]; 71 | break; 72 | default: 73 | [text addAttributes:@{NSForegroundColorAttributeName: [uiBehavior balloonTextColorForColorType:originalColor]} range:NSMakeRange(0, text.length)]; 74 | break; 75 | } 76 | [text removeAttribute:NSLinkAttributeName range:NSMakeRange(0, text.length)]; 77 | textBalloonView.attributedText = text; 78 | } 79 | } 80 | [balloonView setNeedsPrepareForDisplay]; 81 | [balloonView prepareForDisplayIfNeeded]; 82 | } 83 | } 84 | } 85 | 86 | - (void)refreshData { 87 | dispatch_async(dispatch_get_main_queue(), ^{ 88 | [self.collectionView reloadData]; 89 | [self.collectionView __ck_scrollToBottom:NO]; 90 | }); 91 | } 92 | 93 | - (BOOL)balloonView:(CKBalloonView *)balloonView canPerformAction:(SEL)action withSender:(id)sender { 94 | return sel_isEqual(action, @selector(copy:)) ? [super balloonView:balloonView canPerformAction:action withSender:sender] : NO; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /src/CouriaUI/CouriaUI.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | CHConstructor { 4 | @autoreleasepool { 5 | CouriaUIViewServiceInit(); 6 | CouriaUIPhotosViewInit(); 7 | CouriaUIMobileSMSAppInit(); 8 | CouriaUIThirdPartyAppInit(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/CouriaUI/MobileSMSApp.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | static NSString * const daemonListenerID = @"MessagesNotificationViewService"; 4 | 5 | static CouriaAddressBook *addressBook; 6 | static CouriaSearchAgent *searchAgent; 7 | 8 | CHDeclareClass(CouriaInlineReplyViewController) 9 | CHDeclareClass(CouriaInlineReplyViewController_MobileSMSApp) 10 | 11 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController_MobileSMSApp, setupConversation) { 12 | NSString *chatIdentifier = self.context[CKBBUserInfoKeyChatIdentifierKey]; 13 | if (chatIdentifier != nil) { 14 | if (CKListenerPaginatedChatRegistryCapabilities) { 15 | [[IMDaemonController sharedInstance]setCapabilities:CKListenerPaginatedChatRegistryCapabilities() forListenerID:daemonListenerID]; 16 | } 17 | CHSuper(0, CouriaInlineReplyViewController_MobileSMSApp, setupConversation); 18 | CKConversationList *conversationList = [CKConversationList sharedConversationList]; 19 | CKConversation *conversation = [conversationList conversationForExistingChatWithGroupID:chatIdentifier]; 20 | if (conversation == nil) { 21 | CKEntity *entity = [CKEntity copyEntityForAddressString:chatIdentifier]; 22 | IMService *service = [[IMPreferredServiceManager sharedPreferredServiceManager]preferredServiceForHandles:@[entity.defaultIMHandle] newComposition:YES error:NULL serverCheckCompletionBlock:NULL]; 23 | IMAccount *account = [[IMAccountController sharedInstance]__ck_defaultAccountForService:service]; 24 | NSArray *handles = [account __ck_handlesFromAddressStrings:@[chatIdentifier]]; 25 | if ([conversationList respondsToSelector:@selector(conversationForHandles:displayName:joinedChatsOnly:create:)]) { 26 | conversation = [conversationList conversationForHandles:handles displayName:nil joinedChatsOnly:NO create:YES]; 27 | } else if ([conversationList respondsToSelector:@selector(conversationForHandles:create:)]) { 28 | conversation = [conversationList conversationForHandles:handles create:YES]; 29 | } 30 | } 31 | static NSUInteger const messagesLimit = 51; 32 | conversation.limitToLoad = messagesLimit; 33 | conversation.chat.numberOfMessagesToKeepLoaded = messagesLimit; 34 | [conversation.chat loadMessagesBeforeDate:nil limit:messagesLimit loadImmediately:YES]; 35 | NSMutableArray *chatItems = [NSMutableArray array]; 36 | [conversation.chat.chatItems enumerateObjectsUsingBlock:^(IMChatItem *item, NSUInteger index, BOOL *stop) { 37 | [chatItems addObject:[self.conversationViewController chatItemWithIMChatItem:item]]; 38 | }]; 39 | self.conversationViewController.conversation = conversation; 40 | self.conversationViewController.chatItems = chatItems; 41 | self.entryView.conversation = conversation; 42 | } else { 43 | if (CKListenerCapabilities) { 44 | [[IMDaemonController sharedInstance]setCapabilities:CKListenerCapabilities() forListenerID:daemonListenerID]; 45 | } 46 | [addressBook requestAccess]; 47 | searchAgent.updateHandler = ^(void) { 48 | NSMutableArray *contacts = [NSMutableArray array]; 49 | NSString *queryString = searchAgent.queryString; 50 | if (queryString.length == 0) { 51 | CKConversationList *conversationList = [CKConversationList sharedConversationList]; 52 | [conversationList setNeedsReload]; 53 | [conversationList resort]; 54 | [conversationList.activeConversations enumerateObjectsUsingBlock:^(CKConversation *conversation, NSUInteger index, BOOL *stop) { 55 | NSString *identifier = conversation.groupID; 56 | if (identifier.length == 0) { 57 | return; 58 | } 59 | NSString *nickname = conversation.hasDisplayName ? conversation.displayName : conversation.name; 60 | if (nickname == nil) { 61 | nickname = IMStripFormattingFromAddress(identifier); 62 | } 63 | UIImage *avatar = CNContact.class ? [addressBook avatarImageForContacts:conversation.orderedContactsForAvatarView] : [CKEntity copyEntityForAddressString:conversation.groupID].transcriptContactImage; 64 | NSMutableDictionary *contact = [NSMutableDictionary dictionary]; 65 | contact[IdentifierKey] = identifier; 66 | contact[NicknameKey] = nickname; 67 | if (avatar) { 68 | contact[AvatarKey] = avatar; 69 | } 70 | [contacts addObject:contact]; 71 | }]; 72 | } else if (searchAgent.hasResults) { 73 | if (addressBook.accessGranted) { 74 | [contacts addObjectsFromArray:[addressBook processSearchResults:searchAgent.contactsResults withBlock:^(NSString *identifier, NSString *nickname, UIImage *avatar) { 75 | NSMutableDictionary *contact = [NSMutableDictionary dictionary]; 76 | contact[IdentifierKey] = identifier; 77 | contact[NicknameKey] = nickname; 78 | if (avatar) { 79 | contact[AvatarKey] = avatar; 80 | } 81 | return contact; 82 | }]]; 83 | } else { 84 | [contacts addObject:@{ 85 | IdentifierKey: IMStripFormattingFromAddress(queryString), 86 | NicknameKey: queryString 87 | }]; 88 | [self.messagingCenter sendNonBlockingMessageName:UpdateBannerMessage userInfo:@{ 89 | SecondaryTextKey: CouriaLocalizedString(@"NO_ACCESS_TO_CONTACTS") 90 | }]; 91 | } 92 | } else { 93 | [contacts addObject:@{ 94 | IdentifierKey: IMStripFormattingFromAddress(queryString), 95 | NicknameKey: queryString 96 | }]; 97 | } 98 | self.contactsViewController.contacts = contacts; 99 | [self.contactsViewController refreshData]; 100 | }; 101 | __weak __typeof__(self) weakSelf = self; 102 | self.contactsViewController.keywordHandler = ^(NSString *keyword) { 103 | [searchAgent setQueryString:keyword inputMode:weakSelf.contactsViewController.searchBar.textInputMode]; 104 | }; 105 | self.contactsViewController.selectionHandler = ^(NSDictionary *contact) { 106 | NSMutableDictionary *context = weakSelf.context.mutableCopy; 107 | context[CKBBUserInfoKeyChatIdentifierKey] = contact[IdentifierKey]; 108 | weakSelf.context = context; 109 | [weakSelf.conversationViewController refreshData]; 110 | [weakSelf interactiveNotificationDidAppear]; 111 | [weakSelf.messagingCenter sendNonBlockingMessageName:UpdateBannerMessage userInfo:@{ 112 | PrimaryTextKey: contact[NicknameKey] 113 | }]; 114 | }; 115 | } 116 | } 117 | 118 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController_MobileSMSApp, setupView) { 119 | CHSuper(0, CouriaInlineReplyViewController_MobileSMSApp, setupView); 120 | self.entryView.shouldShowPhotoButton = YES; 121 | } 122 | 123 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController_MobileSMSApp, interactiveNotificationDidAppear) { 124 | CHSuper(0, CouriaInlineReplyViewController_MobileSMSApp, interactiveNotificationDidAppear); 125 | if (self.context[CKBBUserInfoKeyChatIdentifierKey] != nil) { 126 | self.entryView.hidden = NO; 127 | self.conversationViewController.view.hidden = NO; 128 | self.contactsViewController.view.hidden = YES; 129 | [self.conversationViewController.conversation markAllMessagesAsRead]; 130 | } else { 131 | self.entryView.hidden = YES; 132 | self.conversationViewController.view.hidden = YES; 133 | self.contactsViewController.view.hidden = NO; 134 | [self.contactsViewController.searchBar becomeFirstResponder]; 135 | [self.contactsViewController searchBar:self.contactsViewController.searchBar textDidChange:self.contactsViewController.searchBar.text]; 136 | } 137 | } 138 | 139 | CHOptimizedMethod(1, super, void, CouriaInlineReplyViewController_MobileSMSApp, messageEntryViewDidChange, CKMessageEntryView *, entryView) { 140 | CHSuper(1, CouriaInlineReplyViewController_MobileSMSApp, messageEntryViewDidChange, entryView); 141 | [self.typingUpdater setNeedsUpdate]; 142 | if ([self respondsToSelector:@selector(updateSendButton)]) { 143 | [self updateSendButton]; 144 | } 145 | } 146 | 147 | FHFunction(BOOL, CKIsRunningInFullCKClient) { 148 | return YES; 149 | } 150 | 151 | FHFunction(BOOL, CKIsRunningInMessages) { 152 | return YES; 153 | } 154 | 155 | FHFunction(BOOL, CKIsRunningInMessagesOrSpringBoard) { 156 | return YES; 157 | } 158 | 159 | void CouriaUIMobileSMSAppInit(void) { 160 | addressBook = [[CouriaAddressBook alloc]init]; 161 | searchAgent = [[CouriaSearchAgent alloc]init]; 162 | CHLoadLateClass(CouriaInlineReplyViewController); 163 | CHRegisterClass(CouriaInlineReplyViewController_MobileSMSApp, CouriaInlineReplyViewController) { 164 | CHHook(0, CouriaInlineReplyViewController_MobileSMSApp, setupConversation); 165 | CHHook(0, CouriaInlineReplyViewController_MobileSMSApp, setupView); 166 | CHHook(0, CouriaInlineReplyViewController_MobileSMSApp, interactiveNotificationDidAppear); 167 | CHHook(1, CouriaInlineReplyViewController_MobileSMSApp, messageEntryViewDidChange); 168 | } 169 | FHHook(CKIsRunningInFullCKClient); 170 | FHHook(CKIsRunningInMessages); 171 | FHHook(CKIsRunningInMessagesOrSpringBoard); 172 | } 173 | -------------------------------------------------------------------------------- /src/CouriaUI/PhotosView.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | CHDeclareClass(CKPhotoPickerSheetViewController) 4 | CHDeclareClass(CKPhotoPickerCollectionViewController) 5 | 6 | @interface CouriaPhotosViewController () 7 | @property (retain, nonatomic) UIViewController *viewController; 8 | @end 9 | 10 | @implementation CouriaPhotosViewController 11 | 12 | - (instancetype)init { 13 | self = [super init]; 14 | if (self) { 15 | [self initController]; 16 | } 17 | return self; 18 | } 19 | 20 | - (BOOL)accessGranted { 21 | return [ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusAuthorized; 22 | } 23 | 24 | - (void)requestAccess { 25 | if ([ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusNotDetermined) { 26 | if (PHPhotoLibrary.class) { 27 | dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); 28 | [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { 29 | dispatch_semaphore_signal(semaphore); 30 | }]; 31 | dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); 32 | } 33 | } 34 | } 35 | 36 | - (void)initController { 37 | [self requestAccess]; 38 | if (self.accessGranted || [ALAssetsLibrary authorizationStatus] == ALAuthorizationStatusNotDetermined) { 39 | if (CHClass(CKPhotoPickerSheetViewController)) { 40 | self.viewController = [CHAlloc(CKPhotoPickerSheetViewController) initWithPresentationViewController:nil]; 41 | } else if (CHClass(CKPhotoPickerCollectionViewController)) { 42 | self.viewController = [CHAlloc(CKPhotoPickerCollectionViewController) initWithNibName:nil bundle:nil]; 43 | } 44 | } else { 45 | UILabel *label = [[UILabel alloc]initWithFrame:CGRectZero]; 46 | label.text = CouriaLocalizedString(@"NO_ACCESS_TO_PHOTOS"); 47 | label.font = [UIFont systemFontOfSize:[UIFont systemFontSize]]; 48 | label.textColor = [[UIColor whiteColor]colorWithAlphaComponent:0.3]; 49 | label.textAlignment = NSTextAlignmentCenter; 50 | UIViewController *viewController = [[UIViewController alloc]initWithNibName:nil bundle:nil]; 51 | viewController.view = label; 52 | self.viewController = viewController; 53 | } 54 | } 55 | 56 | - (CKPhotoPickerSheetViewController *)sheetViewController { // iOS 8.0+ 57 | return [self.viewController isKindOfClass:CHClass(CKPhotoPickerSheetViewController)] ? (CKPhotoPickerSheetViewController *)self.viewController : nil; 58 | } 59 | 60 | - (CKPhotoPickerCollectionViewController *)collectionViewController { // iOS 8.3+ 61 | return [self.viewController isKindOfClass:CHClass(CKPhotoPickerCollectionViewController)] ? (CKPhotoPickerCollectionViewController *)self.viewController : nil; 62 | } 63 | 64 | - (UIView *)view { 65 | if (self.sheetViewController) { 66 | return self.sheetViewController.photosCollectionView; 67 | } else if (self.collectionViewController) { 68 | return self.collectionViewController.collectionView; 69 | } else { 70 | return self.viewController.view; 71 | } 72 | } 73 | 74 | - (NSArray *)fetchAndClearSelectedPhotos { 75 | NSMutableArray *photos = [NSMutableArray array]; 76 | if (self.sheetViewController) { 77 | CKPhotoPickerSheetViewController *viewController = self.sheetViewController; 78 | CKPhotoPickerCollectionView *view = viewController.photosCollectionView; 79 | NSArray *assets = CHIvar(viewController, _assets, NSArray * const); 80 | [view.indexPathsForSelectedItems enumerateObjectsUsingBlock:^(NSIndexPath *indexPath, NSUInteger index, BOOL *stop) { 81 | ALAsset *asset = assets[indexPath.item]; 82 | ALAssetRepresentation *representation = asset.defaultRepresentation; 83 | NSDictionary *transcoderUserInfo = nil; 84 | if (representation.url != nil) { 85 | transcoderUserInfo = @{IMFileTransferAVTranscodeOptionAssetURI: representation.url.absoluteString}; 86 | } 87 | CKMediaObject *mediaObject = [[CKMediaObjectManager sharedInstance]mediaObjectWithData:UIImageJPEGRepresentation([UIImage imageWithCGImage:representation.fullResolutionImage scale:1 orientation:(UIImageOrientation)representation.orientation], 0.8) UTIType:(__bridge NSString *)kUTTypeJPEG filename:nil transcoderUserInfo:transcoderUserInfo]; 88 | [photos addObject:mediaObject]; 89 | [view deselectItemAtIndexPath:indexPath animated:NO]; 90 | [view.delegate collectionView:view didDeselectItemAtIndexPath:indexPath]; 91 | }]; 92 | } else if (self.collectionViewController) { 93 | CKPhotoPickerCollectionViewController *viewController = self.collectionViewController; 94 | UICollectionView *view = self.collectionViewController.collectionView; 95 | NSArray *items = viewController.assetsToSend; 96 | [items enumerateObjectsUsingBlock:^(CKPhotoPickerItemForSending *item, NSUInteger index, BOOL *stop) { 97 | [item waitForOutstandingWork]; 98 | NSURL *assetURL = item.assetURL; 99 | NSURL *localURL = item.localURL; 100 | NSURL *fileURL = nil; 101 | NSDictionary *transcoderUserInfo = nil; 102 | if (PUTIsPersistentURL(assetURL)) { 103 | fileURL = [NSURL fileURLWithPath:PUTCreatePathForPersistentURL(assetURL) isDirectory:NO]; 104 | transcoderUserInfo = @{IMFileTransferAVTranscodeOptionAssetURI: assetURL.absoluteString}; 105 | } else if (localURL.isFileURL) { 106 | fileURL = localURL; 107 | } 108 | if (fileURL != nil) { 109 | CKMediaObject *mediaObject = [[CKMediaObjectManager sharedInstance]mediaObjectWithFileURL:fileURL filename:nil transcoderUserInfo:transcoderUserInfo]; 110 | [photos addObject:mediaObject]; 111 | } 112 | }]; 113 | [view.indexPathsForSelectedItems enumerateObjectsUsingBlock:^(NSIndexPath *indexPath, NSUInteger index, BOOL *stop) { 114 | [view deselectItemAtIndexPath:indexPath animated:NO]; 115 | [view.delegate collectionView:view didDeselectItemAtIndexPath:indexPath]; 116 | }]; 117 | } 118 | return photos; 119 | } 120 | 121 | @end 122 | 123 | CHOptimizedMethod(1, self, void, CKPhotoPickerSheetViewController, setPhotosCollectionView, CKPhotoPickerCollectionView *, photosCollectionView) { 124 | if (photosCollectionView != nil) { 125 | photosCollectionView.backgroundColor = [UIColor clearColor]; 126 | CHSuper(1, CKPhotoPickerSheetViewController, setPhotosCollectionView, photosCollectionView); 127 | } 128 | } 129 | 130 | CHOptimizedMethod(1, self, void, CKPhotoPickerCollectionViewController, setCollectionView, UICollectionView *, collectionView) { 131 | if (collectionView != nil) { 132 | collectionView.backgroundColor = [UIColor clearColor]; 133 | CHSuper(1, CKPhotoPickerCollectionViewController, setCollectionView, collectionView); 134 | } 135 | } 136 | 137 | void CouriaUIPhotosViewInit(void) { 138 | CHLoadLateClass(CKPhotoPickerSheetViewController); 139 | CHLoadLateClass(CKPhotoPickerCollectionViewController); 140 | CHHook(1, CKPhotoPickerSheetViewController, setPhotosCollectionView); 141 | CHHook(1, CKPhotoPickerCollectionViewController, setCollectionView); 142 | } 143 | -------------------------------------------------------------------------------- /src/CouriaUI/SearchAgent.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | @implementation CouriaSearchAgent { 4 | NSString *queryString; 5 | } 6 | 7 | - (instancetype)init { 8 | self = [super init]; 9 | if (self) { 10 | self.searchDomains = @[@(SPSearchDomainPerson)]; 11 | self.delegate = self; 12 | } 13 | return self; 14 | } 15 | 16 | - (NSString *)queryString { 17 | return queryString; 18 | } 19 | 20 | - (void)setQueryString:(NSString *)string inputMode:(UITextInputMode *)mode { 21 | if ([queryString isEqualToString:string]) { 22 | [self notifyResults]; 23 | } else { 24 | queryString = string; 25 | if ([super respondsToSelector:@selector(setQueryString:keyboardLanguage:keyboardPrimaryLanguage:levelZKW:allowInternet:)]) { 26 | static NSString * (^ const inputTypeForInputMode)(UITextInputMode *) = ^(UITextInputMode *inputMode) { 27 | NSString *inputType = nil; 28 | if ([inputMode isKindOfClass:UITextInputMode.class]) { 29 | if ([inputMode.identifier isEqualToString:@"dictation"]) { 30 | inputType = @"dictation"; 31 | } else if (inputMode.extension != nil) { 32 | inputType = @"custom"; 33 | } else { 34 | inputType = inputMode.normalizedIdentifierLevels.firstObject; 35 | } 36 | } 37 | return inputType; 38 | }; 39 | [super setQueryString:string keyboardLanguage:inputTypeForInputMode(mode) keyboardPrimaryLanguage:mode.primaryLanguage levelZKW:0 allowInternet:NO]; 40 | } else if ([super respondsToSelector:@selector(setQueryString:)]) { 41 | [super setQueryString:string]; 42 | } 43 | } 44 | } 45 | 46 | - (BOOL)hasResults { 47 | if ([super respondsToSelector:@selector(hasResults)]) { 48 | return [super hasResults]; 49 | } else if ([super respondsToSelector:@selector(resultCount)]) { 50 | return super.resultCount > 0; 51 | } else { 52 | return NO; 53 | } 54 | } 55 | 56 | - (NSArray *)contactsResults { 57 | if ([self respondsToSelector:@selector(sections)] && [SPSearchResult instanceMethodForSelector:@selector(searchResultDomain)]) { 58 | NSMutableArray *results = [NSMutableArray array]; 59 | [self.sections enumerateObjectsUsingBlock:^(SPSearchResultSection *section, NSUInteger index, BOOL *stop) { 60 | if (section.domain == SPSearchDomainPerson) { 61 | [results addObjectsFromArray:section.results]; 62 | } else { 63 | [section.results enumerateObjectsUsingBlock:^(SPSearchResult *result, NSUInteger index, BOOL *stop) { 64 | if (result.searchResultDomain == SPSearchDomainPerson) { 65 | [results addObject:result]; 66 | } 67 | }]; 68 | } 69 | }]; 70 | return results; 71 | } else { 72 | return [self sectionAtIndex:0].results; 73 | } 74 | } 75 | 76 | - (void)notifyResults { 77 | if (self.updateHandler) { 78 | dispatch_async(dispatch_get_main_queue(), ^{ 79 | self.updateHandler(); 80 | }); 81 | } 82 | } 83 | 84 | - (void)searchAgentUpdatedResults:(SPSearchAgent *)agent { 85 | [self notifyResults]; 86 | } 87 | 88 | - (void)searchAgentClearedResults:(SPSearchAgent *)agent { 89 | [self notifyResults]; 90 | } 91 | 92 | @end 93 | -------------------------------------------------------------------------------- /src/CouriaUI/ThirdPartyApp.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | CHDeclareClass(CouriaInlineReplyViewController) 4 | CHDeclareClass(CouriaInlineReplyViewController_ThirdPartyApp) 5 | 6 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController_ThirdPartyApp, setupConversation) { 7 | NSString *applicationIdentifier = self.context[CouriaIdentifier ApplicationDomain]; 8 | NSString *userIdentifier = self.context[CouriaIdentifier UserDomain]; 9 | if (userIdentifier != nil) { 10 | CHSuper(0, CouriaInlineReplyViewController_ThirdPartyApp, setupConversation); 11 | NSArray *result = [NSKeyedUnarchiver unarchiveObjectWithData:[self.messagingCenter sendMessageAndReceiveReplyName:GetMessagesMessage userInfo:@{ 12 | ApplicationKey: applicationIdentifier, 13 | UserKey: userIdentifier 14 | } error:NULL][MessagesKey]]; 15 | NSMutableArray *chatItems = [NSMutableArray array]; 16 | [result enumerateObjectsUsingBlock:^(NSDictionary *messageDictionary, NSUInteger index, BOOL *stop) { 17 | id content = messageDictionary[ContentKey]; 18 | BOOL outgoing = [messageDictionary[OutgoingKey]boolValue]; 19 | NSDate *timestamp = messageDictionary[TimestampKey]; 20 | IMMessageItem *messageItem = [[IMMessageItem alloc]init]; 21 | BOOL finished = YES, fromme = outgoing, delivered = YES, read = !outgoing, sent = outgoing; 22 | messageItem.flags |= (finished << 0x0 | fromme << 0x2 | delivered << 0xc | read << 0xd | sent << 0xf); 23 | messageItem.time = timestamp; 24 | messageItem.timeDelivered = timestamp; 25 | messageItem.timeRead = timestamp; 26 | if ([content isKindOfClass:NSString.class]) { 27 | NSString *string = content; 28 | messageItem.plainBody = string; 29 | } else if ([content isKindOfClass:NSURL.class]) { 30 | NSURL *url = content; 31 | CKMediaObject *mediaObject = [[CKMediaObjectManager sharedInstance]mediaObjectWithFileURL:url filename:url.lastPathComponent transcoderUserInfo:nil]; 32 | messageItem.body = [[NSAttributedString alloc]initWithString:IMAttachmentCharacterString attributes:@{ 33 | IMMessagePartAttributeName: @(1), 34 | IMFileTransferGUIDAttributeName: mediaObject.transferGUID, 35 | IMFilenameAttributeName: url.lastPathComponent, 36 | IMBaseWritingDirectionAttributeName: @(NSWritingDirectionNatural) 37 | }]; 38 | } 39 | IMMessage *message = [IMMessage messageFromIMMessageItem:messageItem sender:nil subject:nil]; 40 | if ([IMMessageItem respondsToSelector:@selector(contextClass)]) { 41 | IMMessageItemChatContext *context = [[[IMMessageItem contextClass]alloc]init]; 42 | CHIvar(context, _message, IMMessage * __strong) = message; 43 | messageItem.context = context; 44 | } else { 45 | messageItem.context = message; 46 | } 47 | CKChatItem *chatItem = [self.conversationViewController chatItemWithIMChatItem:messageItem._newChatItems]; 48 | if (chatItem.transcriptDrawerText == nil) { 49 | chatItem.transcriptDrawerText = [[NSAttributedString alloc]initWithString:@""]; 50 | } 51 | [chatItems addObject:chatItem]; 52 | }]; 53 | self.conversationViewController.chatItems = chatItems; 54 | } else { 55 | __weak __typeof__(self) weakSelf = self; 56 | self.contactsViewController.keywordHandler = ^(NSString *keyword) { 57 | NSArray *result = [NSKeyedUnarchiver unarchiveObjectWithData:[weakSelf.messagingCenter sendMessageAndReceiveReplyName:GetContactsMessage userInfo:@{ 58 | ApplicationKey: applicationIdentifier, 59 | KeywordKey: keyword ?: @"" 60 | } error:NULL][ContactsKey]]; 61 | weakSelf.contactsViewController.contacts = result; 62 | [weakSelf.contactsViewController refreshData]; 63 | }; 64 | self.contactsViewController.selectionHandler = ^(NSDictionary *contact) { 65 | NSMutableDictionary *context = weakSelf.context.mutableCopy; 66 | context[CouriaIdentifier UserDomain] = contact[IdentifierKey]; 67 | weakSelf.context = context; 68 | [weakSelf.conversationViewController refreshData]; 69 | [weakSelf interactiveNotificationDidAppear]; 70 | [weakSelf.messagingCenter sendNonBlockingMessageName:UpdateBannerMessage userInfo:@{ 71 | PrimaryTextKey: contact[NicknameKey] 72 | }]; 73 | }; 74 | } 75 | } 76 | 77 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController_ThirdPartyApp, setupView) { 78 | CHSuper(0, CouriaInlineReplyViewController_ThirdPartyApp, setupView); 79 | self.entryView.shouldShowSubject = NO; 80 | self.entryView.shouldShowCharacterCount = NO; 81 | self.entryView.shouldShowPhotoButton = [self.context[CouriaIdentifier OptionsDomain][CanSendPhotosOption] boolValue]; 82 | } 83 | 84 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController_ThirdPartyApp, interactiveNotificationDidAppear) { 85 | CHSuper(0, CouriaInlineReplyViewController_ThirdPartyApp, interactiveNotificationDidAppear); 86 | NSString *applicationIdentifier = self.context[CouriaIdentifier ApplicationDomain]; 87 | NSString *userIdentifier = self.context[CouriaIdentifier UserDomain]; 88 | if (userIdentifier != nil) { 89 | self.entryView.hidden = NO; 90 | self.conversationViewController.view.hidden = NO; 91 | self.contactsViewController.view.hidden = YES; 92 | [self.messagingCenter sendNonBlockingMessageName:MarkReadMessage userInfo:@{ 93 | ApplicationKey: applicationIdentifier, 94 | UserKey: userIdentifier 95 | }]; 96 | } else { 97 | self.entryView.hidden = YES; 98 | self.conversationViewController.view.hidden = YES; 99 | self.contactsViewController.view.hidden = NO; 100 | [self.contactsViewController.searchBar becomeFirstResponder]; 101 | [self.contactsViewController searchBar:self.contactsViewController.searchBar textDidChange:self.contactsViewController.searchBar.text]; 102 | } 103 | } 104 | 105 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController_ThirdPartyApp, sendMessage) { 106 | CHSuper(0, CouriaInlineReplyViewController_ThirdPartyApp, sendMessage); 107 | NSString *applicationIdentifier = self.context[CouriaIdentifier ApplicationDomain]; 108 | NSString *userIdentifier = self.context[CouriaIdentifier UserDomain]; 109 | CKComposition *composition = self.entryView.composition; 110 | void (^ sendMessage)(id) = ^(id content) { 111 | [self.messagingCenter sendNonBlockingMessageName:SendMessageMessage userInfo:@{ 112 | ApplicationKey: applicationIdentifier, 113 | UserKey: userIdentifier, 114 | ContentKey: [NSKeyedArchiver archivedDataWithRootObject:content] 115 | }]; 116 | }; 117 | sendMessage(composition.text.string); 118 | for (CKMediaObject *mediaObject in composition.mediaObjects) { 119 | sendMessage(mediaObject.fileURL); 120 | } 121 | } 122 | 123 | void CouriaUIThirdPartyAppInit(void) { 124 | CHLoadLateClass(CouriaInlineReplyViewController); 125 | CHRegisterClass(CouriaInlineReplyViewController_ThirdPartyApp, CouriaInlineReplyViewController) { 126 | CHHook(0, CouriaInlineReplyViewController_ThirdPartyApp, setupConversation); 127 | CHHook(0, CouriaInlineReplyViewController_ThirdPartyApp, setupView); 128 | CHHook(0, CouriaInlineReplyViewController_ThirdPartyApp, interactiveNotificationDidAppear); 129 | CHHook(0, CouriaInlineReplyViewController_ThirdPartyApp, sendMessage); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/CouriaUI/ViewService.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | 3 | static CPDistributedMessagingCenter *messagingCenter; 4 | static NSUserDefaults *preferences; 5 | static NSMutableArray *customBubbleColors; 6 | 7 | CHDeclareClass(CKInlineReplyViewController) 8 | CHDeclareClass(CouriaInlineReplyViewController) 9 | CHDeclareClass(CKMessageEntryView) 10 | CHDeclareClass(CKUIBehavior) 11 | CHPropertyRetainNonatomic(CouriaInlineReplyViewController, CouriaConversationViewController *, conversationViewController, setConversationViewController) 12 | CHPropertyRetainNonatomic(CouriaInlineReplyViewController, CouriaContactsViewController *, contactsViewController, setContactsViewController) 13 | CHPropertyRetainNonatomic(CouriaInlineReplyViewController, CouriaPhotosViewController *, photosViewController, setPhotosViewController) 14 | 15 | CHOptimizedMethod(0, super, id, CouriaInlineReplyViewController, init) { 16 | self = CHSuper(0, CouriaInlineReplyViewController, init); 17 | if (self) { 18 | self.conversationViewController = [[CouriaConversationViewController alloc]initWithConversation:nil transcriptWidth:self.view.bounds.size.width entryContentViewWidth:self.entryView.contentView.bounds.size.width]; 19 | self.contactsViewController = [[CouriaContactsViewController alloc]initWithStyle:UITableViewStylePlain]; 20 | self.photosViewController = [[CouriaPhotosViewController alloc]init]; 21 | [self addChildViewController:self.conversationViewController]; 22 | [self addChildViewController:self.contactsViewController]; 23 | [self addChildViewController:self.photosViewController.viewController]; 24 | } 25 | return self; 26 | } 27 | 28 | CHPropertyGetter(CouriaInlineReplyViewController, messagingCenter, CPDistributedMessagingCenter *) { 29 | return messagingCenter; 30 | } 31 | 32 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController, setupConversation) { 33 | CHSuper(0, CouriaInlineReplyViewController, setupConversation); 34 | NSString *applicationIdentifier = self.context[CouriaIdentifier ApplicationDomain]; 35 | CouriaRegisterDefaults(preferences, applicationIdentifier); 36 | CouriaBubbleTheme bubbleTheme = [preferences integerForKey:[applicationIdentifier stringByAppendingString:BubbleThemeSetting]]; 37 | self.conversationViewController.bubbleTheme = bubbleTheme; 38 | self.conversationViewController.bubbleColors = bubbleTheme == CouriaBubbleThemeCustom ? @[ 39 | CouriaColor([preferences stringForKey:[applicationIdentifier stringByAppendingString:CustomMyBubbleColorSetting]]), 40 | CouriaColor([preferences stringForKey:[applicationIdentifier stringByAppendingString:CustomMyBubbleTextColorSetting]]), 41 | CouriaColor([preferences stringForKey:[applicationIdentifier stringByAppendingString:CustomOthersBubbleColorSetting]]), 42 | CouriaColor([preferences stringForKey:[applicationIdentifier stringByAppendingString:CustomOthersBubbleTextColorSetting]]) 43 | ] : nil; 44 | } 45 | 46 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController, setupView) { 47 | CHSuper(0, CouriaInlineReplyViewController, setupView); 48 | [self.view addSubview:self.conversationViewController.view]; 49 | [self.view addSubview:self.contactsViewController.view]; 50 | (void)self.photosViewController.viewController.view; 51 | [self.entryView.photoButton addTarget:self action:@selector(photoButtonTapped:) forControlEvents:UIControlEventTouchUpInside]; 52 | self.conversationViewController.view.hidden = YES; 53 | self.contactsViewController.view.hidden = YES; 54 | self.entryView.hidden = YES; 55 | } 56 | 57 | CHOptimizedMethod(0, super, CGFloat, CouriaInlineReplyViewController, preferredContentHeight) { 58 | return self.maximumHeight ?: CHSuper(0, CouriaInlineReplyViewController, preferredContentHeight); 59 | } 60 | 61 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController, viewDidLayoutSubviews) { 62 | CHSuper(0, CouriaInlineReplyViewController, viewDidLayoutSubviews); 63 | CGFloat contentHeight = self.preferredContentHeight; 64 | if (self.view.bounds.size.height != contentHeight) { 65 | [self requestPreferredContentHeight:contentHeight]; 66 | } 67 | CGSize size = self.view.bounds.size; 68 | BOOL photoShowing = self.photosViewController.view.superview == self.view; 69 | CGFloat photoHeight = [CKUIBehavior sharedBehaviors].photoPickerMaxPhotoHeight; 70 | CGFloat entryHeight = MIN([self.entryView sizeThatFits:size].height, size.height - photoHeight * photoShowing); 71 | CGFloat conversationHeight = size.height - entryHeight - photoHeight * photoShowing; 72 | self.conversationViewController.view.frame = CGRectMake(0, 0, size.width, conversationHeight); 73 | self.contactsViewController.view.frame = CGRectMake(0, 0, size.width, size.height); 74 | self.photosViewController.view.frame = CGRectMake(0, conversationHeight, size.width, photoHeight); 75 | self.entryView.frame = CGRectMake(0, conversationHeight + photoHeight * photoShowing, size.width, entryHeight); 76 | if (!self.conversationViewController.collectionView.__ck_isScrolledToBottom) { 77 | [self.conversationViewController.collectionView __ck_scrollToBottom:NO]; 78 | } 79 | if (!self.contactsViewController.tableView.__ck_isScrolledToTop) { 80 | [self.contactsViewController.tableView __ck_scrollToTop:NO]; 81 | } 82 | } 83 | 84 | CHOptimizedMethod(1, super, void, CouriaInlineReplyViewController, messageEntryViewDidChange, CKMessageEntryView *, entryView) { 85 | [self.view setNeedsLayout]; 86 | [self.view layoutIfNeeded]; 87 | } 88 | 89 | CHOptimizedMethod(1, super, void, CouriaInlineReplyViewController, messageEntryViewSendButtonHit, CKMessageEntryView *, entryView) { 90 | if ([preferences boolForKey:[self.context[CouriaIdentifier ApplicationDomain]stringByAppendingString:DismissOnSendSetting]]) { 91 | CHSuper(1, CouriaInlineReplyViewController, messageEntryViewSendButtonHit, entryView); 92 | } else { 93 | UITextView *typingView = [self viewForTyping]; 94 | [self sendMessage]; 95 | self.entryView.sendingMessage = NO; 96 | self.entryView.composition = [CKComposition composition]; 97 | [typingView becomeFirstResponder]; 98 | } 99 | } 100 | 101 | CHOptimizedMethod(0, super, void, CouriaInlineReplyViewController, sendMessage) { 102 | if (self.photosViewController.view.superview == self.view) { 103 | [self photoButtonTapped:nil]; 104 | } 105 | CHSuper(0, CouriaInlineReplyViewController, sendMessage); 106 | } 107 | 108 | CHOptimizedMethod(1, new, void, CouriaInlineReplyViewController, photoButtonTapped, UIButton *, button) { 109 | if (self.photosViewController.view.superview != self.view) { 110 | [self.view addSubview:self.photosViewController.view]; 111 | } else { 112 | NSArray *mediaObjects = self.photosViewController.fetchAndClearSelectedPhotos; 113 | CKComposition *photosComposition = [CKComposition photoPickerCompositionWithMediaObjects:mediaObjects]; 114 | self.entryView.composition = [self.entryView.composition compositionByAppendingComposition:photosComposition]; 115 | [self.photosViewController.view removeFromSuperview]; 116 | } 117 | } 118 | 119 | CHOptimizedMethod(6, self, id ,CKMessageEntryView, initWithFrame, CGRect, frame, marginInsets, UIEdgeInsets, marginInsets, shouldShowSendButton, BOOL, shouldShowSendButton, shouldShowSubject, BOOL, shouldShowSubject, shouldShowPhotoButton, BOOL, shouldShowPhotoButton, shouldShowCharacterCount, BOOL, shouldShowCharacterCount) { 120 | shouldShowPhotoButton = YES; 121 | self = CHSuper(6, CKMessageEntryView, initWithFrame, frame, marginInsets, marginInsets, shouldShowSendButton, shouldShowSendButton, shouldShowSubject, shouldShowSubject, shouldShowPhotoButton, shouldShowPhotoButton, shouldShowCharacterCount, shouldShowCharacterCount); 122 | if (self) { 123 | self.shouldShowPhotoButton = NO; 124 | } 125 | return self; 126 | } 127 | 128 | CHOptimizedMethod(5, self, id, CKMessageEntryView, initWithFrame, CGRect, frame, shouldShowSendButton, BOOL, sendButton, shouldShowSubject, BOOL, subject, shouldShowPhotoButton, BOOL, photoButton, shouldShowCharacterCount, BOOL, characterCount) { 129 | photoButton = YES; 130 | self = CHSuper(5, CKMessageEntryView, initWithFrame, frame, shouldShowSendButton, sendButton, shouldShowSubject, subject, shouldShowPhotoButton, photoButton, shouldShowCharacterCount, characterCount); 131 | if (self) { 132 | self.shouldShowPhotoButton = NO; 133 | } 134 | return self; 135 | } 136 | 137 | CHOptimizedMethod(1, self, void, CKMessageEntryView, setShouldShowPhotoButton, BOOL, shouldShowPhotoButton) { 138 | CHSuper(1, CKMessageEntryView, setShouldShowPhotoButton, shouldShowPhotoButton); 139 | self.photoButton.hidden = !shouldShowPhotoButton; 140 | [self setNeedsLayout]; 141 | [self layoutIfNeeded]; 142 | } 143 | 144 | CHOptimizedMethod(0, self, void, CKMessageEntryView, updateEntryView) { 145 | CHSuper(0, CKMessageEntryView, updateEntryView); 146 | if (self.conversation.chat == nil) { 147 | self.sendButton.enabled = self.composition.hasContent; 148 | self.photoButton.enabled = YES; 149 | } 150 | } 151 | 152 | #define CHCKUIBehavior(type, name, value) \ 153 | CHOptimizedMethod(0, self, type, CKUIBehavior, name) { \ 154 | static type name; \ 155 | static dispatch_once_t onceToken; \ 156 | dispatch_once(&onceToken, ^{ \ 157 | name = value; \ 158 | }); \ 159 | return name; \ 160 | } 161 | CHCKUIBehavior(UIColor *, transcriptBackgroundColor, [UIColor clearColor]) 162 | CHCKUIBehavior(BOOL, transcriptCanUseOpaqueMask, NO) 163 | CHCKUIBehavior(BOOL, photoPickerShouldZoomOnSelection, NO) 164 | 165 | CHOptimizedMethod(1, self, NSArray *, CKUIBehavior, balloonColorsForColorType, CKBalloonColor, colorType) { 166 | return colorType >= CKBalloonColorCouria ? @[customBubbleColors[colorType - CKBalloonColorCouria]] : CHSuper(1, CKUIBehavior, balloonColorsForColorType, colorType); 167 | } 168 | 169 | CHOptimizedMethod(1, self, UIColor *, CKUIBehavior, balloonOverlayColorForColorType, CKBalloonColor, colorType) { 170 | return colorType >= CKBalloonColorCouria ? [UIColor colorWithWhite:0 alpha:0.1] : CHSuper(1, CKUIBehavior, balloonOverlayColorForColorType, colorType); 171 | } 172 | 173 | CHOptimizedMethod(1, new, CKBalloonColor, CKUIBehavior, colorTypeForColor, UIColor *, color) { 174 | NSUInteger index = [customBubbleColors indexOfObject:color]; 175 | if (index == NSNotFound) { 176 | if (customBubbleColors.count >= (UINT8_MAX + 1 - 5)) { 177 | [customBubbleColors removeObjectAtIndex:0]; 178 | } 179 | [customBubbleColors addObject:color]; 180 | index = customBubbleColors.count - 1; 181 | } 182 | return CKBalloonColorCouria + index; 183 | } 184 | 185 | void CouriaUIViewServiceInit(void) { 186 | messagingCenter = [CPDistributedMessagingCenter centerNamed:CouriaIdentifier]; 187 | preferences = [[NSUserDefaults alloc]initWithSuiteName:CouriaIdentifier]; 188 | customBubbleColors = [NSMutableArray array]; 189 | CHLoadLateClass(CKInlineReplyViewController); 190 | CHRegisterClass(CouriaInlineReplyViewController, CKInlineReplyViewController) { 191 | CHHook(0, CouriaInlineReplyViewController, init); 192 | CHHook(0, CouriaInlineReplyViewController, messagingCenter); 193 | CHHook(0, CouriaInlineReplyViewController, conversationViewController); 194 | CHHook(1, CouriaInlineReplyViewController, setConversationViewController); 195 | CHHook(0, CouriaInlineReplyViewController, contactsViewController); 196 | CHHook(1, CouriaInlineReplyViewController, setContactsViewController); 197 | CHHook(0, CouriaInlineReplyViewController, photosViewController); 198 | CHHook(1, CouriaInlineReplyViewController, setPhotosViewController); 199 | CHHook(0, CouriaInlineReplyViewController, setupConversation); 200 | CHHook(0, CouriaInlineReplyViewController, setupView); 201 | CHHook(0, CouriaInlineReplyViewController, preferredContentHeight); 202 | CHHook(0, CouriaInlineReplyViewController, viewDidLayoutSubviews); 203 | CHHook(1, CouriaInlineReplyViewController, messageEntryViewDidChange); 204 | CHHook(1, CouriaInlineReplyViewController, messageEntryViewSendButtonHit); 205 | CHHook(0, CouriaInlineReplyViewController, sendMessage); 206 | CHHook(1, CouriaInlineReplyViewController, photoButtonTapped); 207 | } 208 | CHLoadClass(CKMessageEntryView); 209 | CHLoadClass(CKUIBehavior); 210 | CHHook(6, CKMessageEntryView, initWithFrame, marginInsets, shouldShowSendButton, shouldShowSubject, shouldShowPhotoButton, shouldShowCharacterCount); 211 | CHHook(5, CKMessageEntryView, initWithFrame, shouldShowSendButton, shouldShowSubject, shouldShowPhotoButton, shouldShowCharacterCount); 212 | CHHook(1, CKMessageEntryView, setShouldShowPhotoButton); 213 | CHHook(0, CKMessageEntryView, updateEntryView); 214 | CHHook(0, CKUIBehavior, transcriptBackgroundColor); 215 | CHHook(0, CKUIBehavior, transcriptCanUseOpaqueMask); 216 | CHHook(0, CKUIBehavior, photoPickerShouldZoomOnSelection); 217 | CHHook(1, CKUIBehavior, balloonColorsForColorType); 218 | CHHook(1, CKUIBehavior, balloonOverlayColorForColorType); 219 | CHHook(1, CKUIBehavior, colorTypeForColor); 220 | } 221 | -------------------------------------------------------------------------------- /src/Headers.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | #import 6 | #import 7 | #import 8 | #import 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | #import 16 | #import "../Couria.h" 17 | 18 | #define CouriaIdentifier @"me.qusic.couria" 19 | #define SpringBoardIdentifier @"com.apple.springboard" 20 | #define MobileSMSIdentifier @"com.apple.MobileSMS" 21 | #define MessagesNotificationViewServiceIdentifier @"com.apple.mobilesms.notification" 22 | 23 | #define ApplicationDomain ".application" 24 | #define UserDomain ".user" 25 | #define ActionDomain ".action" 26 | #define OptionsDomain ".options" 27 | 28 | #define ExtensionsKey @"extensions" 29 | #define IdentifierKey @"identifier" 30 | #define ApplicationKey @"application" 31 | #define NameKey @"name" 32 | #define IconKey @"icon" 33 | #define UserKey @"user" 34 | #define NicknameKey @"nickname" 35 | #define AvatarKey @"avatar" 36 | #define MessagesKey @"messages" 37 | #define ContactsKey @"contacts" 38 | #define ContentKey @"content" 39 | #define TimestampKey @"timestamp" 40 | #define OutgoingKey @"outgoing" 41 | #define KeywordKey @"keyword" 42 | #define PrimaryTextKey @"primaryText" 43 | #define SecondaryTextKey @"secondaryText" 44 | 45 | #define GetMessagesMessage @"getMessages" 46 | #define GetContactsMessage @"getContacts" 47 | #define SendMessageMessage @"sendMessage" 48 | #define MarkReadMessage @"markRead" 49 | #define ListExtensionsMessage @"listExtensions" 50 | #define UpdateBannerMessage @"updateBanner" 51 | 52 | #define CanSendPhotosOption @"canSendPhotos" 53 | #define ColorSpecifierOption @"colorSpecifier" 54 | 55 | #define EnabledSetting @".enabled" 56 | #define AuthenticationRequiredSetting @".authenticationRequired" 57 | #define DismissOnSendSetting @".dismissOnSend" 58 | #define BubbleThemeSetting @".bubbleTheme" 59 | #define CustomMyBubbleColorSetting @".customMyBubbleColor" 60 | #define CustomMyBubbleTextColorSetting @".customMyBubbleTextColor" 61 | #define CustomOthersBubbleColorSetting @".customOthersBubbleColor" 62 | #define CustomOthersBubbleTextColorSetting @".customOthersBubbleTextColor" 63 | 64 | typedef NS_ENUM(NSInteger, CouriaBubbleTheme) { 65 | CouriaBubbleThemeOriginal = 0, 66 | CouriaBubbleThemeOutline = 1, 67 | CouriaBubbleThemeCustom = 2 68 | }; 69 | 70 | @interface UIScrollView (CKUtilities) 71 | - (void)__ck_scrollToTop:(BOOL)animated; 72 | - (BOOL)__ck_isScrolledToTop; 73 | - (CGPoint)__ck_scrollToTopContentOffset; 74 | - (void)__ck_scrollToBottom:(BOOL)animated; 75 | - (BOOL)__ck_isScrolledToBottom; 76 | - (CGPoint)__ck_scrollToBottomContentOffset; 77 | - (CGSize)__ck_contentSize; 78 | @end 79 | 80 | @interface UISearchBar (Private) 81 | - (UIView *)_backgroundView; 82 | @end 83 | 84 | @interface UITextInputMode (Private) 85 | - (NSString *)identifier; 86 | - (NSString *)extension; 87 | - (NSArray *)normalizedIdentifierLevels; 88 | @end 89 | 90 | @class BBDataProvider, BBBulletinRequest; 91 | 92 | extern dispatch_queue_t __BBServerQueue; 93 | 94 | extern void _BBDataProviderAddBulletinForDestinations(BBDataProvider *dataProvider, BBBulletinRequest *bulletin, NSUInteger destinations, BOOL addToLockScreen); 95 | extern void BBDataProviderAddBulletinForDestinations(BBDataProvider *dataProvider, BBBulletinRequest *bulletin, NSUInteger destinations); // _BBDataProviderAddBulletinForDestinations: addToLockScreen = NO 96 | extern void BBDataProviderAddBulletin(BBDataProvider *dataProvider, BBBulletinRequest *bulletin, BOOL allDestinations); // _BBDataProviderAddBulletinForDestinations: destinations = allDestinations ? 0xe : 0x2, addToLockScreen = NO 97 | extern void BBDataProviderAddBulletinToLockScreen(BBDataProvider *dataProvider, BBBulletinRequest *bulletin); // _BBDataProviderAddBulletinForDestinations: destinations = 0x4, addToLockScreen = YES 98 | extern void BBDataProviderModifyBulletin(BBDataProvider *dataProvider, BBBulletinRequest *bulletin); // _BBDataProviderAddBulletinForDestinations: destinations = 0x0, addToLockScreen = NO 99 | extern void BBDataProviderWithdrawBulletinWithPublisherBulletinID(BBDataProvider *dataProvider, NSString *publisherBulletinID); 100 | extern void BBDataProviderWithdrawBulletinsWithRecordID(BBDataProvider *dataProvider, NSString *recordID); 101 | extern void BBDataProviderInvalidateBulletinsForDestinations(BBDataProvider *dataProvider, NSUInteger destinations); 102 | extern void BBDataProviderInvalidateBulletins(BBDataProvider *dataProvider); // BBDataProviderInvalidateBulletinsForDestinations: destinations = 0x32 103 | extern void BBDataProviderReloadDefaultSectionInfo(BBDataProvider *dataProvider); 104 | extern void BBDataProviderSetApplicationBadge(BBDataProvider *dataProvider, NSInteger value); 105 | extern void BBDataProviderSetApplicationBadgeString(BBDataProvider *dataProvider, NSString *value); 106 | 107 | @interface BBDataProvider : NSObject 108 | @end 109 | 110 | @interface BBAppearance : NSObject 111 | @property (copy, nonatomic) NSString *title; 112 | + (instancetype)appearanceWithTitle:(NSString *)title; 113 | @end 114 | 115 | @interface BBAction : NSObject 116 | @property (copy, nonatomic) NSString *identifier; 117 | @property (assign, nonatomic) NSInteger actionType; 118 | @property (copy, nonatomic) BBAppearance *appearance; 119 | @property (copy, nonatomic) NSString *launchBundleID; 120 | @property (copy, nonatomic) NSURL *launchURL; 121 | @property (copy, nonatomic) NSString *remoteServiceBundleIdentifier; 122 | @property (copy, nonatomic) NSString *remoteViewControllerClassName; 123 | @property (assign, nonatomic) BOOL canBypassPinLock; 124 | @property (assign, nonatomic) BOOL launchCanBypassPinLock; 125 | @property (assign, nonatomic) NSUInteger activationMode; 126 | @property (assign ,nonatomic, getter=isAuthenticationRequired) BOOL authenticationRequired; 127 | + (instancetype)action; 128 | + (instancetype)actionWithIdentifier:(NSString *)identifier; 129 | + (instancetype)actionWithLaunchBundleID:(NSString *)bundleID; 130 | @end 131 | 132 | @interface BBBulletin : NSObject 133 | @property (copy, nonatomic) NSString *bulletinID; 134 | @property (copy, nonatomic) NSString *sectionID; 135 | @property (copy, nonatomic) NSString *recordID; 136 | @property (copy, nonatomic) NSString *publisherBulletinID; 137 | @property (copy, nonatomic) NSString *title; 138 | @property (copy, nonatomic) NSString *subtitle; 139 | @property (copy, nonatomic) NSString *message; 140 | @property (retain, nonatomic) NSDictionary *context; 141 | @property (copy, nonatomic) NSDictionary *actions; 142 | @property (retain, nonatomic) NSDictionary *supplementaryActionsByLayout; 143 | @property (copy, nonatomic) BBAction *defaultAction; 144 | @property (copy, nonatomic) BBAction *alternateAction; 145 | @property (copy, nonatomic) BBAction *acknowledgeAction; 146 | - (NSArray *)_allActions; 147 | - (NSArray *)_allSupplementaryActions; 148 | - (NSArray *)supplementaryActions; 149 | - (NSArray *)supplementaryActionsForLayout:(NSInteger)layout; 150 | @end 151 | 152 | @interface BBBulletinRequest : BBBulletin 153 | - (void)setContextValue:(id)value forKey:(NSString *)key; 154 | - (void)setSupplementaryActions:(NSArray *)actions; 155 | - (void)setSupplementaryActions:(NSArray *)actions forLayout:(NSInteger)layout; 156 | - (void)generateNewBulletinID; 157 | @end 158 | 159 | @interface BBServer : NSObject 160 | - (BBDataProvider *)dataProviderForSectionID:(NSString *)sectionID; 161 | - (NSSet *)allBulletinIDsForSectionID:(NSString *)sectionID; 162 | - (NSSet *)bulletinIDsForSectionID:(NSString *)sectionID inFeed:(NSUInteger)feed; 163 | - (NSSet *)bulletinsRequestsForBulletinIDs:(NSSet *)bulletinIDs; 164 | - (NSSet *)bulletinsForPublisherBulletinIDs:(NSSet *)publisherBulletinIDs sectionID:(NSString *)sectionID; 165 | - (void)_publishBulletinRequest:(BBBulletinRequest *)bulletinRequest forSectionID:(NSString *)sectionID forDestinations:(NSUInteger)destinations alwaysToLockScreen:(BOOL)alwaysToLockScreen; 166 | - (void)publishBulletinRequest:(BBBulletinRequest *)bulletinRequest destinations:(NSUInteger)destinations alwaysToLockScreen:(BOOL)alwaysToLockScreen; 167 | @end 168 | 169 | @interface BBServer (Couria) 170 | + (instancetype)sharedInstance; 171 | @end 172 | 173 | typedef unsigned int FZListenerCapability; 174 | 175 | extern FZListenerCapability kFZListenerCapOnDemandChatRegistry; 176 | extern NSString *IMChatItemsDidChangeNotification; 177 | extern NSString *IMAttachmentCharacterString; 178 | extern NSString *IMMessagePartAttributeName; 179 | extern NSString *IMFileTransferGUIDAttributeName; 180 | extern NSString *IMFilenameAttributeName; 181 | extern NSString *IMInlineMediaWidthAttributeName; 182 | extern NSString *IMInlineMediaHeightAttributeName; 183 | extern NSString *IMBaseWritingDirectionAttributeName; 184 | extern NSString *IMFileTransferAVTranscodeOptionAssetURI; 185 | extern NSString *IMStripFormattingFromAddress(NSString *formattedAddress); 186 | 187 | @interface IMService : NSObject 188 | @end 189 | 190 | @interface IMAccount : NSObject 191 | - (NSArray *)__ck_handlesFromAddressStrings:(NSArray *)addresses; 192 | @end 193 | 194 | @interface IMHandle : NSObject 195 | @property (retain, nonatomic, readonly) NSString *ID; 196 | @property (retain, nonatomic, readonly) NSString *name; 197 | @end 198 | 199 | @class IMChatItem; 200 | 201 | @interface IMItem : NSObject 202 | @property (retain, nonatomic) NSDate *time; 203 | @property (retain, nonatomic) id context; 204 | + (Class)contextClass; 205 | - (instancetype)initWithDictionary:(NSDictionary *)dictionary; 206 | - (IMChatItem *)_newChatItems; 207 | @end 208 | 209 | @interface IMMessageItem : IMItem 210 | @property (retain, nonatomic) NSString *subject; 211 | @property (retain, nonatomic) NSAttributedString *body; 212 | @property (retain, nonatomic) NSString *plainBody; 213 | @property (retain, nonatomic) NSData *bodyData; 214 | @property (retain, nonatomic) NSDate *timeDelivered; 215 | @property (retain, nonatomic) NSDate *timeRead; 216 | @property (assign, nonatomic) NSUInteger flags; 217 | @end 218 | 219 | @interface IMMessage : NSObject 220 | + (instancetype)messageFromIMMessageItem:(IMMessageItem *)item sender:(id)sender subject:(id)subject; 221 | @end 222 | 223 | @interface IMItemChatContext : NSObject { 224 | IMHandle *_otherHandle; 225 | IMHandle *_senderHandle; 226 | } 227 | @end 228 | 229 | @interface IMMessageItemChatContext : IMItemChatContext { 230 | BOOL _invitation; 231 | IMMessage *_message; 232 | } 233 | @end 234 | 235 | @interface IMChatItem : NSObject 236 | - (IMItem *)_item; 237 | @end 238 | 239 | @interface IMTranscriptChatItem : IMChatItem 240 | @end 241 | 242 | @protocol IMMessageChatItem 243 | @required 244 | - (NSDate *)time; 245 | - (IMHandle *)sender; 246 | - (BOOL)isFromMe; 247 | - (BOOL)failed; 248 | @end 249 | 250 | @interface IMMessageChatItem : IMTranscriptChatItem 251 | @end 252 | 253 | @interface IMMessagePartChatItem : IMMessageChatItem 254 | @end 255 | 256 | @interface IMTextMessagePartChatItem : IMMessagePartChatItem 257 | @end 258 | 259 | @interface IMAttachmentMessagePartChatItem : IMMessagePartChatItem 260 | - (instancetype)_initWithItem:(IMMessageItem *)item text:(NSAttributedString *)text index:(NSInteger)index transferGUID:(NSString *)transferGUID; 261 | @end 262 | 263 | @interface IMChat : NSObject 264 | @property (nonatomic, readonly) NSString *chatIdentifier; 265 | @property (retain, nonatomic) NSString *displayName; 266 | @property (retain, nonatomic) IMHandle *recipient; 267 | @property (nonatomic, readonly) NSArray *participants; 268 | @property (nonatomic, readonly) NSArray *chatItems; 269 | @property (assign, nonatomic) NSUInteger numberOfMessagesToKeepLoaded; 270 | - (NSString *)loadMessagesBeforeDate:(NSDate *)date limit:(NSUInteger)limit loadImmediately:(BOOL)immediately; 271 | @end 272 | 273 | @interface IMPreferredServiceManager : NSObject 274 | + (instancetype)sharedPreferredServiceManager; 275 | - (IMService *)preferredServiceForHandles:(NSArray *)handles newComposition:(BOOL)newComposition error:(NSError * __autoreleasing *)errpt serverCheckCompletionBlock:(id)completion; 276 | @end 277 | 278 | @interface IMAccountController : NSObject 279 | + (instancetype)sharedInstance; 280 | - (IMAccount *)__ck_defaultAccountForService:(IMService *)service; 281 | @end 282 | 283 | @interface IMHandleRegistrar : NSObject 284 | + (instancetype)sharedInstance; 285 | - (NSArray *)allIMHandles; 286 | @end 287 | 288 | @interface IMChatRegistry : NSObject 289 | + (instancetype)sharedInstance; 290 | - (NSArray *)allExistingChats; 291 | @end 292 | 293 | @interface IMDaemonListener : NSObject 294 | @property (nonatomic, readonly) NSArray *allServices; 295 | @property (nonatomic, readonly) NSArray *handlers; 296 | - (void)addHandler:(id)handler; 297 | @end 298 | 299 | @interface IMDaemonController : NSObject 300 | @property (nonatomic, readonly) FZListenerCapability capabilities; 301 | @property (nonatomic, readonly) IMDaemonListener *listener; 302 | @property (nonatomic, readonly) BOOL isConnected; 303 | @property (nonatomic, readonly) BOOL isConnecting; 304 | + (instancetype)sharedInstance; 305 | - (BOOL)connectToDaemon; 306 | - (BOOL)connectToDaemonWithLaunch:(BOOL)launch; 307 | - (BOOL)connectToDaemonWithLaunch:(BOOL)launch capabilities:(FZListenerCapability)capabilities blockUntilConnected:(BOOL)block; 308 | - (BOOL)addListenerID:(NSString *)listenerID capabilities:(FZListenerCapability)capabilities; 309 | - (FZListenerCapability)capabilitiesForListenerID:(NSString *)listenerID; 310 | - (BOOL)setCapabilities:(FZListenerCapability)capabilities forListenerID:(NSString *)listenerID; 311 | @end 312 | 313 | #define CKBBUserInfoKeyChatIdentifierKey @"CKBBUserInfoKeyChatIdentifier" 314 | extern NSBundle *CKFrameworkBundle(void); 315 | extern FZListenerCapability CKListenerCapabilities(void) __attribute__((weak_import)); 316 | extern FZListenerCapability CKListenerPaginatedChatRegistryCapabilities(void) __attribute__((weak_import)); 317 | extern BOOL CKIsRunningInFullCKClient(void); 318 | extern BOOL CKIsRunningInMessages(void); 319 | extern BOOL CKIsRunningInMessagesOrSpringBoard(void); 320 | 321 | @interface CKEntity : NSObject 322 | @property (copy, nonatomic, readonly) NSString *name; 323 | @property (copy, nonatomic, readonly) NSString *rawAddress; 324 | @property (retain, nonatomic, readonly) UIImage *transcriptContactImage; 325 | @property (retain, nonatomic) IMHandle *handle; 326 | @property (retain, nonatomic, readonly) IMHandle *defaultIMHandle; 327 | + (instancetype)copyEntityForAddressString:(NSString *)addressString; 328 | @end 329 | 330 | @interface CKChatItem : NSObject 331 | @property (retain, nonatomic) IMTranscriptChatItem *IMChatItem; 332 | @property (copy, nonatomic) NSAttributedString *transcriptText; 333 | @property (copy, nonatomic) NSAttributedString *transcriptDrawerText; 334 | @end 335 | 336 | @interface CKMediaObject : NSObject 337 | @property (copy, nonatomic, readonly) NSString *transferGUID; 338 | @property (copy, nonatomic, readonly) NSURL *fileURL; 339 | @end 340 | 341 | @interface CKMediaObjectManager : NSObject 342 | + (instancetype)sharedInstance; 343 | - (CKMediaObject *)mediaObjectWithFileURL:(NSURL *)url filename:(NSString *)filename transcoderUserInfo:(NSDictionary *)transcoderUserInfo; 344 | - (CKMediaObject *)mediaObjectWithData:(NSData *)data UTIType:(NSString *)type filename:(NSString *)filename transcoderUserInfo:(NSDictionary *)transcoderUserInfo; 345 | @end 346 | 347 | typedef NS_ENUM(SInt8, CKBalloonColor) { 348 | CKBalloonColorGray = -1, 349 | CKBalloonColorGreen = 0, 350 | CKBalloonColorBlue = 1, 351 | CKBalloonColorWhite = 2, 352 | CKBalloonColorRed = 3, 353 | CKBalloonColorCouria = 4, 354 | }; 355 | 356 | @interface CKBalloonChatItem : CKChatItem 357 | @end 358 | 359 | @interface CKMessagePartChatItem : CKBalloonChatItem 360 | @property (nonatomic, readonly) CKBalloonColor color; 361 | @end 362 | 363 | @interface CKTextMessagePartChatItem : CKMessagePartChatItem 364 | @end 365 | 366 | @interface CKAttachmentMessagePartChatItem : CKMessagePartChatItem 367 | @property (retain, nonatomic) CKMediaObject *mediaObject; 368 | @end 369 | 370 | @interface CKConversation : NSObject 371 | @property (retain, nonatomic) IMChat *chat; 372 | @property (nonatomic, readonly, retain) NSString *groupID; 373 | @property (retain, nonatomic, readonly) NSString *name; 374 | @property (nonatomic) NSString *displayName; 375 | @property (nonatomic, readonly) BOOL hasDisplayName; 376 | @property (nonatomic, readonly, retain) CKEntity *recipient; 377 | @property (retain, nonatomic) NSArray *recipients; 378 | @property (nonatomic, readonly) unsigned int recipientCount; 379 | @property (getter=isGroupConversation, nonatomic, readonly) BOOL groupConversation; 380 | @property (retain, nonatomic, readonly) NSString *previewText; 381 | @property (nonatomic, readonly) BOOL isPreviewTextForAttachment; 382 | @property (assign, nonatomic) NSUInteger limitToLoad; 383 | - (NSArray *)orderedContactsForAvatarView; 384 | - (void)markAllMessagesAsRead; 385 | @end 386 | 387 | @interface CKConversationList : NSObject 388 | + (instancetype)sharedConversationList; 389 | - (NSArray *)conversations; 390 | - (NSArray *)activeConversations; 391 | - (CKConversation *)conversationForExistingChatWithGroupID:(NSString *)groupID; 392 | - (CKConversation *)conversationForHandles:(NSArray *)handles displayName:(NSString *)displayName joinedChatsOnly:(BOOL)joinedChatsOnly create:(BOOL)create; // iOS 9 393 | - (CKConversation *)conversationForHandles:(NSArray *)handles create:(BOOL)create; // iOS 8 394 | - (void)setNeedsReload; 395 | - (void)resort; 396 | - (void)resetCaches; 397 | @end 398 | 399 | @interface CKComposition : NSObject 400 | @property (copy, nonatomic) NSAttributedString *subject; 401 | @property (copy, nonatomic) NSAttributedString *text; 402 | @property (retain, nonatomic, readonly) NSArray *mediaObjects; 403 | @property (nonatomic, readonly) BOOL hasContent; 404 | @property (nonatomic, readonly) BOOL hasNonwhiteSpaceContent; 405 | + (instancetype)composition; 406 | + (instancetype)compositionWithMediaObjects:(NSArray *)mediaObjects subject:(NSAttributedString *)subject; 407 | + (instancetype)compositionWithMediaObject:(CKMediaObject *)mediaObject subject:(NSAttributedString *)subject; 408 | + (instancetype)photoPickerCompositionWithMediaObjects:(NSArray *)mediaObjects; 409 | + (instancetype)photoPickerCompositionWithMediaObject:(CKMediaObject *)mediaObject; 410 | + (instancetype)quickImageCompositionWithMediaObject:(CKMediaObject *)mediaObject; 411 | + (instancetype)audioCompositionWithMediaObject:(CKMediaObject *)mediaObject; 412 | + (instancetype)expirableCompositionWithMediaObject:(CKMediaObject *)mediaObject; 413 | - (instancetype)compositionByAppendingComposition:(CKComposition *)composition; 414 | - (instancetype)compositionByAppendingText:(NSAttributedString *)text; 415 | - (instancetype)compositionByAppendingMediaObjects:(NSArray *)mediaObjects; 416 | - (instancetype)compositionByAppendingMediaObject:(CKMediaObject *)mediaObject; 417 | @end 418 | 419 | @interface CKAddressBook : NSObject 420 | + (UIImage *)transcriptContactImageOfDiameter:(CGFloat)diameter forRecordID:(ABRecordID)recordID; 421 | @end 422 | 423 | @interface CKBalloonTextView : UITextView 424 | @end 425 | 426 | @interface CKBalloonImageView : UIView 427 | @end 428 | 429 | @class CKBalloonView, CKMovieBalloonView; 430 | 431 | @protocol CKBalloonViewDelegate 432 | - (void)balloonViewWillResignFirstResponder:(CKBalloonView *)balloonView; 433 | - (void)balloonViewTapped:(CKBalloonView *)balloonView; 434 | - (void)balloonView:(CKBalloonView *)balloonView performAction:(SEL)action withSender:(id)sender; 435 | - (BOOL)balloonView:(CKBalloonView *)balloonView canPerformAction:(SEL)action withSender:(id)sender; 436 | - (CGRect)calloutTargetRectForBalloonView:(CKBalloonView *)balloonView; 437 | - (BOOL)shouldShowMenuForBalloonView:(CKBalloonView *)balloonView; 438 | - (NSArray *)menuItemsForBalloonView:(CKBalloonView *)balloonView; 439 | - (void)balloonViewDidFinishDataDetectorAction:(CKBalloonView *)balloonView; 440 | @end 441 | 442 | @protocol CKMovieBalloonViewDelegate 443 | @required 444 | - (void)balloonView:(CKMovieBalloonView *)balloonView mediaObjectDidFinishPlaying:(id)mediaObject; 445 | @end 446 | 447 | @protocol CKLocationShareBalloonViewDelegate 448 | @required 449 | - (void)locationShareBalloonViewShareButtonTapped:(id)balloonView; 450 | - (void)locationShareBalloonViewIgnoreButtonTapped:(id)balloonView; 451 | @end 452 | 453 | typedef NS_ENUM(SInt8, CKBalloonOrientation) { 454 | CKBalloonOrientationLeft = 0, 455 | CKBalloonOrientationRight = 1 456 | }; 457 | 458 | @interface CKBalloonView : CKBalloonImageView 459 | @property (assign, nonatomic) CKBalloonOrientation orientation; 460 | @property (assign, nonatomic) BOOL hasTail; 461 | @property (assign, nonatomic, getter=isFilled) BOOL filled; 462 | @property (assign, nonatomic) BOOL canUseOpaqueMask; 463 | @property (assign, nonatomic) id delegate; 464 | - (void)prepareForReuse; 465 | - (void)prepareForDisplay; 466 | - (void)setNeedsPrepareForDisplay; 467 | - (void)prepareForDisplayIfNeeded; 468 | @end 469 | 470 | @interface CKColoredBalloonView : CKBalloonView 471 | @property (assign, nonatomic) CKBalloonColor color; 472 | @property (assign, nonatomic) BOOL wantsGradient; 473 | @end 474 | 475 | @interface CKTextBalloonView : CKColoredBalloonView 476 | @property (copy, nonatomic) NSAttributedString *attributedText; 477 | @end 478 | 479 | @interface CKHyperlinkBalloonView : CKTextBalloonView 480 | @end 481 | 482 | @interface CKAnimatedImage : NSObject 483 | - (instancetype)initWithImages:(NSArray *)images durations:(NSArray *)durations; 484 | @end 485 | 486 | @interface CKImageBalloonView : CKBalloonView 487 | @property (retain, nonatomic) CKAnimatedImage *animatedImage; 488 | @end 489 | 490 | @interface CKMovieBalloonView : CKImageBalloonView 491 | @property (retain, nonatomic, setter=setAVPlayerItem:) AVPlayerItem *avPlayerItem; 492 | @end 493 | 494 | @interface CKViewController : UIViewController 495 | @end 496 | 497 | @interface CKEditableCollectionView : UICollectionView 498 | @end 499 | 500 | @interface CKTranscriptCollectionView : CKEditableCollectionView 501 | @end 502 | 503 | @class CKTranscriptCell; 504 | 505 | @interface CKTranscriptCollectionViewController : CKViewController 506 | @property (retain, nonatomic) CKConversation *conversation; 507 | @property (copy, nonatomic) NSArray *chatItems; 508 | @property (retain, nonatomic) CKTranscriptCollectionView *collectionView; 509 | @property (nonatomic, readonly) CGFloat leftBalloonMaxWidth; 510 | @property (nonatomic, readonly) CGFloat rightBalloonMaxWidth; 511 | - (instancetype)initWithConversation:(CKConversation *)conversation balloonMaxWidth:(CGFloat)balloonMaxWidth marginInsets:(UIEdgeInsets)marginInsets; // iOS 9 512 | - (instancetype)initWithConversation:(CKConversation *)conversation rightBalloonMaxWidth:(CGFloat)rightBalloonMaxWidth leftBalloonMaxWidth:(CGFloat)leftBalloonMaxWidth; // iOS 8 513 | - (CKChatItem *)chatItemWithIMChatItem:(IMChatItem *)imChatItem; 514 | - (void)configureCell:(CKTranscriptCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath; 515 | - (void)chatItemsDidChange:(NSNotification *)notification; 516 | @end 517 | 518 | @interface CouriaConversationViewController : CKTranscriptCollectionViewController 519 | @property (assign, nonatomic) CouriaBubbleTheme bubbleTheme; 520 | @property (retain, nonatomic) NSArray *bubbleColors; 521 | - (instancetype)initWithConversation:(CKConversation *)conversation transcriptWidth:(CGFloat)transcriptWidth entryContentViewWidth:(CGFloat)entryContentViewWidth; 522 | - (void)refreshData; 523 | @end 524 | 525 | @interface CKEditableCollectionViewCell : UICollectionViewCell 526 | @end 527 | 528 | @interface CKTranscriptCell : CKEditableCollectionViewCell 529 | @property (assign, nonatomic) BOOL wantsDrawerLayout; 530 | @end 531 | 532 | @interface CKTranscriptHeaderCell : CKTranscriptCell 533 | @end 534 | 535 | @interface CKTranscriptLabelCell : CKTranscriptCell 536 | @end 537 | 538 | @interface CKTranscriptMessageCell : CKTranscriptCell 539 | @property (assign, nonatomic) BOOL wantsContactImageLayout; 540 | @property (retain, nonatomic) UIImage *contactImage; 541 | @end 542 | 543 | @class CKAvatarView; 544 | 545 | @interface CKPhoneTranscriptMessageCell : CKTranscriptMessageCell 546 | @property (nonatomic, retain) CKAvatarView *avatarView; 547 | - (void)setAvatarView:(CKAvatarView *)avatarView; 548 | - (void)setShowAvatarView:(BOOL)showAvatarView withContact:(CNContact *)contact preferredHandle:(IMHandle *)preferredHandle avatarViewDelegate:(id)delegate; 549 | @end 550 | 551 | @interface CKTranscriptStatusCell : CKTranscriptLabelCell 552 | @end 553 | 554 | @interface CKTranscriptBalloonCell : CKTranscriptMessageCell 555 | @property (retain, nonatomic) CKBalloonView *balloonView; 556 | @property (copy, nonatomic) NSAttributedString *drawerText; 557 | @end 558 | 559 | @interface CouriaContactsViewController : UITableViewController 560 | @property (retain, nonatomic) NSArray *contacts; 561 | @property (retain, nonatomic) UISearchBar *searchBar; 562 | @property (copy, nonatomic) void (^ keywordHandler)(NSString *keyword); 563 | @property (copy, nonatomic) void (^ selectionHandler)(NSDictionary *contact); 564 | - (void)refreshData; 565 | @end 566 | 567 | @interface CKMessageEntryContentView : UIScrollView 568 | @end 569 | 570 | @interface CKMessageEntryView : UIView 571 | @property (retain, nonatomic) CKConversation *conversation; 572 | @property (retain, nonatomic) CKComposition *composition; 573 | @property (assign, nonatomic, getter=isSendingMessage) BOOL sendingMessage; 574 | @property (assign, nonatomic) BOOL shouldShowSendButton; 575 | @property (assign, nonatomic) BOOL shouldShowSubject; 576 | @property (assign, nonatomic) BOOL shouldShowPhotoButton; 577 | @property (assign, nonatomic) BOOL shouldShowCharacterCount; 578 | @property (retain, nonatomic) CKMessageEntryContentView *contentView; 579 | @property (retain, nonatomic) UIButton *sendButton; 580 | @property (retain, nonatomic) UIButton *photoButton; 581 | - (instancetype)initWithFrame:(CGRect)frame marginInsets:(UIEdgeInsets)marginInsets shouldShowSendButton:(BOOL)shouldShowSendButton shouldShowSubject:(BOOL)shouldShowSubject shouldShowPhotoButton:(BOOL)shouldShowPhotoButton shouldShowCharacterCount:(BOOL)shouldShowCharacterCount; // iOS 9 582 | - (instancetype)initWithFrame:(CGRect)frame shouldShowSendButton:(BOOL)sendButton shouldShowSubject:(BOOL)subject shouldShowPhotoButton:(BOOL)photoButton shouldShowCharacterCount:(BOOL)characterCount; // iOS 8 583 | - (void)updateEntryView; 584 | @end 585 | 586 | @protocol CKMessageEntryViewDelegate 587 | @required 588 | - (void)messageEntryViewDidChange:(CKMessageEntryView *)entryView; 589 | - (BOOL)messageEntryViewShouldBeginEditing:(CKMessageEntryView *)entryView; 590 | - (void)messageEntryViewDidBeginEditing:(CKMessageEntryView *)entryView; 591 | - (void)messageEntryViewDidEndEditing:(CKMessageEntryView *)entryView; 592 | - (void)messageEntryViewRecordingDidChange:(CKMessageEntryView *)entryView; 593 | - (BOOL)messageEntryView:(CKMessageEntryView *)entryView shouldInsertMediaObjects:(NSArray *)mediaObjects; 594 | - (void)messageEntryViewSendButtonHit:(CKMessageEntryView *)entryView; 595 | - (void)messageEntryViewSendButtonHitWhileDisabled:(CKMessageEntryView *)entryView; 596 | - (void)messageEntryViewRaiseGestureAutoSend:(CKMessageEntryView *)entryView; 597 | @optional 598 | - (BOOL)getContainerWidth:(double*)arg1 offset:(double*)arg2; 599 | @end 600 | 601 | @interface CKManualUpdater : NSObject 602 | - (void)setNeedsUpdate; 603 | - (void)updateIfNeeded; 604 | @end 605 | 606 | @interface CKScheduledUpdater : CKManualUpdater 607 | @end 608 | 609 | @interface CKPhotoPickerCollectionView : UICollectionView 610 | @end 611 | 612 | @interface CKPhotoPickerSheetViewController : UIViewController { // iOS 8.0+ 613 | NSArray *_assets; 614 | } 615 | @property (retain, nonatomic) CKPhotoPickerCollectionView *photosCollectionView; 616 | - (instancetype)initWithPresentationViewController:(UIViewController *)viewController; 617 | @end 618 | 619 | @interface CKPhotoPickerItemForSending : NSObject 620 | @property (retain, nonatomic, readonly) NSURL *assetURL; 621 | @property (retain, nonatomic, readonly) NSURL *localURL; 622 | @property (retain) UIImage *thumbnail; 623 | - (void)waitForOutstandingWork; 624 | @end 625 | 626 | @interface CKPhotoPickerCollectionViewController : CKViewController 627 | @property (retain, nonatomic) PHFetchResult *assets; 628 | @property (retain, nonatomic, readonly) NSArray *assetsToSend; 629 | @property (retain, nonatomic) UICollectionView *collectionView; 630 | @end 631 | 632 | @interface CKPhotoPickerController : UIViewController // iOS 8.3+ 633 | @property (retain, nonatomic) CKPhotoPickerCollectionViewController *photosCollectionView; 634 | @end 635 | 636 | @interface CouriaPhotosViewController : NSObject 637 | - (UIViewController *)viewController; 638 | - (UIView *)view; 639 | - (NSArray *)fetchAndClearSelectedPhotos; 640 | @end 641 | 642 | @protocol NCInteractiveNotificationHostInterface 643 | @required 644 | - (void)_dismissWithContext:(NSDictionary *)context; 645 | - (void)_requestPreferredContentHeight:(CGFloat)height; 646 | - (void)_setActionEnabled:(BOOL)enabled atIndex:(NSUInteger)index; 647 | - (void)_requestProximityMonitoringEnabled:(BOOL)enabled; 648 | @end 649 | 650 | @interface NCInteractiveNotificationHostViewController : UIViewController 651 | @end 652 | 653 | @protocol NCInteractiveNotificationServiceInterface 654 | @required 655 | - (void)_setContext:(NSDictionary *)context; 656 | - (void)_getInitialStateWithCompletion:(id)completion; 657 | - (void)_setMaximumHeight:(CGFloat)maximumHeight; 658 | - (void)_setModal:(BOOL)modal; 659 | - (void)_interactiveNotificationDidAppear; 660 | - (void)_proximityStateDidChange:(BOOL)state; 661 | - (void)_didChangeRevealPercent:(CGFloat)percent; 662 | - (void)_willPresentFromActionIdentifier:(NSString *)identifier; 663 | - (void)_getActionContextWithCompletion:(id)completion; 664 | - (void)_getActionTitlesWithCompletion:(id)completion; 665 | - (void)_handleActionAtIndex:(NSUInteger)index; 666 | - (void)_handleActionIdentifier:(NSString *)identifier; 667 | @end 668 | 669 | @interface NCInteractiveNotificationViewController : UIViewController 670 | @property (copy, nonatomic) NSDictionary *context; 671 | @property (assign, nonatomic) CGFloat maximumHeight; 672 | - (CGFloat)preferredContentHeight; 673 | - (void)requestPreferredContentHeight:(CGFloat)height; 674 | - (void)requestProximityMonitoringEnabled:(BOOL)enabled; 675 | @end 676 | 677 | @interface CPDistributedMessagingCenter : NSObject 678 | + (instancetype)centerNamed:(NSString *)name; 679 | - (void)runServerOnCurrentThread; 680 | - (void)stopServer; 681 | - (void)registerForMessageName:(NSString *)message target:(id)target selector:(SEL)selector; 682 | - (BOOL)sendNonBlockingMessageName:(NSString *)message userInfo:(NSDictionary *)userInfo; 683 | - (NSDictionary *)sendMessageAndReceiveReplyName:(NSString *)message userInfo:(NSDictionary *)userInfo error:(NSError * __autoreleasing *)errpt; 684 | @end 685 | 686 | @interface CKInlineReplyViewController : NCInteractiveNotificationViewController 687 | @property (retain, nonatomic) CKMessageEntryView *entryView; 688 | @property (retain, nonatomic) CKScheduledUpdater *typingUpdater; 689 | - (UITextView *)viewForTyping; 690 | - (void)setupConversation; 691 | - (void)setupView; 692 | - (void)interactiveNotificationDidAppear; 693 | - (void)updateSendButton; // iOS 8 694 | - (void)updateTyping; 695 | - (void)sendMessage; 696 | @end 697 | 698 | @interface CouriaInlineReplyViewController : CKInlineReplyViewController 699 | @property (retain, nonatomic, readonly) CPDistributedMessagingCenter *messagingCenter; 700 | @property (retain, nonatomic) CouriaConversationViewController *conversationViewController; 701 | @property (retain, nonatomic) CouriaContactsViewController *contactsViewController; 702 | @property (retain, nonatomic) CouriaPhotosViewController *photosViewController; 703 | - (void)photoButtonTapped:(UIButton *)button; 704 | @end 705 | 706 | @interface CouriaInlineReplyViewController_MobileSMSApp : CouriaInlineReplyViewController 707 | @end 708 | 709 | @interface CouriaInlineReplyViewController_ThirdPartyApp : CouriaInlineReplyViewController 710 | @end 711 | 712 | @interface CKUIBehavior : NSObject 713 | + (instancetype)sharedBehaviors; 714 | - (UIEdgeInsets)transcriptMarginInsets; // iOS 8 715 | - (UIEdgeInsets)balloonTranscriptInsets; 716 | - (CGFloat)balloonMaxWidthForTranscriptWidth:(CGFloat)transcriptWidth marginInsets:(UIEdgeInsets)marginInsets shouldShowPhotoButton:(BOOL)shouldShowPhotoButton shouldShowCharacterCount:(BOOL)shouldShowCharacterCount; // iOS 9 717 | - (CGFloat)leftBalloonMaxWidthForTranscriptWidth:(CGFloat)transcriptWidth marginInsets:(UIEdgeInsets)marginInsets; // iOS 8 718 | - (CGFloat)rightBalloonMaxWidthForEntryContentViewWidth:(CGFloat)entryContentViewWidth; // iOS 8 719 | - (CGFloat)conversationListContactImageDiameter; 720 | - (CGFloat)transcriptContactImageDiameter; 721 | - (CGFloat)transcriptDrawerContactImageDiameter; 722 | - (UIColor *)transcriptBackgroundColor; 723 | - (BOOL)shouldShowPhotoButton; 724 | - (BOOL)shouldShowCharacterCount; 725 | - (BOOL)shouldShowContactPhotosInTranscript; 726 | - (BOOL)transcriptCanUseOpaqueMask; 727 | - (CGFloat)photoPickerMaxPhotoHeight; 728 | - (BOOL)photoPickerShouldZoomOnSelection; 729 | - (NSArray *)balloonColorsForColorType:(CKBalloonColor)colorType; 730 | - (UIColor *)unfilledBalloonColorForColorType:(CKBalloonColor)colorType; 731 | - (UIColor *)balloonTextColorForColorType:(CKBalloonColor)colorType; 732 | - (UIColor *)balloonTextLinkColorForColorType:(CKBalloonColor)colorType; 733 | - (UIColor *)balloonOverlayColorForColorType:(CKBalloonColor)colorType; 734 | - (UIColor *)chevronImageForColorType:(CKBalloonColor)colorType; 735 | - (UIColor *)waveformColorForColorType:(CKBalloonColor)colorType; 736 | - (UIColor *)progressViewColorForColorType:(CKBalloonColor)colorType; 737 | - (UIColor *)recipientTextColorForColorType:(CKBalloonColor)colorType; 738 | - (UIColor *)sendButtonColorForColorType:(CKBalloonColor)colorType; 739 | @end 740 | 741 | @interface CKUIBehavior (Couria) 742 | - (CKBalloonColor)colorTypeForColor:(UIColor *)color; 743 | @end 744 | 745 | @interface CKUIBehaviorPhone : CKUIBehavior 746 | @end 747 | 748 | @interface CKUIBehaviorPad : CKUIBehavior 749 | @end 750 | 751 | @interface CKUIBehaviorHUDPhone : CKUIBehavior 752 | @end 753 | 754 | @interface CKUIBehaviorHUDPad : CKUIBehavior 755 | @end 756 | 757 | @interface CNAvatarView : UIControl 758 | @property (nonatomic, retain) NSArray *contacts; 759 | @property (nonatomic, readonly) UIImage *contentImage; 760 | + (id)descriptorForRequiredKeys; 761 | - (void)_updateAvatarView; 762 | @end 763 | 764 | @interface CKAvatarView : CNAvatarView 765 | @end 766 | 767 | extern BOOL PUTIsPersistentURL(NSURL *url); 768 | extern NSString *PUTCreatePathForPersistentURL(NSURL *url); 769 | 770 | typedef NS_ENUM(UInt32, SPSearchDomain) { 771 | SPSearchDomainTopHits = 0x00, 772 | SPSearchDomainOther = 0x01, 773 | SPSearchDomainPerson = 0x02, 774 | SPSearchDomainMessage = 0x03, 775 | SPSearchDomainApplication = 0x04, 776 | SPSearchDomainNote = 0x05, 777 | SPSearchDomainMusic = 0x06, 778 | SPSearchDomainPodcast = 0x07, 779 | SPSearchDomainVideo = 0x08, 780 | SPSearchDomainAudiobook = 0x09, 781 | SPSearchDomainEvent = 0x0a, 782 | SPSearchDomainBookmark = 0x0b, 783 | SPSearchDomainVoiceMemo = 0x0c, 784 | SPSearchDomainReminder = 0x0d, 785 | SPSearchDomainDocument = 0x0e, 786 | SPSearchDomainCloudDocument = 0x0f, 787 | SPSearchDomainParsec = 0x10, 788 | SPSearchDomainWebSearch = 0x11, 789 | SPSearchDomainSafari = 0x12, 790 | SPSearchDomainSettings = 0x13, 791 | SPSearchDomainPseudoContact = 0x14, 792 | SPSearchDomainMapCategory = 0x15, 793 | SPSearchDomainZKWs = 0x16, 794 | SPSearchDomainCoreSpotlight = 0x17, 795 | SPSearchDomainCalculation = 0x18, 796 | SPSearchDomainConversion = 0x19, 797 | SPSearchDomainMobileSMS = 0x1a 798 | }; 799 | 800 | @interface SPSearchResult : NSObject 801 | @property (nonatomic) NSUInteger identifier; 802 | @property (nonatomic) unsigned int searchResultDomain; // iOS 9 803 | @property (retain, nonatomic) NSString *externalIdentifier; // iOS 9 804 | @property (retain, nonatomic) NSString *title; 805 | @end 806 | 807 | @interface SPSearchResultSection : NSObject 808 | @property (nonatomic) NSUInteger domain; 809 | @property (retain, nonatomic) NSString *displayIdentifier; 810 | @property (retain, nonatomic) NSMutableArray *results; 811 | - (SPSearchResult *)resultsAtIndex:(NSUInteger)index; 812 | @end 813 | 814 | @class SPSearchAgent; 815 | 816 | @protocol SPSearchAgentDelegate 817 | @optional 818 | - (void)searchAgentUpdatedResults:(SPSearchAgent *)agent; 819 | - (void)searchAgentClearedResults:(SPSearchAgent *)agent; 820 | @end 821 | 822 | @interface SPSearchAgent : NSObject 823 | @property (retain, nonatomic) NSArray *searchDomains; 824 | @property (assign, nonatomic, readonly) BOOL queryComplete; 825 | @property (retain, nonatomic) dispatch_queue_t queryProcessor; 826 | @property (assign, nonatomic) id delegate; 827 | @property (retain, readonly) NSArray *sections; 828 | - (SPSearchResultSection *)sectionAtIndex:(NSUInteger)index; 829 | - (BOOL)hasResults; // iOS 9 830 | - (NSUInteger)sectionCount; // iOS 9 831 | - (NSUInteger)resultCount; // iOS 8 832 | - (NSString *)queryString; 833 | - (BOOL)setQueryString:(NSString *)queryString withResponse:(NSDictionary *)response keyboardLanguage:(NSString *)keyboardLanguage keyboardPrimaryLanguage:(NSString *)keyboardPrimaryLanguage isStable:(BOOL)isStable levelZKW:(int)levelZKW allowInternet:(BOOL)allowInternet; // iOS 9 834 | - (BOOL)setQueryString:(NSString *)queryString keyboardLanguage:(NSString *)keyboardLanguage keyboardPrimaryLanguage:(NSString *)keyboardPrimaryLanguage levelZKW:(int)levelZKW allowInternet:(BOOL)allowInternet; 835 | - (BOOL)setQueryString:(NSString *)queryString keyboardLanguage:(NSString *)keyboardLanguage withResponse:(NSDictionary *)response isStable:(BOOL)isStable; 836 | - (BOOL)setQueryString:(NSString *)queryString; // iOS 8 837 | @end 838 | 839 | @interface CouriaSearchAgent : SPSearchAgent 840 | @property (copy) void (^ updateHandler)(void); 841 | - (void)setQueryString:(NSString *)queryString inputMode:(UITextInputMode *)inputMode; 842 | - (BOOL)hasResults; 843 | - (NSArray *)contactsResults; 844 | @end 845 | 846 | @interface CouriaAddressBook : NSObject 847 | - (BOOL)accessGranted; 848 | - (void)requestAccess; 849 | - (NSArray *)processSearchResults:(NSArray *)searchResults withBlock:(id (^)(NSString *identifier, NSString *nickname, UIImage *avatar))block; 850 | - (UIImage *)avatarImageForContacts:(NSArray *)contacts; 851 | @end 852 | 853 | @interface SBApplication : NSObject 854 | - (NSString *)displayName; 855 | @end 856 | 857 | @interface SBApplicationController : NSObject 858 | + (instancetype)sharedInstance; 859 | - (SBApplication *)applicationWithBundleIdentifier:(NSString *)identifier; 860 | @end 861 | 862 | @interface SBIcon : NSObject 863 | - (UIImage *)getIconImage:(int)format; 864 | @end 865 | 866 | @interface SBLeafIcon : SBIcon 867 | @end 868 | 869 | @interface SBApplicationIcon : SBLeafIcon 870 | @end 871 | 872 | @interface SBIconModel : NSObject 873 | - (SBApplicationIcon *)applicationIconForBundleIdentifier:(NSString *)identifier; 874 | @end 875 | 876 | @interface SBReusableViewMap : NSObject 877 | @end 878 | 879 | @interface SBIconViewMap : SBReusableViewMap 880 | @property (retain, nonatomic, readonly) SBIconModel *iconModel; 881 | + (SBIconViewMap *)homescreenMap; 882 | @end 883 | 884 | @interface SBIconController : NSObject 885 | + (instancetype)sharedInstance; 886 | - (SBIconViewMap *)homescreenIconViewMap; 887 | @end 888 | 889 | @interface SBUIBannerItem : NSObject 890 | @end 891 | 892 | @interface SBBulletinBannerItem : SBUIBannerItem 893 | - (BBBulletin *)seedBulletin; 894 | @end 895 | 896 | @interface SBUIBannerContext : NSObject 897 | @property (retain, nonatomic, readonly) SBBulletinBannerItem *item; 898 | @end 899 | 900 | @interface SBDefaultBannerTextView : UIView 901 | @property (copy, nonatomic) NSString *primaryText; 902 | @property (copy, nonatomic) NSString *secondaryText; 903 | @property (nonatomic, readonly) UILabel *relevanceDateLabel; 904 | - (void)setRelevanceDate:(NSDate *)relevanceDate; 905 | @end 906 | 907 | @interface SBDefaultBannerView : UIView { 908 | SBDefaultBannerTextView *_textView; 909 | } 910 | @end 911 | 912 | @interface SBBannerContextView : UIView { 913 | SBDefaultBannerView *_contentView; 914 | } 915 | @end 916 | 917 | @interface SBBannerController : NSObject { 918 | NSInteger _activeGestureType; 919 | } 920 | + (instancetype)sharedInstance; 921 | - (SBUIBannerContext *)_bannerContext; 922 | - (SBBannerContextView *)_bannerView; 923 | - (void)dismissBannerWithAnimation:(BOOL)animated reason:(NSInteger)reason; 924 | - (void)_handleGestureState:(NSInteger)state location:(CGPoint)location displacement:(CGFloat)displacement velocity:(CGFloat)velocity; 925 | - (BOOL)isShowingModalBanner; 926 | @end 927 | 928 | @interface SBBulletinBannerController : NSObject 929 | + (instancetype)sharedInstance; 930 | - (void)modallyPresentBannerForBulletin:(BBBulletin *)bulletin action:(BBAction *)action; 931 | @end 932 | 933 | extern NSDictionary *CouriaExtensions(void); 934 | extern NSUserDefaults *CouriaPreferences(void); 935 | extern id CouriaExtension(NSString *application); 936 | extern BOOL CouriaEnabled(NSString *application); 937 | extern NSString *CouriaApplicationName(NSString *applicationIdentifier); 938 | extern UIImage *CouriaApplicationIcon(NSString *applicationIdentifier, BOOL small); 939 | extern void CouriaUpdateBulletinRequest(BBBulletinRequest *bulletinRequest); 940 | extern void CouriaPresentViewController(NSString *application, NSString *user); 941 | extern void CouriaDismissViewController(void); 942 | 943 | extern void CouriaNotificationsInit(void); 944 | extern void CouriaGesturesInit(void); 945 | extern void CouriaUIViewServiceInit(void); 946 | extern void CouriaUIPhotosViewInit(void); 947 | extern void CouriaUIMobileSMSAppInit(void); 948 | extern void CouriaUIThirdPartyAppInit(void); 949 | 950 | CHInline void CouriaRegisterDefaults(NSUserDefaults *preferences, NSString *applicationIdentifier) { 951 | [preferences registerDefaults:@{ 952 | [applicationIdentifier stringByAppendingString:EnabledSetting]: @(YES), 953 | [applicationIdentifier stringByAppendingString:AuthenticationRequiredSetting]: @(NO), 954 | [applicationIdentifier stringByAppendingString:DismissOnSendSetting]: @(YES), 955 | [applicationIdentifier stringByAppendingString:BubbleThemeSetting]: @(CouriaBubbleThemeOutline) 956 | }]; 957 | } 958 | 959 | CHInline NSBundle *CouriaResourcesBundle(void) { 960 | return [NSBundle bundleWithPath:@"/Library/PreferenceBundles/CouriaPreferences.bundle"]; 961 | } 962 | 963 | CHInline UIImage *CouriaImage(NSString *name) { 964 | return [UIImage imageNamed:name inBundle:CouriaResourcesBundle() compatibleWithTraitCollection:nil]; 965 | } 966 | 967 | CHInline NSString *CouriaLocalizedString(NSString *key) { 968 | return [CouriaResourcesBundle() localizedStringForKey:key value:nil table:nil]; 969 | } 970 | 971 | CHInline UIColor *CouriaColor(NSString *colorString) { 972 | CGFloat red = 0, green = 0, blue = 0, alpha = 0; 973 | if (colorString.length == 6) { 974 | colorString = [colorString stringByAppendingString:@"ff"]; 975 | } 976 | if (colorString.length == 8) { 977 | unsigned int colorValue; 978 | [[NSScanner scannerWithString:colorString]scanHexInt:&colorValue]; 979 | red = ((colorValue >> 24) & 0xff) / 255.f; 980 | green = ((colorValue >> 16) & 0xff) / 255.f; 981 | blue = ((colorValue >> 8) & 0xff) / 255.f; 982 | alpha = ((colorValue >> 0) & 0xff) / 255.f; 983 | } 984 | return [UIColor colorWithRed:red green:green blue:blue alpha:alpha]; 985 | } 986 | 987 | CHInline NSString *CouriaColorString(UIColor *color) { 988 | CGFloat red = 0, green = 0, blue = 0, alpha = 0; 989 | [color getRed:&red green:&green blue:&blue alpha:&alpha]; 990 | return [NSString stringWithFormat:@"%02x%02x%02x%02x", (unsigned int)(red * 255), (unsigned int)(green * 255), (unsigned int)(blue * 255), (unsigned int)(alpha * 255)]; 991 | } 992 | 993 | @interface CouriaMessage : NSObject 994 | @property (copy) id content; 995 | @property (assign) BOOL outgoing; 996 | @property (copy) NSDate *timestamp; 997 | @end 998 | 999 | @interface CouriaService : NSObject 1000 | + (instancetype)sharedInstance; 1001 | - (void)run; 1002 | @end 1003 | 1004 | @interface CouriaExtras : NSObject 1005 | + (instancetype)sharedInstance; 1006 | - (void)registerExtrasForApplication:(NSString *)applicationIdentifier; 1007 | - (void)unregisterExtrasForApplication:(NSString *)applicationIdentifier; 1008 | @end 1009 | 1010 | typedef enum PSCellType { 1011 | PSGroupCell, 1012 | PSLinkCell, 1013 | PSLinkListCell, 1014 | PSListItemCell, 1015 | PSTitleValueCell, 1016 | PSSliderCell, 1017 | PSSwitchCell, 1018 | PSStaticTextCell, 1019 | PSEditTextCell, 1020 | PSSegmentCell, 1021 | PSGiantIconCell, 1022 | PSGiantCell, 1023 | PSSecureEditTextCell, 1024 | PSButtonCell, 1025 | PSEditTextViewCell, 1026 | } PSCellType; 1027 | 1028 | @interface PSSpecifier : NSObject { 1029 | @public 1030 | id target; 1031 | SEL getter; 1032 | SEL setter; 1033 | SEL action; 1034 | Class detailControllerClass; 1035 | PSCellType cellType; 1036 | Class editPaneClass; 1037 | UIKeyboardType keyboardType; 1038 | UITextAutocapitalizationType autoCapsType; 1039 | UITextAutocorrectionType autoCorrectionType; 1040 | int textFieldType; 1041 | @private 1042 | NSString *_name; 1043 | NSArray *_values; 1044 | NSDictionary *_titleDict; 1045 | NSDictionary *_shortTitleDict; 1046 | id _userInfo; 1047 | NSMutableDictionary *_properties; 1048 | } 1049 | @property (retain) NSMutableDictionary *properties; 1050 | @property (retain) NSString *identifier; 1051 | @property (retain) NSString *name; 1052 | @property (retain) id userInfo; 1053 | @property (retain) id titleDictionary; 1054 | @property (retain) id shortTitleDictionary; 1055 | @property (retain) NSArray *values; 1056 | + (id)preferenceSpecifierNamed:(NSString *)title target:(id)target set:(SEL)set get:(SEL)get detail:(Class)detail cell:(PSCellType)cell edit:(Class)edit; 1057 | + (PSSpecifier *)groupSpecifierWithName:(NSString *)title; 1058 | + (PSSpecifier *)emptyGroupSpecifier; 1059 | + (UITextAutocapitalizationType)autoCapsTypeForString:(PSSpecifier *)string; 1060 | + (UITextAutocorrectionType)keyboardTypeForString:(PSSpecifier *)string; 1061 | - (id)propertyForKey:(NSString *)key; 1062 | - (void)setProperty:(id)property forKey:(NSString *)key; 1063 | - (void)removePropertyForKey:(NSString *)key; 1064 | - (void)loadValuesAndTitlesFromDataSource; 1065 | - (void)setValues:(NSArray *)values titles:(NSArray *)titles; 1066 | - (void)setValues:(NSArray *)values titles:(NSArray *)titles shortTitles:(NSArray *)shortTitles; 1067 | - (void)setupIconImageWithPath:(NSString *)path; 1068 | - (NSString *)identifier; 1069 | - (void)setTarget:(id)target; 1070 | - (void)setKeyboardType:(UIKeyboardType)type autoCaps:(UITextAutocapitalizationType)autoCaps autoCorrection:(UITextAutocorrectionType)autoCorrection; 1071 | @end 1072 | 1073 | @interface PSViewController : UIViewController { 1074 | PSSpecifier *_specifier; 1075 | } 1076 | @property (retain) PSSpecifier *specifier; 1077 | - (id)readPreferenceValue:(PSSpecifier *)specifier; 1078 | - (void)setPreferenceValue:(id)value specifier:(PSSpecifier *)specifier; 1079 | @end 1080 | 1081 | @interface PSListController : PSViewController { 1082 | NSArray *_specifiers; 1083 | } 1084 | @property (retain, nonatomic) NSArray *specifiers; 1085 | - (NSArray *)loadSpecifiersFromPlistName:(NSString *)plistName target:(id)target; 1086 | - (PSSpecifier *)specifierForID:(NSString *)identifier; 1087 | - (PSSpecifier *)specifierAtIndex:(NSInteger)index; 1088 | - (NSArray *)specifiersForIDs:(NSArray *)identifiers; 1089 | - (NSArray *)specifiersInGroup:(NSInteger)group; 1090 | - (BOOL)containsSpecifier:(PSSpecifier *)specifier; 1091 | - (NSInteger)numberOfGroups; 1092 | - (NSInteger)rowsForGroup:(NSInteger)group; 1093 | - (NSInteger)indexForRow:(NSInteger)row inGroup:(NSInteger)group; 1094 | - (BOOL)getGroup:(NSInteger *)group row:(NSInteger *)row ofSpecifier:(PSSpecifier *)specifier; 1095 | - (BOOL)getGroup:(NSInteger *)group row:(NSInteger *)row ofSpecifierID:(NSString *)identifier; 1096 | - (BOOL)getGroup:(NSInteger *)group row:(NSInteger *)row ofSpecifierAtIndex:(NSInteger )index; 1097 | - (void)addSpecifier:(PSSpecifier *)specifier; 1098 | - (void)addSpecifiersFromArray:(NSArray *)array; 1099 | - (void)addSpecifier:(PSSpecifier *)specifier animated:(BOOL)animated; 1100 | - (void)addSpecifiersFromArray:(NSArray *)array animated:(BOOL)animated; 1101 | - (void)insertSpecifier:(PSSpecifier *)specifier afterSpecifier:(PSSpecifier *)afterSpecifier; 1102 | - (void)insertSpecifier:(PSSpecifier *)specifier afterSpecifierID:(NSString *)afterSpecifierID; 1103 | - (void)insertSpecifier:(PSSpecifier *)specifier atIndex:(NSInteger)index; 1104 | - (void)insertSpecifier:(PSSpecifier *)specifier atEndOfGroup:(NSInteger)index; 1105 | - (void)insertContiguousSpecifiers:(NSArray *)spcifiers afterSpecifier:(PSSpecifier *)afterSpecifier; 1106 | - (void)insertContiguousSpecifiers:(NSArray *)spcifiers afterSpecifierID:(NSString *)afterSpecifierID; 1107 | - (void)insertContiguousSpecifiers:(NSArray *)spcifiers atIndex:(NSInteger)index; 1108 | - (void)insertContiguousSpecifiers:(NSArray *)spcifiers atEndOfGroup:(NSInteger)index; 1109 | - (void)insertSpecifier:(PSSpecifier *)specifier afterSpecifier:(PSSpecifier *)afterSpecifier animated:(BOOL)animated; 1110 | - (void)insertSpecifier:(PSSpecifier *)specifier afterSpecifierID:(NSString *)afterSpecifierID animated:(BOOL)animated; 1111 | - (void)insertSpecifier:(PSSpecifier *)specifier atIndex:(NSInteger)index animated:(BOOL)animated; 1112 | - (void)insertSpecifier:(PSSpecifier *)specifier atEndOfGroup:(NSInteger)index animated:(BOOL)animated; 1113 | - (void)insertContiguousSpecifiers:(NSArray *)spcifiers afterSpecifier:(PSSpecifier *)afterSpecifier animated:(BOOL)animated; 1114 | - (void)insertContiguousSpecifiers:(NSArray *)spcifiers afterSpecifierID:(NSString *)afterSpecifierID animated:(BOOL)animated; 1115 | - (void)insertContiguousSpecifiers:(NSArray *)spcifiers atIndex:(NSInteger)index animated:(BOOL)animated; 1116 | - (void)insertContiguousSpecifiers:(NSArray *)spcifiers atEndOfGroup:(NSInteger)index animated:(BOOL)animated; 1117 | - (void)replaceContiguousSpecifiers:(NSArray *)oldSpecifiers withSpecifiers:(NSArray *)newSpecifiers; 1118 | - (void)replaceContiguousSpecifiers:(NSArray *)oldSpecifiers withSpecifiers:(NSArray *)newSpecifiers animated:(BOOL)animated; 1119 | - (void)removeSpecifier:(PSSpecifier *)specifier; 1120 | - (void)removeSpecifierID:(NSString *)identifier; 1121 | - (void)removeSpecifierAtIndex:(NSInteger)index; 1122 | - (void)removeLastSpecifier; 1123 | - (void)removeContiguousSpecifiers:(NSArray *)specifiers; 1124 | - (void)removeSpecifier:(PSSpecifier *)specifier animated:(BOOL)animated; 1125 | - (void)removeSpecifierID:(NSString *)identifier animated:(BOOL)animated; 1126 | - (void)removeSpecifierAtIndex:(NSInteger)index animated:(BOOL)animated; 1127 | - (void)removeLastSpecifierAnimated:(BOOL)animated; 1128 | - (void)removeContiguousSpecifiers:(NSArray *)specifiers animated:(BOOL)animated; 1129 | - (void)reloadSpecifier:(PSSpecifier *)specifier; 1130 | - (void)reloadSpecifierID:(NSString *)identifier; 1131 | - (void)reloadSpecifierAtIndex:(NSInteger)index; 1132 | - (void)reloadSpecifier:(PSSpecifier *)specifier animated:(BOOL)animated; 1133 | - (void)reloadSpecifierID:(NSString *)identifier animated:(BOOL)animated; 1134 | - (void)reloadSpecifierAtIndex:(NSInteger)index animated:(BOOL)animated; 1135 | - (void)reloadSpecifiers; 1136 | - (void)updateSpecifiers:(NSArray *)oldSpecifiers withSpecifiers:(NSArray *)newSpecifiers; 1137 | - (void)updateSpecifiersInRange:(NSRange)range withSpecifiers:(NSArray *)newSpecifiers; 1138 | @end 1139 | 1140 | @interface PSListItemsController : PSListController 1141 | @end 1142 | -------------------------------------------------------------------------------- /src/Preferences/Preferences.m: -------------------------------------------------------------------------------- 1 | #import "../Headers.h" 2 | #import "../../external/Color-Picker-for-iOS/ColorPicker/HRColorPickerView.h" 3 | #import "../../external/Color-Picker-for-iOS/ColorPicker/HRColorMapView.h" 4 | #import "../../external/Color-Picker-for-iOS/ColorPicker/HRBrightnessSlider.h" 5 | 6 | static NSUserDefaults *preferences; 7 | static CPDistributedMessagingCenter *messagingCenter; 8 | 9 | @interface CouriaPreferencesController : PSListController 10 | @property (retain, nonatomic) NSArray *extensionsSpecifiers; 11 | @property (retain, nonatomic) NSArray *aboutSpecifiers; 12 | @property (retain, nonatomic) NSArray *translationCreditsSpecifiers; 13 | @end 14 | 15 | @interface CouriaExtensionPreferencesController : PSListController 16 | @property (retain, nonatomic) NSArray *mainSettingsSpecifiers; 17 | @property (retain, nonatomic) NSArray *themeSettingsSpecifiers; 18 | @end 19 | 20 | @interface CouriaColorPickerViewController : UIViewController 21 | @property (retain, nonatomic) HRColorPickerView *colorPickerView; 22 | @property (copy) void (^ resultCallback)(UIColor *color); 23 | - (void)showInViewController:(UIViewController *)viewController title:(NSString *)title initialColor:(UIColor *)color resultCallback:(void (^)(UIColor *))callback; 24 | @end 25 | 26 | @implementation CouriaPreferencesController 27 | 28 | - (NSArray *)extensionsSpecifiers { 29 | if (_extensionsSpecifiers == nil) { 30 | NSMutableArray *specifiers = [NSMutableArray array]; 31 | NSArray *extensions = [NSKeyedUnarchiver unarchiveObjectWithData:[messagingCenter sendMessageAndReceiveReplyName:ListExtensionsMessage userInfo:nil error:NULL][ExtensionsKey]]; 32 | if (extensions.count > 0) { 33 | [extensions enumerateObjectsUsingBlock:^(NSDictionary *extension, NSUInteger index, BOOL *stop) { 34 | CouriaRegisterDefaults(preferences, extension[IdentifierKey]); 35 | [specifiers addObject:({ 36 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:extension[NameKey] target:self set:NULL get:NULL detail:CouriaExtensionPreferencesController.class cell:PSLinkCell edit:Nil]; 37 | [specifier setIdentifier:extension[IdentifierKey]]; 38 | [specifier setProperty:extension[IconKey] forKey:@"iconImage"]; 39 | specifier; 40 | })]; 41 | }]; 42 | } else { 43 | [specifiers addObject:[PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"NO_INSTALLED_ITEMS") target:self set:NULL get:NULL detail:Nil cell:PSStaticTextCell edit:Nil]]; 44 | } 45 | _extensionsSpecifiers = specifiers; 46 | } 47 | return _extensionsSpecifiers; 48 | } 49 | 50 | - (NSArray *)aboutSpecifiers { 51 | if (_aboutSpecifiers == nil) { 52 | _aboutSpecifiers = @[({ 53 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:@"@QusicS" target:self set:NULL get:NULL detail:Nil cell:PSButtonCell edit:Nil]; 54 | [specifier setIdentifier:@"twitter"]; 55 | [specifier setProperty:CouriaImage(@"Twitter") forKey:@"iconImage"]; 56 | specifier->action = @selector(actionForSpecifier:); 57 | specifier; 58 | }), ({ 59 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:@"Couria" target:self set:NULL get:NULL detail:Nil cell:PSButtonCell edit:Nil]; 60 | [specifier setIdentifier:@"github"]; 61 | [specifier setProperty:CouriaImage(@"Github") forKey:@"iconImage"]; 62 | specifier->action = @selector(actionForSpecifier:); 63 | specifier; 64 | }), ({ 65 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"DONATE") target:self set:NULL get:NULL detail:Nil cell:PSButtonCell edit:Nil]; 66 | [specifier setIdentifier:@"donate"]; 67 | [specifier setProperty:CouriaImage(@"PayPal") forKey:@"iconImage"]; 68 | specifier->action = @selector(actionForSpecifier:); 69 | specifier; 70 | }), ({ 71 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"TRANSLATION_CREDITS") target:self set:NULL get:NULL detail:Nil cell:PSButtonCell edit:Nil]; 72 | [specifier setIdentifier:@"translationCredits"]; 73 | [specifier setProperty:CouriaImage(@"Languages") forKey:@"iconImage"]; 74 | specifier->action = @selector(actionForSpecifier:); 75 | specifier; 76 | })]; 77 | } 78 | return _aboutSpecifiers; 79 | } 80 | 81 | - (NSArray *)translationCreditsSpecifiers { 82 | if (_translationCreditsSpecifiers == nil) { 83 | NSMutableArray *specifiers = [NSMutableArray array]; 84 | [[self.translationCreditsData.allKeys sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]enumerateObjectsUsingBlock:^(NSString *language, NSUInteger index, BOOL *stop) { 85 | [specifiers addObject:({ 86 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:language target:self set:NULL get:@selector(getValueForTranslationCreditsSpecifier:) detail:Nil cell:PSTitleValueCell edit:Nil]; 87 | [specifier setIdentifier:language]; 88 | specifier; 89 | })]; 90 | }]; 91 | _translationCreditsSpecifiers = specifiers; 92 | } 93 | return _translationCreditsSpecifiers; 94 | } 95 | 96 | - (NSArray *)specifiers { 97 | if (_specifiers == nil) { 98 | NSMutableArray *specifiers = [NSMutableArray array]; 99 | [specifiers addObject:[PSSpecifier groupSpecifierWithName:CouriaLocalizedString(@"EXTENSIONS")]]; 100 | [specifiers addObjectsFromArray:self.extensionsSpecifiers]; 101 | [specifiers addObject:({ 102 | PSSpecifier *specifier = [PSSpecifier groupSpecifierWithName:CouriaLocalizedString(@"ABOUT")]; 103 | [specifier setProperty:@"Couria © Qusic" forKey:@"footerText"]; 104 | specifier; 105 | })]; 106 | [specifiers addObjectsFromArray:self.aboutSpecifiers]; 107 | _specifiers = specifiers; 108 | } 109 | return _specifiers; 110 | } 111 | 112 | - (NSDictionary *)translationCreditsData { 113 | return @{@"Dansk": @"Felix E. Drud", 114 | @"Deutsch": @"Tim Klute", 115 | @"Español": @"MXNMike", 116 | @"Français": @"Léo", 117 | @"Italiano": @"Bruno Di Marco", 118 | @"Nederlands": @"Alphyraz", 119 | @"Русский": @"Victor Ryabov", 120 | @"Svenska": @"Mattias W", 121 | @"Türkçe": @"aybo101 AppleTurk", 122 | @"繁體中文": @"Hiraku", 123 | @"日本語": @"wakinchan", 124 | @"한국어": @"Jeong Woo Yoon", 125 | @"العربية": @"Mohamed El Fawal"}; 126 | } 127 | 128 | - (id)getValueForTranslationCreditsSpecifier:(PSSpecifier *)specifier { 129 | return self.translationCreditsData[specifier.identifier]; 130 | } 131 | 132 | - (void)viewDidLoad { 133 | [super viewDidLoad]; 134 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"😘" style:UIBarButtonItemStylePlain target:self action:@selector(shareAction:)]; 135 | } 136 | 137 | - (void)actionForSpecifier:(PSSpecifier *)specifier { 138 | NSString *identifier = specifier.identifier; 139 | if ([identifier isEqualToString:@"twitter"]) { 140 | [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"https://twitter.com/QusicS"]]; 141 | } else if ([identifier isEqualToString:@"github"]) { 142 | [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"https://github.com/Qusic/Couria"]]; 143 | } else if ([identifier isEqualToString:@"donate"]) { 144 | [[UIApplication sharedApplication]openURL:[NSURL URLWithString:@"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=PJ93RW7TLKZZ4"]]; 145 | } else if ([identifier isEqualToString:@"translationCredits"]) { 146 | if (![self containsSpecifier:self.translationCreditsSpecifiers.firstObject]) { 147 | [self insertContiguousSpecifiers:self.translationCreditsSpecifiers afterSpecifierID:@"translationCredits" animated:YES]; 148 | } else { 149 | for (PSSpecifier *specifier in self.translationCreditsSpecifiers) { 150 | [self removeSpecifier:specifier animated:YES]; 151 | } 152 | } 153 | } 154 | } 155 | 156 | - (void)shareAction:(UIBarButtonItem *)buttonItem { 157 | NSString *serviceType = nil; 158 | if ([[NSLocale preferredLanguages][0]isEqualToString:@"zh-Hans"]) { 159 | serviceType = SLServiceTypeSinaWeibo; 160 | } else { 161 | serviceType = SLServiceTypeTwitter; 162 | } 163 | SLComposeViewController *composeSheet = [SLComposeViewController composeViewControllerForServiceType:serviceType]; 164 | [composeSheet setInitialText:CouriaLocalizedString(@"SHARE_TEXT")]; 165 | [self presentViewController:composeSheet animated:YES completion:nil]; 166 | } 167 | 168 | @end 169 | 170 | @implementation CouriaExtensionPreferencesController 171 | 172 | - (NSArray *)mainSettingsSpecifiers { 173 | if (_mainSettingsSpecifiers == nil) { 174 | _mainSettingsSpecifiers = @[[PSSpecifier emptyGroupSpecifier], ({ 175 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"ENABLED") target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:Nil cell:PSSwitchCell edit:Nil]; 176 | [specifier setIdentifier:[self.specifier.identifier stringByAppendingString:EnabledSetting]]; 177 | specifier; 178 | }), [PSSpecifier emptyGroupSpecifier], ({ 179 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"AUTHENTICATION_REQUIRED") target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:Nil cell:PSSwitchCell edit:Nil]; 180 | [specifier setIdentifier:[self.specifier.identifier stringByAppendingString:AuthenticationRequiredSetting]]; 181 | specifier; 182 | }), ({ 183 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"DISMISS_ON_SEND") target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:Nil cell:PSSwitchCell edit:Nil]; 184 | [specifier setIdentifier:[self.specifier.identifier stringByAppendingString:DismissOnSendSetting]]; 185 | specifier; 186 | })]; 187 | } 188 | return _mainSettingsSpecifiers; 189 | } 190 | 191 | - (NSArray *)themeSettingsSpecifiers { 192 | if (_themeSettingsSpecifiers == nil) { 193 | _themeSettingsSpecifiers = @[[PSSpecifier groupSpecifierWithName:CouriaLocalizedString(@"BUBBLE_THEME")], ({ 194 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"BUBBLE_THEME") target:self set:@selector(setPreferenceValue:specifier:) get:@selector(readPreferenceValue:) detail:Nil cell:PSSegmentCell edit:Nil]; 195 | [specifier setIdentifier:[self.specifier.identifier stringByAppendingString:BubbleThemeSetting]]; 196 | [specifier setValues:@[@(CouriaBubbleThemeOriginal), @(CouriaBubbleThemeOutline), @(CouriaBubbleThemeCustom)] titles:@[CouriaLocalizedString(@"BUBBLE_THEME_ORIGINAL"), CouriaLocalizedString(@"BUBBLE_THEME_OUTLINE"), CouriaLocalizedString(@"BUBBLE_THEME_CUSTOM")]]; 197 | specifier; 198 | }), ({ 199 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"MY_BUBBLE_COLOR") target:self set:NULL get:NULL detail:Nil cell:PSTitleValueCell edit:Nil]; 200 | [specifier setIdentifier:[self.specifier.identifier stringByAppendingString:CustomMyBubbleColorSetting]]; 201 | [specifier setProperty:@(YES) forKey:ColorSpecifierOption]; 202 | specifier; 203 | }), ({ 204 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"MY_BUBBLE_TEXT_COLOR") target:self set:NULL get:NULL detail:Nil cell:PSTitleValueCell edit:Nil]; 205 | [specifier setIdentifier:[self.specifier.identifier stringByAppendingString:CustomMyBubbleTextColorSetting]]; 206 | [specifier setProperty:@(YES) forKey:ColorSpecifierOption]; 207 | specifier; 208 | }), ({ 209 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"OTHERS_BUBBLE_COLOR") target:self set:NULL get:NULL detail:Nil cell:PSTitleValueCell edit:Nil]; 210 | [specifier setIdentifier:[self.specifier.identifier stringByAppendingString:CustomOthersBubbleColorSetting]]; 211 | [specifier setProperty:@(YES) forKey:ColorSpecifierOption]; 212 | specifier; 213 | }), ({ 214 | PSSpecifier *specifier = [PSSpecifier preferenceSpecifierNamed:CouriaLocalizedString(@"OTHERS_BUBBLE_TEXT_COLOR") target:self set:NULL get:NULL detail:Nil cell:PSTitleValueCell edit:Nil]; 215 | [specifier setIdentifier:[self.specifier.identifier stringByAppendingString:CustomOthersBubbleTextColorSetting]]; 216 | [specifier setProperty:@(YES) forKey:ColorSpecifierOption]; 217 | specifier; 218 | })]; 219 | } 220 | return _themeSettingsSpecifiers; 221 | } 222 | 223 | - (NSArray *)specifiers { 224 | if (_specifiers == nil) { 225 | NSMutableArray *specifiers = [NSMutableArray array]; 226 | [specifiers addObjectsFromArray:self.mainSettingsSpecifiers]; 227 | [specifiers addObjectsFromArray:self.themeSettingsSpecifiers]; 228 | _specifiers = specifiers; 229 | } 230 | return _specifiers; 231 | } 232 | 233 | - (id)readPreferenceValue:(PSSpecifier *)specifier { 234 | return [preferences objectForKey:specifier.identifier]; 235 | } 236 | 237 | - (void)setPreferenceValue:(id)value specifier:(PSSpecifier *)specifier { 238 | [preferences setObject:value forKey:specifier.identifier]; 239 | } 240 | 241 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 242 | UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath]; 243 | PSSpecifier *specifier = [self specifierAtIndex:[self indexForRow:indexPath.row inGroup:indexPath.section]]; 244 | if ([[specifier propertyForKey:ColorSpecifierOption]boolValue]) { 245 | NSString *colorString = [self readPreferenceValue:specifier]; 246 | UIColor *color = CouriaColor(colorString); 247 | cell.detailTextLabel.attributedText = [[NSAttributedString alloc]initWithString:@"████" attributes:@{NSForegroundColorAttributeName: color}]; 248 | cell.accessoryType = UITableViewCellAccessoryDetailButton; 249 | } 250 | return cell; 251 | } 252 | 253 | - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { 254 | [super tableView:tableView cellForRowAtIndexPath:indexPath]; 255 | PSSpecifier *specifier = [self specifierAtIndex:[self indexForRow:indexPath.row inGroup:indexPath.section]]; 256 | if ([[specifier propertyForKey:ColorSpecifierOption]boolValue]) { 257 | NSString *colorString = [self readPreferenceValue:specifier]; 258 | UIColor *color = CouriaColor(colorString); 259 | CouriaColorPickerViewController *colorPicker = [[CouriaColorPickerViewController alloc]init]; 260 | [colorPicker showInViewController:self title:specifier.name initialColor:color resultCallback:^(UIColor *newColor) { 261 | [self setPreferenceValue:CouriaColorString(newColor) specifier:specifier]; 262 | [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; 263 | }]; 264 | } 265 | } 266 | 267 | @end 268 | 269 | @implementation CouriaColorPickerViewController 270 | 271 | - (HRColorPickerView *)colorPickerView { 272 | if (_colorPickerView == nil) { 273 | _colorPickerView = [[HRColorPickerView alloc]init]; 274 | _colorPickerView.colorMapView.saturationUpperLimit = @(1); 275 | _colorPickerView.brightnessSlider.brightnessLowerLimit = @(0); 276 | } 277 | return _colorPickerView; 278 | } 279 | 280 | - (void)loadView { 281 | self.view = self.colorPickerView; 282 | } 283 | 284 | - (void)viewDidLoad { 285 | [super viewDidLoad]; 286 | self.navigationController.navigationBar.translucent = NO; 287 | self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelAction:)]; 288 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneAction:)]; 289 | } 290 | 291 | - (void)viewDidLayoutSubviews { 292 | [super viewDidLayoutSubviews]; 293 | } 294 | 295 | - (void)showInViewController:(UIViewController *)viewController title:(NSString *)title initialColor:(UIColor *)color resultCallback:(void (^)(UIColor *))callback { 296 | self.title = title; 297 | self.colorPickerView.color = color; 298 | self.resultCallback = callback; 299 | [viewController presentViewController:[[UINavigationController alloc]initWithRootViewController:self] animated:YES completion:NULL]; 300 | } 301 | 302 | - (void)cancelAction:(UIBarButtonItem *)buttonItem { 303 | [self.presentingViewController dismissViewControllerAnimated:YES completion:NULL]; 304 | } 305 | 306 | - (void)doneAction:(UIBarButtonItem *)buttonItem { 307 | if (self.resultCallback) { 308 | self.resultCallback(self.colorPickerView.color); 309 | } 310 | [self.presentingViewController dismissViewControllerAnimated:YES completion:NULL]; 311 | } 312 | 313 | @end 314 | 315 | CHConstructor { 316 | @autoreleasepool { 317 | preferences = [[NSUserDefaults alloc]initWithSuiteName:CouriaIdentifier]; 318 | messagingCenter = [CPDistributedMessagingCenter centerNamed:CouriaIdentifier]; 319 | } 320 | } 321 | --------------------------------------------------------------------------------