pax_global_header00006660000000000000000000000064116255141600014513gustar00rootroot0000000000000052 comment=19154a3eebb1d29d2a8e5572dd75e46fae134076 libphone-ui-0.0.1+git20110825/000077500000000000000000000000001162551416000153265ustar00rootroot00000000000000libphone-ui-0.0.1+git20110825/.gitignore000066400000000000000000000006311162551416000173160ustar00rootroot00000000000000stamp-h1 Makefile Makefile.in *.pc src/*.lo src/*.o src/*.la src/.libs src/.deps src/Makefile src/Makefile.in* src/phoneui.h configure config.* po/*.gmo po/*.po~ po/POTFILES po/*.pot po/*.sin po/*.sed po/*.header po/stamp-po po/Makefile.in* po/Makefile po/Makevars.template po/Rules-quot po/stamp-po data/*.edj autom4te.cache aclocal.m4 m4 ABOUT-NLS depcomp install-sh libtool ltmain.sh missing mkinstalldirs libphone-ui-0.0.1+git20110825/AUTHORS000066400000000000000000000004251162551416000163770ustar00rootroot00000000000000#Authors in alphabetical order author Klaus Kurzmann author Maksim 'max_posedon' Melnikau author Sebastian Krzyszkowiak author Thomas Zimmermann author Tom 'TAsn' Hacohen libphone-ui-0.0.1+git20110825/COPYING000066400000000000000000001045131162551416000163650ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . libphone-ui-0.0.1+git20110825/ChangeLog000066400000000000000000000000561162551416000171010ustar00rootroot000000000000002008-10-09 quickdev * Initial setup libphone-ui-0.0.1+git20110825/INSTALL000066400000000000000000000224501162551416000163620ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. This file is free documentation; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 6. Often, you can also type `make uninstall' to remove the installed files again. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of the options to `configure', and exit. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. libphone-ui-0.0.1+git20110825/LICENSE000066400000000000000000000636421162551416000163460ustar00rootroot00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libphone-ui-0.0.1+git20110825/Makefile.am000066400000000000000000000004661162551416000173700ustar00rootroot00000000000000SUBDIRS = src pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libphone-ui.pc ACLOCAL_AMFLAGS = -I m4 MAINTAINERCLEANFILES = \ Makefile.in Makefile aclocal.m4 config.guess \ config.h.in config.sub configure install-sh \ ltconfig ltmain.sh missing mkinstalldirs \ stamp-h.in acconfig.h stamp-h depcomp libphone-ui-0.0.1+git20110825/NEWS000066400000000000000000000000001162551416000160130ustar00rootroot00000000000000libphone-ui-0.0.1+git20110825/README000066400000000000000000000000401162551416000162000ustar00rootroot00000000000000This is the libphoneui library. libphone-ui-0.0.1+git20110825/TODO000066400000000000000000000013041162551416000160140ustar00rootroot00000000000000* add Timezone info when sending an sms. * document utility (and non utility, but mostly utility) functions * consider lodaing utilityl functions from modules as well (an opimd module and an alsa module to start with) * drop all the g_slice0 * typedef all the callback functions we provide * add phoneui_deinit * move the screens init to libphone-ui instead of the phoneui-*.c in backends and then make screen caching configurable * Should probably be in phoneuid, and I should provide an option to pass to the init function whether to hide or destroy the screen when closed Make the utils functions (and more?) thread safe as they might be used from different modules that can reside on different threads libphone-ui-0.0.1+git20110825/autogen.sh000077500000000000000000000002001162551416000173170ustar00rootroot00000000000000#! /bin/sh autoreconf -v --install || exit 1 glib-gettextize --force --copy || exit 1 ./configure --enable-maintainer-mode "$@" libphone-ui-0.0.1+git20110825/conf/000077500000000000000000000000001162551416000162535ustar00rootroot00000000000000libphone-ui-0.0.1+git20110825/conf/libphoneui.conf000066400000000000000000000036501162551416000212640ustar00rootroot00000000000000# The following sections are "view" specific settings # every view must have a "module" field that specifies the name of the # module that should be used for that view, and additional view specific # settings if supported by that view. [dialer] module = shr [messages] module = shr request_message_receipt = 0 [contacts] module = shr [calls] module = shr [phonelog] module = shr [notification] module = shr [idle_screen] module = shr [settings] module = shr #Alsa configuration for the sound utility functions # The general alsa section [alsa] hardware_control_name = hw:0 #Each section describs a sound state #each section can accept the following fields: #speaker: the name of the corrosponding alsa control #microphone: the name of the corrosponding alsa control #speaker_min: the wanted lower bound to allow setting this control to #speaker_max: the wanted upper bound to allow setting this control to #microphone_min: the wanted lower bound to allow setting this control to #microphone_max: the wanted upper bound to allow setting this control to [alsa_control_idle] #speaker = PCM Volume [alsa_control_speaker] speaker = Headphone Playback Volume microphone = Mono Playback Volume microphone_mute = Mono Mixer Sidetone Playback Switch [alsa_control_handset] speaker = Speaker Playback Volume speaker_min = 90 microphone = Mono Playback Volume microphone_mute = Mono Mixer Sidetone Playback Switch [alsa_control_headset] speaker = Headphone Playback Volume microphone = Mono Playback Volume microphone_mute = Mono Mixer Sidetone Playback Switch [alsa_control_bluetooth] speaker = Speaker Playback Volume microphone = Mono Playback Volume #Remove the segfaulting stuff #[device] # sysfs node for the vibrator to use #vibrator = /sys/class/leds/neo1973:vibrator/brightness # sysfs node to set the backlight brightness #backlight = /sys/class/backlight/gta02-bl #[feedback_error] #[feedback_warning] #[feedback_notice] #[feedback_click] libphone-ui-0.0.1+git20110825/conf/om-gta02/000077500000000000000000000000001162551416000176015ustar00rootroot00000000000000libphone-ui-0.0.1+git20110825/conf/om-gta02/libphoneui.conf000066400000000000000000000036201162551416000226070ustar00rootroot00000000000000# The following sections are "view" specific settings # every view must have a "module" field that specifies the name of the # module that should be used for that view, and additional view specific # settings if supported by that view. [dialer] module = shr [messages] module = shr request_message_receipt = 0 [contacts] module = shr [calls] module = shr [phonelog] module = shr [notification] module = shr [idle_screen] module = shr [settings] module = shr #Alsa configuration for the sound utility functions # The general alsa section [alsa] hardware_control_name = hw:0 #Each section describs a sound state #each section can accept the following fields: #speaker: the name of the corrosponding alsa control #microphone: the name of the corrosponding alsa control #speaker_min: the wanted lower bound to allow setting this control to #speaker_max: the wanted upper bound to allow setting this control to #microphone_min: the wanted lower bound to allow setting this control to #microphone_max: the wanted upper bound to allow setting this control to [alsa_control_idle] #speaker = PCM Volume [alsa_control_speaker] speaker = Headphone Playback Volume microphone = Mono Playback Volume microphone_mute = Mono Mixer Sidetone Playback Switch [alsa_control_handset] speaker = Speaker Playback Volume speaker_min = 90 microphone = Mono Playback Volume microphone_mute = Mono Mixer Sidetone Playback Switch [alsa_control_headset] speaker = Headphone Playback Volume microphone = Mono Playback Volume microphone_mute = Mono Mixer Sidetone Playback Switch [alsa_control_bluetooth] speaker = Speaker Playback Volume microphone = Mono Playback Volume [device] # sysfs node for the vibrator to use vibrator = /sys/class/leds/gta02\::vibrator/brightness # sysfs node to set the backlight brightness backlight = /sys/class/backlight/pcf50633-backlight #[feedback_error] #[feedback_warning] #[feedback_notice] #[feedback_click] libphone-ui-0.0.1+git20110825/conf/palmpre/000077500000000000000000000000001162551416000177135ustar00rootroot00000000000000libphone-ui-0.0.1+git20110825/conf/palmpre/libphoneui.conf000066400000000000000000000007211162551416000227200ustar00rootroot00000000000000# The following sections are "view" specific settings # every view must have a "module" field that specifies the name of the # module that should be used for that view, and additional view specific # settings if supported by that view. [dialer] module = shr [messages] module = shr request_message_receipt = 0 [contacts] module = shr [calls] module = shr [phonelog] module = shr [notification] module = shr [idle_screen] module = shr [settings] module = shr libphone-ui-0.0.1+git20110825/configure.ac000066400000000000000000000011561162551416000176170ustar00rootroot00000000000000AC_PREREQ(2.53) AC_INIT(libphone-ui, 0.0.1, http://www.shr-project.org/) AM_INIT_AUTOMAKE() AM_CONFIG_HEADER(config.h) AM_MAINTAINER_MODE AC_GNU_SOURCE AC_ISC_POSIX AC_PROG_CC AC_STDC_HEADERS AC_PROG_LIBTOOL PKG_CHECK_MODULES(FSO_GLIB, fso-glib-1.0) PKG_CHECK_MODULES(SHR_GLIB, shr-glib-1.0) PKG_CHECK_MODULES(FSO_FRAMEWORK, fsoframework-2.0) PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.29.3) PKG_CHECK_MODULES(LIBPHONE_UTILS, libphone-utils) PKG_CHECK_MODULES(ALSA, alsa) PKG_CHECK_MODULES(X11, x11) EXPAND(SYSCONFDIR, $sysconfdir) EXPAND(LIBDIR, $libdir) AC_OUTPUT([ Makefile src/Makefile src/phoneui.h libphone-ui.pc ]) libphone-ui-0.0.1+git20110825/libphone-ui.bb000066400000000000000000000005411162551416000200460ustar00rootroot00000000000000DESCRIPTION = "A generic framework for phone ui" HOMEPAGE = "http://shr-project.org/" LICENSE = "GPL" SECTION = "libs" PV = "0.0.0+LOCAL${GITVER}" PR = "r0" DEPENDS="glib-2.0 dbus-glib libframeworkd-glib libfso-glib libfsoframework libphone-utils alsa-lib" inherit pkgconfig autotools srctree gitver CONFFILES_${PN} = "${sysconfdir}/libphoneui.conf" libphone-ui-0.0.1+git20110825/libphone-ui.pc.in000066400000000000000000000004211162551416000204670ustar00rootroot00000000000000prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: libphone-ui Description: phoneui library Version: @VERSION@ Requires: glib-2.0 gobject-2.0 fso-glib-1.0 fsoframework-2.0 Libs: -L${libdir} -lphone-ui Cflags: -I${includedir}/phoneui libphone-ui-0.0.1+git20110825/m4/000077500000000000000000000000001162551416000156465ustar00rootroot00000000000000libphone-ui-0.0.1+git20110825/m4/expand.m4000066400000000000000000000014121162551416000173650ustar00rootroot00000000000000AC_DEFUN([EXPAND], [ EXP_VAR=[$1] FROM_VAR=[$2] dnl first expand prefix and exec_prefix if necessary prefix_save=$prefix exec_prefix_save=$exec_prefix # normally, this is done automatically first when running AC_OUTPUT, but we need them expanded now test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' full_var="$FROM_VAR" dnl loop until it doesn"t change anymore while true; do new_full_var="`eval echo $full_var`" if test "x$new_full_var" = "x$full_var"; then break; fi full_var=$new_full_var done dnl clean up full_var=$new_full_var AC_SUBST([$1], "$full_var") dnl restore prefix and exec_prefix prefix=$prefix_save exec_prefix=$exec_prefix_save ]) libphone-ui-0.0.1+git20110825/src/000077500000000000000000000000001162551416000161155ustar00rootroot00000000000000libphone-ui-0.0.1+git20110825/src/Makefile.am000066400000000000000000000026571162551416000201630ustar00rootroot00000000000000MAINTAINERCLEANFILES = Makefile.in localedir = $(datadir)/locale AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DPKGDATADIR=\"$(pkgdatadir)\" -DG_LOG_DOMAIN=\"libphone-ui\" AM_CFLAGS = -Wall -Wextra -Werror @GLIB_CFLAGS@ @SHR_GLIB_CFLAGS@ @FSO_GLIB_CFLAGS@ @FSO_FRAMEWORK_CFLAGS@ \ @LIBPHONE_UTILS_CFLAGS@ @ALSA_CFLAGS@ @X11_CFLAGS@ lib_LTLIBRARIES = libphone-ui.la libphone_ui_la_SOURCES = phoneui.c phoneui.h phoneui-utils.h phoneui-utils.c \ phoneui-utils-sound.c phoneui-utils-sound.h \ phoneui-utils-device.c phoneui-utils-device.h \ phoneui-utils-feedback.c phoneui-utils-feedback.h \ phoneui-utils-contacts.c phoneui-utils-contacts.h \ phoneui-utils-messages.c phoneui-utils-messages.h \ phoneui-utils-sim.c phoneui-utils-sim.h \ phoneui-utils-calls.c phoneui-utils-calls.h \ phoneui-info.c phoneui-info.h \ dbus.c dbus.h helpers.c helpers.h libphone_ui_HEADERS = phoneui.h phoneui-utils.h phoneui-utils-sound.h \ phoneui-utils-device.h phoneui-utils-feedback.h \ phoneui-utils-contacts.h phoneui-utils-messages.h \ phoneui-utils-calls.h phoneui-utils-sim.h \ phoneui-info.h libphone_uidir = $(includedir)/phoneui libphone_ui_la_LDFLAGS = $(all_libraries) -ldl #libphone_ui_la_LDFLAGS = $(all_libraries) -ldl -version-info 0:0:1 -release 20100812 -no-undefined libphone_ui_la_LIBADD = @GLIB_LIBS@ @SHR_GLIB_LIBS@ @FSO_GLIB_LIBS@ @LIBPHONE_UTILS_LIBS@ @ALSA_LIBS@ @X11_LIBS@ libphone-ui-0.0.1+git20110825/src/dbus.c000066400000000000000000000133761162551416000172300ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include "dbus.h" gpointer _fso(GType type, const gchar *obj, const gchar *path, const gchar *iface) { GError *error = NULL; gpointer ret; ret = g_initable_new(type, NULL, &error, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, "g-name", obj, "g-bus-type", G_BUS_TYPE_SYSTEM, "g-object-path", path, "g-interface-name", iface, NULL); if (error) { g_warning("failed to connect to %s: %s", path, error->message); g_error_free(error); return NULL; } return ret; } gpointer _fso_pim_contacts() { return _fso(FREE_SMARTPHONE_PIM_TYPE_CONTACTS_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, FSO_FRAMEWORK_PIM_ContactsServicePath, FSO_FRAMEWORK_PIM_ContactsServiceFace); } gpointer _fso_pim_contact(const gchar* path) { return _fso(FREE_SMARTPHONE_PIM_TYPE_CONTACT_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".Contact"); } gpointer _fso_pim_dates(const gchar* path) { return _fso(FREE_SMARTPHONE_PIM_TYPE_DATE_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".Date"); } gpointer _fso_pim_messages() { return _fso(FREE_SMARTPHONE_PIM_TYPE_MESSAGES_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, FSO_FRAMEWORK_PIM_MessagesServicePath, FSO_FRAMEWORK_PIM_MessagesServiceFace); } gpointer _fso_pim_message(const gchar* path) { return _fso(FREE_SMARTPHONE_PIM_TYPE_MESSAGE_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".Message"); } gpointer _fso_pim_notes() { return _fso(FREE_SMARTPHONE_PIM_TYPE_NOTES_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, FSO_FRAMEWORK_PIM_NotesServicePath, FSO_FRAMEWORK_PIM_NotesServiceFace); } gpointer _fso_pim_tasks() { return _fso(FREE_SMARTPHONE_PIM_TYPE_TASKS_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, FSO_FRAMEWORK_PIM_TasksServicePath, FSO_FRAMEWORK_PIM_TasksServiceFace); } gpointer _fso_pim_calls() { return _fso(FREE_SMARTPHONE_PIM_TYPE_CALLS_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, FSO_FRAMEWORK_PIM_CallsServicePath, FSO_FRAMEWORK_PIM_CallsServiceFace); } gpointer _fso_pim_fields(const gchar* path) { return _fso(FREE_SMARTPHONE_PIM_TYPE_FIELDS_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".Fields"); } gpointer _fso_gsm_sim() { return _fso(FREE_SMARTPHONE_GSM_TYPE_SIM_PROXY, FSO_FRAMEWORK_GSM_ServiceDBusName, FSO_FRAMEWORK_GSM_DeviceServicePath, FSO_FRAMEWORK_GSM_ServiceFacePrefix ".SIM"); } gpointer _fso_gsm_call() { return _fso(FREE_SMARTPHONE_GSM_TYPE_CALL_PROXY, FSO_FRAMEWORK_GSM_ServiceDBusName, FSO_FRAMEWORK_GSM_DeviceServicePath, FSO_FRAMEWORK_GSM_ServiceFacePrefix ".Call"); } gpointer _fso_gsm_network() { return _fso(FREE_SMARTPHONE_GSM_TYPE_NETWORK_PROXY, FSO_FRAMEWORK_GSM_ServiceDBusName, FSO_FRAMEWORK_GSM_DeviceServicePath, FSO_FRAMEWORK_GSM_ServiceFacePrefix ".Network"); } gpointer _fso_gsm_pdp() { return _fso(FREE_SMARTPHONE_GSM_TYPE_PDP_PROXY, FSO_FRAMEWORK_GSM_ServiceDBusName, FSO_FRAMEWORK_GSM_DeviceServicePath, FSO_FRAMEWORK_GSM_ServiceFacePrefix ".PDP"); } gpointer _fso_device_idle_notifier() { return _fso(FREE_SMARTPHONE_DEVICE_TYPE_IDLE_NOTIFIER_PROXY, FSO_FRAMEWORK_DEVICE_ServiceDBusName, FSO_FRAMEWORK_DEVICE_IdleNotifierServicePath "/0", FSO_FRAMEWORK_DEVICE_IdleNotifierServiceFace); } gpointer _fso_device_display() { return _fso(FREE_SMARTPHONE_DEVICE_TYPE_DISPLAY_PROXY, FSO_FRAMEWORK_DEVICE_ServiceDBusName, FSO_FRAMEWORK_DEVICE_DisplayServicePath "/0", FSO_FRAMEWORK_DEVICE_DisplayServiceFace); } gpointer _fso_device_input() { return _fso(FREE_SMARTPHONE_DEVICE_TYPE_INPUT_PROXY, FSO_FRAMEWORK_DEVICE_ServiceDBusName, FSO_FRAMEWORK_DEVICE_InputServicePath, FSO_FRAMEWORK_DEVICE_InputServiceFace); } gpointer _fso_device_power_supply() { return _fso(FREE_SMARTPHONE_DEVICE_TYPE_POWER_SUPPLY_PROXY, FSO_FRAMEWORK_DEVICE_ServiceDBusName, FSO_FRAMEWORK_DEVICE_PowerSupplyServicePath, FSO_FRAMEWORK_DEVICE_PowerSupplyServiceFace); } gpointer _fso_preferences() { return _fso(FREE_SMARTPHONE_TYPE_PREFERENCES_PROXY, FSO_FRAMEWORK_PREFERENCES_ServiceDBusName, FSO_FRAMEWORK_PREFERENCES_ServicePathPrefix, FSO_FRAMEWORK_PREFERENCES_ServiceFacePrefix); } gpointer _fso_usage() { return _fso(FREE_SMARTPHONE_TYPE_USAGE_PROXY, FSO_FRAMEWORK_USAGE_ServiceDBusName, FSO_FRAMEWORK_USAGE_ServicePathPrefix, FSO_FRAMEWORK_USAGE_ServiceFacePrefix); } gpointer _phonefso(GError **error) { return phonefso_usage_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, "org.shr.phonefso", "/org/shr/phonefso/Usage", NULL, error); } libphone-ui-0.0.1+git20110825/src/dbus.h000066400000000000000000000031351162551416000172250ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _DBUS_H #define _DBUS_H #include gpointer _fso(GType type, const gchar *obj, const gchar *path, const gchar *iface); gpointer _fso_pim_contacts(); gpointer _fso_pim_contact(const gchar *path); gpointer _fso_pim_messages(); gpointer _fso_pim_message(const gchar *path); gpointer _fso_pim_notes(); gpointer _fso_pim_tasks(); gpointer _fso_pim_calls(); gpointer _fso_pim_dates(); gpointer _fso_pim_fields(const gchar *path); gpointer _fso_gsm_sim(); gpointer _fso_gsm_call(); gpointer _fso_gsm_network(); gpointer _fso_gsm_pdp(); gpointer _fso_device_power_supply(); gpointer _fso_device_input(); gpointer _fso_device_idle_notifier(); gpointer _fso_device_display(); gpointer _fso_preferences(); gpointer _fso_usage(); gpointer _phonefso(); #endif libphone-ui-0.0.1+git20110825/src/helpers.c000066400000000000000000000033471162551416000177320ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include GValue * _helpers_new_gvalue_string(const char *value) { GValue *val = calloc(1, sizeof(GValue)); if (!val) { return NULL; } g_value_init(val, G_TYPE_STRING); g_value_set_string(val, value); return val; } GValue * _helpers_new_gvalue_int(int value) { GValue *val = calloc(1, sizeof(GValue)); if (!val) { return NULL; } g_value_init(val, G_TYPE_INT); g_value_set_int(val, value); return val; } GValue * _helpers_new_gvalue_boolean(int value) { GValue *val = calloc(1, sizeof(GValue)); if (!val) { return NULL; } g_value_init(val, G_TYPE_BOOLEAN); g_value_set_boolean(val, value); return val; } void _helpers_free_gvalue(gpointer val) { GValue *value = (GValue *)val; g_value_unset(value); g_free(value); } void _helpers_free_gvariant(gpointer value) { GVariant *val = (GVariant *)value; g_variant_unref(val); } libphone-ui-0.0.1+git20110825/src/helpers.h000066400000000000000000000022411162551416000177270ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _HELPERS_H #define _HELPERS_H #include #include GValue *_helpers_new_gvalue_string(const char *value); GValue *_helpers_new_gvalue_int(int value); GValue *_helpers_new_gvalue_boolean(gboolean value); void _helpers_free_gvalue(gpointer value); void _helpers_free_gvariant(gpointer value); #endif libphone-ui-0.0.1+git20110825/src/phoneui-info.c000066400000000000000000001417341162551416000206730ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * Sebastian Krzyszkowiak * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include #include "phoneui-info.h" #include "phoneui-utils-contacts.h" #include "dbus.h" struct _fso { FreeSmartphoneUsage *usage; FreeSmartphoneGSMCall *gsm_call; FreeSmartphoneGSMNetwork *gsm_network; FreeSmartphoneGSMPDP *gsm_pdp; FreeSmartphoneDeviceIdleNotifier *idle_notifier; FreeSmartphoneDeviceInput *input; FreeSmartphoneDevicePowerSupply *power_supply; FreeSmartphoneDeviceDisplay *display; FreeSmartphonePreferences *preferences; FreeSmartphonePIMMessages *pim_messages; FreeSmartphonePIMContacts *pim_contacts; FreeSmartphonePIMCalls *pim_calls; FreeSmartphonePIMTasks *pim_tasks; }; static struct _fso fso; static GList *callbacks_contact_changes = NULL; static GList *callbacks_message_changes = NULL; static GList *callbacks_call_changes = NULL; static GList *callbacks_profile_changes = NULL; static GList *callbacks_capacity_changes = NULL; static GList *callbacks_missed_calls = NULL; static GList *callbacks_unread_messages = NULL; static GList *callbacks_unfinished_tasks = NULL; static GList *callbacks_resource_changes = NULL; static GList *callbacks_network_status = NULL; static GList *callbacks_pdp_context_status = NULL; static GList *callbacks_signal_strength = NULL; static GList *callbacks_input_events = NULL; static GList *callbacks_idle_notifier = NULL; static GList *callbacks_backlight_power = NULL; static GList *callbacks_call_status = NULL; static GHashTable *single_contact_changes = NULL; struct _cb_pim_changes_pack { void (*callback)(void *, const char *, enum PhoneuiInfoChangeType); void *data; }; struct _cb_pim_single_changes_pack { void (*callback)(void *, int, enum PhoneuiInfoChangeType); void *data; }; struct _single_pim_changes_pack { int entryid; GObject *proxy; GList *callbacks; }; struct _cb_hashtable_pack { void (*callback)(void *, GHashTable *); void *data; }; struct _cb_int_pack { void (*callback)(void *, int); void *data; }; struct _cb_idle_pack { void (*callback)(void *, FreeSmartphoneDeviceIdleState); void *data; }; struct _cb_charp_pack { void (*callback)(void *, const char *); void *data; }; struct _cb_input_event_pack { void (*callback)(void *, const char *, FreeSmartphoneDeviceInputState, int); void *data; }; struct _cb_resource_changes_pack { void (*callback)(void *, const char*, gboolean, GHashTable *); void *data; }; struct _cb_3int_pack { void (*callback)(void *, int, int, int); void *data; }; struct _cb_int_hashtable_pack { void (*callback)(void *, int, GHashTable *); void *data; }; struct _cb_gsm_context_status_pack { void (*callback)(void *, FreeSmartphoneGSMContextStatus, GHashTable *); void *data; }; static void _pim_missed_calls_handler(GObject *source, int amount, gpointer data); static void _pim_new_call_handler(GObject *source, char *path, gpointer data); static void _pim_unread_messages_handler(GObject *source, int amount, gpointer data); static void _pim_unfinished_tasks_handler(GObject *source, int amount, gpointer data); static void _resource_changed_handler(GObject *source, char *resource, gboolean state, GHashTable *properties, gpointer data); static void _call_status_handler(GObject *source, int callid, FreeSmartphoneGSMCallStatus state, GHashTable *properties, gpointer data); static void _profile_changed_handler(GObject *source, const char *profile, gpointer data); //static void _alarm_changed_handler(int time); static void _capacity_changed_handler(GObject *source, int energy, gpointer data); static void _network_status_handler(GObject *source, GHashTable *properties, gpointer data); static void _pdp_context_status_handler(GObject *source, FreeSmartphoneGSMContextStatus status, GHashTable *properties, gpointer data); static void _signal_strength_handler(GObject *source, int signal, gpointer data); static void _idle_notifier_handler(GObject *source, FreeSmartphoneDeviceIdleState state, gpointer data); static void _backlight_power_handler(GObject *source, int state, gpointer data); static void _pim_contact_new_handler(GObject *source, const char *path, gpointer data); static void _pim_contact_updated_handler(GObject *source, const char *path, GHashTable *content, gpointer data); static void _pim_contact_deleted_handler(GObject *source, const char *path, gpointer data); static void _pim_single_contact_updated_handler(GObject *source, GHashTable *content, gpointer data); static void _pim_single_contact_deleted_handler(GObject *source, gpointer data); static void _pim_message_new_handler(GObject *source, const char *path, gpointer data); static void _pim_message_updated_handler(GObject *source, const char *path, GHashTable *content, gpointer data); static void _pim_message_deleted_handler(GObject *source, const char *path, gpointer data); static void _device_input_event_handler(GObject* source, char* input_source, FreeSmartphoneDeviceInputState state, int duration, gpointer data); static void _pim_missed_calls_callback( GObject* source, GAsyncResult* res, gpointer data); static void _pim_unread_messages_callback( GObject* source, GAsyncResult* res, gpointer data); // static void _pim_unfinished_tasks_callback(GError *error, int amount, gpointer userdata); static void _list_resources_callback(GObject *source, GAsyncResult *res, gpointer data); static void _resource_state_callback(GObject *source, GAsyncResult *res, gpointer data); static void _get_profile_callback(GObject *source, GAsyncResult *res, gpointer data); static void _get_capacity_callback(GObject *source, GAsyncResult *res, gpointer data); static void _get_network_status_callback(GObject *source, GAsyncResult *res, gpointer data); static void _get_pdp_context_status_callback(GObject *source, GAsyncResult *res, gpointer data); static void _get_signal_strength_callback(GObject *source, GAsyncResult *res, gpointer data); static void _get_backlight_power_callback(GObject *source, GAsyncResult *res, gpointer data); //static void _get_alarm_callback(GError *error, int time, gpointer userdata); // static void _name_owner_changed(DBusGProxy *proxy, const char *name, const char *prev, const char *new, gpointer data); static void _execute_pim_changed_callbacks(GList *cbs, const char *path, enum PhoneuiInfoChangeType type); static void _execute_pim_single_changed_callbacks(GList* cbs, int entryid, enum PhoneuiInfoChangeType type); static void _execute_int_callbacks(GList *cbs, int value); static void _execute_idle_callbacks(GList *cbs, FreeSmartphoneDeviceIdleState value); static void _execute_charp_callbacks(GList *cbs, const char *value); static void _execute_input_event_callbacks(GList *cbs, const char *value1, FreeSmartphoneDeviceInputState value2, int value3); static void _execute_hashtable_callbacks(GList *cbs, GHashTable *properties); static void _execute_resource_callbacks(GList *cbs, const char *resource, gboolean state, GHashTable *properties); static void _execute_int_hashtable_callbacks(GList *cbs, int val1, GHashTable *val2); static void _execute_gsm_context_status_callbacks(GList *cbs, FreeSmartphoneGSMContextStatus val1, GHashTable *val2); static void _callbacks_list_free_foreach(gpointer _data, gpointer userdata) { struct _cb_hashtable_pack *data = (struct _cb_hashtable_pack *) _data; (void) userdata; if (data->data) free(data->data); free(data); } static void callbacks_list_free(GList *list) { if (!list) return; g_list_foreach(list, _callbacks_list_free_foreach, NULL); g_list_free(list); } int phoneui_info_init() { fso.usage = _fso_usage(); if (fso.usage) { g_signal_connect(fso.usage, "resource-changed", G_CALLBACK(_resource_changed_handler), NULL); } fso.gsm_call = _fso_gsm_call(); if (fso.gsm_call) { g_signal_connect(fso.gsm_call, "call-status", G_CALLBACK(_call_status_handler), NULL); } fso.gsm_network =_fso_gsm_network(); if (fso.gsm_network) { g_signal_connect(fso.gsm_network, "status", G_CALLBACK(_network_status_handler), NULL); g_signal_connect(fso.gsm_network, "signal-strength", G_CALLBACK(_signal_strength_handler), NULL); } fso.gsm_pdp = _fso_gsm_pdp(); if (fso.gsm_pdp) { g_signal_connect(fso.gsm_pdp, "context-status", G_CALLBACK(_pdp_context_status_handler), NULL); } fso.power_supply = _fso_device_power_supply(); if (fso.power_supply) { g_signal_connect(fso.power_supply, "capacity", G_CALLBACK(_capacity_changed_handler), NULL); } fso.input = _fso_device_input(); if (fso.input) { g_signal_connect(fso.input, "event", G_CALLBACK(_device_input_event_handler), NULL); } fso.idle_notifier = _fso_device_idle_notifier(); if (fso.idle_notifier) { g_signal_connect(fso.idle_notifier, "state", G_CALLBACK(_idle_notifier_handler), NULL); } fso.display = _fso_device_display(); if (fso.display) { g_signal_connect(fso.display, "backlight-power", G_CALLBACK(_backlight_power_handler), NULL); } fso.preferences = _fso_preferences(); if (fso.preferences) { g_signal_connect(fso.preferences, "changed", G_CALLBACK(_profile_changed_handler), NULL); } fso.pim_contacts = _fso_pim_contacts(); if (fso.pim_contacts) { g_signal_connect(fso.pim_contacts, "new-contact", G_CALLBACK(_pim_contact_new_handler), NULL); g_signal_connect(fso.pim_contacts, "updated-contact", G_CALLBACK(_pim_contact_updated_handler), NULL); g_signal_connect(fso.pim_contacts, "deleted-contact", G_CALLBACK(_pim_contact_deleted_handler), NULL); } fso.pim_messages = _fso_pim_messages(); if (fso.pim_messages) { g_signal_connect(fso.pim_messages, "unread-messages", G_CALLBACK(_pim_unread_messages_handler), NULL); g_signal_connect(fso.pim_messages, "new-message", G_CALLBACK(_pim_message_new_handler), NULL); g_signal_connect(fso.pim_messages, "updated-message", G_CALLBACK(_pim_message_updated_handler), NULL); g_signal_connect(fso.pim_messages, "deleted-message", G_CALLBACK(_pim_message_deleted_handler), NULL); } fso.pim_tasks = _fso_pim_tasks(); if (fso.pim_tasks) { g_signal_connect(fso.pim_tasks, "unfinished-tasks", G_CALLBACK(_pim_unfinished_tasks_handler), NULL); } fso.pim_calls = _fso_pim_calls(); if (fso.pim_calls) { g_signal_connect(fso.pim_calls, "new-missed-calls", G_CALLBACK(_pim_missed_calls_handler), NULL); g_signal_connect(fso.pim_calls, "new-call", G_CALLBACK(_pim_new_call_handler), NULL); } return 0; } void phoneui_info_deinit() { /*FIXME: find out how to correctly clean up dbus proxies and the connection itself */ //dbus_g_connection_unref(_dbus()); callbacks_list_free(callbacks_contact_changes); callbacks_list_free(callbacks_message_changes); callbacks_list_free(callbacks_call_changes); callbacks_list_free(callbacks_profile_changes); callbacks_list_free(callbacks_capacity_changes); callbacks_list_free(callbacks_missed_calls); callbacks_list_free(callbacks_unread_messages); callbacks_list_free(callbacks_resource_changes); callbacks_list_free(callbacks_network_status); callbacks_list_free(callbacks_pdp_context_status); callbacks_list_free(callbacks_idle_notifier); callbacks_list_free(callbacks_backlight_power); callbacks_list_free(callbacks_signal_strength); callbacks_list_free(callbacks_input_events); callbacks_list_free(callbacks_call_status); } void phoneui_info_trigger() { /* manually feed initial data to the idle screen... further * updates will be handled by the signal handlers registered above */ //TODO unfinished tasks // TODO odeviced_realtime_clock_get_alarm(_get_alarm_callback, NULL); } struct _resource_status_request_pack { char *resource; struct _cb_resource_changes_pack pack; }; void phoneui_info_register_contact_changes(void (*callback)(void *, const char*, enum PhoneuiInfoChangeType), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback - fix your code"); return; } struct _cb_pim_changes_pack *pack = malloc(sizeof(struct _cb_pim_changes_pack)); if (!pack) { g_warning("Failed allocating callback pack - not registering"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_contact_changes, pack); if (!l) { g_warning("Failed to register callback for contact changes"); } else { if (!callbacks_contact_changes) { callbacks_contact_changes = l; g_debug("Registered a callback for contact changes"); } } } void phoneui_info_register_single_contact_changes(int entryid, void (*callback)(void *, int, enum PhoneuiInfoChangeType), void *data) { struct _single_pim_changes_pack *pack = NULL; struct _cb_pim_single_changes_pack *cbpack = NULL; GList *l; char *path; if (single_contact_changes) { pack = g_hash_table_lookup(single_contact_changes, &entryid); } else { single_contact_changes = g_hash_table_new(g_int_hash, g_int_equal); } cbpack = malloc(sizeof(*cbpack)); if (!cbpack) { g_warning("Failed allocating cb pack for changes of contact %d - Not registering", entryid); return; } cbpack->callback = callback; cbpack->data = data; if (!pack) { pack = malloc(sizeof(*pack)); if (!pack) { g_warning("Failed allocating pack for single PIM contact changes!"); free(cbpack); return; } path = phoneui_utils_contact_get_dbus_path(entryid); if (!path) { free(cbpack); return; } pack->entryid = entryid; pack->callbacks = NULL; pack->proxy = _fso_pim_contact(path); g_signal_connect(pack->proxy, "contact-updated", G_CALLBACK(_pim_single_contact_updated_handler), GINT_TO_POINTER(entryid)); g_signal_connect(pack->proxy, "contact-deleted", G_CALLBACK(_pim_single_contact_deleted_handler), GINT_TO_POINTER(entryid)); g_hash_table_insert(single_contact_changes, &pack->entryid, pack); free(path); } l = g_list_append(pack->callbacks, cbpack); if (!l) { g_warning("Failed to register callback for changes of contact %d", entryid); } else { if (!pack->callbacks) { pack->callbacks = l; } g_debug("Registered a callback for changes of contact %d", entryid); } } void phoneui_info_unregister_single_contact_changes(int entryid, void (*callback)(void *, int, enum PhoneuiInfoChangeType)) { GList *cb; struct _single_pim_changes_pack *pack; struct _cb_pim_single_changes_pack *cbpack; if (!single_contact_changes) { g_debug("No one registered for single contact changes - Nothing to unregister"); return; } pack = g_hash_table_lookup(single_contact_changes, &entryid); if (!pack) { g_debug("No one registered for changes of contact %d - Nothing to unregister", entryid); return; } for (cb = g_list_first(pack->callbacks); cb; cb = g_list_next(cb)) { cbpack = cb->data; g_debug("comparing a callback"); if ((void *)cbpack->callback == (void *)callback) { pack->callbacks = g_list_remove(pack->callbacks, cbpack); g_debug("Removed callback for Contact %d", entryid); if (!pack->callbacks) { g_debug("Was the last one - releasing the Contact proxy for %d", entryid); g_object_unref(pack->proxy); free(pack); g_hash_table_remove(single_contact_changes, &entryid); } return; } } g_debug("Callback not found for contact %d", entryid); } void phoneui_info_register_message_changes(void (*callback)(void *, const char*, enum PhoneuiInfoChangeType), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback - fix your code"); return; } struct _cb_pim_changes_pack *pack = malloc(sizeof(struct _cb_pim_changes_pack)); if (!pack) { g_warning("Failed allocating callback pack - not registering"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_message_changes, pack); if (!l) { g_warning("Failed to register callback for message changes"); } else { if (!callbacks_message_changes) { callbacks_message_changes = l; g_debug("Registered a callback for message changes"); } } } void phoneui_info_register_call_changes(void (*callback)(void *, const char *, enum PhoneuiInfoChangeType), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback - fix your code"); return; } struct _cb_pim_changes_pack *pack = malloc(sizeof(struct _cb_pim_changes_pack)); if (!pack) { g_warning("Failed allocating callback pack - not registering"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_call_changes, pack); if (!l) { g_warning("Failed to register callback for call changes"); } else { if (!callbacks_call_changes) { callbacks_call_changes = l; g_debug("Registered a callback for call changes"); } } } void phoneui_info_register_call_status_changes(void (*callback)(void *, int, GHashTable *), void* data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (call status)"); return; } struct _cb_int_hashtable_pack *pack = malloc(sizeof(struct _cb_int_hashtable_pack)); if (!pack) { g_warning("Failed allocating callback pack (call status)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_call_status, pack); if (!l) { g_warning("Failed to register callback for call status"); } else { if (!callbacks_call_status) { callbacks_call_status = l; } g_debug("Registered a callback for call status"); } } void phoneui_info_register_profile_changes(void (*callback)(void *, const char *), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (profile changes)"); return; } struct _cb_charp_pack *pack = malloc(sizeof(struct _cb_charp_pack)); if (!pack) { g_warning("Failed allocating callback pack (profile changes)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_profile_changes, pack); if (!l) { g_warning("Failed to register callback for profile changes"); } else { if (!callbacks_profile_changes) { callbacks_profile_changes = l; g_debug("Registered a callback for profile changes"); } } } void phoneui_info_request_profile(void (*callback)(void *, const char *), void *data) { if (!fso.preferences) return; struct _cb_charp_pack *pack = malloc(sizeof(struct _cb_charp_pack)); pack->callback = callback; pack->data = data; free_smartphone_preferences_get_profile(fso.preferences, _get_profile_callback, pack); } void phoneui_info_register_and_request_profile_changes(void (*callback)(void *, const char *), void *data) { phoneui_info_register_profile_changes(callback, data); phoneui_info_request_profile(callback, data); } void phoneui_info_register_capacity_changes(void (*callback)(void *, int), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (capacity changes)"); return; } struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); if (!pack) { g_warning("Failed allocating callback pack (capacity changes)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_capacity_changes, pack); if (!l) { g_warning("Failed to register callback for capacity changes"); } else { if (!callbacks_capacity_changes) { callbacks_capacity_changes = l; g_debug("Registered a callback for capacity changes"); } } } void phoneui_info_request_capacity(void (*callback)(void *, int), void *data) { if (!fso.power_supply) return; struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); pack->callback = callback; pack->data = data; free_smartphone_device_power_supply_get_capacity(fso.power_supply, (GAsyncReadyCallback) _get_capacity_callback, pack); } void phoneui_info_register_and_request_capacity_changes(void (*callback)(void *, int), void *data) { phoneui_info_register_capacity_changes(callback, data); phoneui_info_request_capacity(callback, data); } void phoneui_info_register_missed_calls(void (*callback)(void *, int), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (missed calls)"); return; } struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); if (!pack) { g_warning("Failed allocating callback pack (missed calls)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_missed_calls, pack); if (!l) { g_warning("Failed to register callback for missed calls"); } else { if (!callbacks_missed_calls) { callbacks_missed_calls = l; g_debug("Registered a callback for missed calls"); } } } void phoneui_info_request_missed_calls(void (*callback)(void *, int), void *data) { if (!fso.pim_calls) return; struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); pack->callback = callback; pack->data = data; free_smartphone_pim_calls_get_new_missed_calls(fso.pim_calls, (GAsyncReadyCallback)_pim_missed_calls_callback, pack); } void phoneui_info_register_and_request_missed_calls(void (*callback)(void *, int), void *data) { phoneui_info_register_missed_calls(callback, data); phoneui_info_request_missed_calls(callback, data); } void phoneui_info_register_unread_messages(void (*callback)(void *, int), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (unread messages)"); return; } struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); if (!pack) { g_warning("Failed allocating callback pack (unread messages)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_unread_messages, pack); if (!l) { g_warning("Failed to register callback for unread messages"); } else { if (!callbacks_unread_messages) { callbacks_unread_messages = l; g_debug("Registered a callback for unread messages"); } } } void phoneui_info_request_unread_messages(void (*callback)(void *, int), void *data) { if (!fso.pim_messages) return; struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); pack->callback = callback; pack->data = data; free_smartphone_pim_messages_get_unread_messages(fso.pim_messages, (GAsyncReadyCallback)_pim_unread_messages_callback, pack); } void phoneui_info_register_and_request_unread_messages(void (*callback)(void *, int), void *data) { phoneui_info_register_unread_messages(callback, data); phoneui_info_request_unread_messages(callback, data); } void phoneui_info_register_unfinished_tasks(void (*callback)(void *, int), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (unfinished tasks)"); return; } struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); if (!pack) { g_warning("Failed allocating callback pack (unfinished tasks)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_unfinished_tasks, pack); if (!l) { g_warning("Failed to register callback for unfinished tasks"); } else { if (!callbacks_unfinished_tasks) { callbacks_unfinished_tasks = l; g_debug("Registered a callback for unfinished tasks"); } } } void phoneui_info_request_unfinished_tasks(void (*callback)(void *, int), void *data) { (void) callback; (void) data; // FIXME: activate when PIM.Tasks has GetUnfinishedTasks() /* struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); pack->callback = callback; pack->data = data; opimd_tasks_get_unfinished_tasks(_unfinished_tasks_callback, pack);*/ } void phoneui_info_register_and_request_unfinished_tasks(void (*callback)(void *, int), void *data) { phoneui_info_register_unfinished_tasks(callback, data); phoneui_info_request_unfinished_tasks(callback, data); } void phoneui_info_register_resource_status(void (*callback)(void *, const char *, gboolean, GHashTable *), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (resource changes)"); return; } struct _cb_resource_changes_pack *pack = malloc(sizeof(struct _cb_resource_changes_pack)); if (!pack) { g_warning("Failed allocating callback pack (resource changes)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_resource_changes, pack); if (!l) { g_warning("Failed to register callback for resource changes"); } else { if (!callbacks_resource_changes) { callbacks_resource_changes = l; g_debug("Registered a callback for resource changes"); } } } void phoneui_info_request_resource_status(void (*callback)(void *, const char *, gboolean, GHashTable *), void *data) { if (!fso.usage) return; struct _cb_resource_changes_pack *pack = malloc(sizeof(struct _cb_resource_changes_pack)); pack->callback = callback; pack->data = data; free_smartphone_usage_list_resources(fso.usage, (GAsyncReadyCallback)_list_resources_callback, pack); } void phoneui_info_register_and_request_resource_status(void (*callback)(void *, const char *, gboolean, GHashTable *), void *data) { phoneui_info_register_resource_status(callback, data); phoneui_info_request_resource_status(callback, data); } void phoneui_info_register_network_status(void (*callback)(void *, GHashTable *), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (network status)"); return; } struct _cb_hashtable_pack *pack = malloc(sizeof(struct _cb_hashtable_pack)); if (!pack) { g_warning("Failed allocating callback pack (network status)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_network_status, pack); if (!l) { g_warning("Failed to register callback for network status"); } else { if (!callbacks_network_status) { callbacks_network_status = l; g_debug("Registered a callback for network status"); } } } void phoneui_info_request_network_status(void (*callback)(void *, GHashTable *), void *data) { if (!fso.gsm_network) return; struct _cb_hashtable_pack *pack = malloc(sizeof(struct _cb_hashtable_pack)); pack->callback = callback; pack->data = data; free_smartphone_gsm_network_get_status(fso.gsm_network, (GAsyncReadyCallback)_get_network_status_callback, pack); } void phoneui_info_register_and_request_network_status(void (*callback)(void *, GHashTable *), void *data) { phoneui_info_register_network_status(callback, data); phoneui_info_request_network_status(callback, data); } void phoneui_info_register_pdp_context_status(void (*callback)(void *, FreeSmartphoneGSMContextStatus, GHashTable *), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (pdp context status)"); return; } struct _cb_gsm_context_status_pack *pack = malloc(sizeof(struct _cb_gsm_context_status_pack)); if (!pack) { g_warning("Failed allocating callback pack (pdp context status)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_pdp_context_status, pack); if (!l) { g_warning("Failed to register callback for pdp context status"); } else { if (!callbacks_pdp_context_status) { callbacks_pdp_context_status = l; g_debug("Registered a callback for pdp context status"); } } } void phoneui_info_request_pdp_context_status(void (*callback)(void *, FreeSmartphoneGSMContextStatus, GHashTable *), void *data) { if (!fso.gsm_pdp) return; struct _cb_gsm_context_status_pack *pack = malloc(sizeof(struct _cb_gsm_context_status_pack)); pack->callback = callback; pack->data = data; free_smartphone_gsm_pdp_get_context_status(fso.gsm_pdp, _get_pdp_context_status_callback, pack); } void phoneui_info_register_and_request_pdp_context_status(void (*callback)(void *, FreeSmartphoneGSMContextStatus, GHashTable *), void *data) { phoneui_info_register_pdp_context_status(callback, data); phoneui_info_request_pdp_context_status(callback, data); } void phoneui_info_register_idle_notifier(void (*callback)(void *, FreeSmartphoneDeviceIdleState), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (idle notifier)"); return; } struct _cb_idle_pack *pack = malloc(sizeof(struct _cb_idle_pack)); if (!pack) { g_warning("Failed allocating callback pack (idle notifier)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_idle_notifier, pack); if (!l) { g_warning("Failed to register callback for idle notifier"); } else { if (!callbacks_idle_notifier) { callbacks_idle_notifier = l; g_debug("Registered a callback for idle notifier"); } } } void phoneui_info_register_signal_strength(void (*callback)(void *, int), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (signal strength)"); return; } struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); if (!pack) { g_warning("Failed allocating callback pack (signal strength)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_signal_strength, pack); if (!l) { g_warning("Failed to register callback for signal strength"); } else { if (!callbacks_signal_strength) { callbacks_signal_strength = l; g_debug("Registered a callback for signal strength"); } } } void phoneui_info_request_signal_strength(void (*callback)(void *, int), void *data) { if (!fso.gsm_network) return; struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); pack->callback = callback; pack->data = data; free_smartphone_gsm_network_get_signal_strength(fso.gsm_network, (GAsyncReadyCallback)_get_signal_strength_callback, pack); } void phoneui_info_register_and_request_signal_strength(void (*callback)(void *, int), void *data) { phoneui_info_register_signal_strength(callback, data); phoneui_info_request_signal_strength(callback, data); } void phoneui_info_register_input_events(void (*callback)(void *, const char *, FreeSmartphoneDeviceInputState, int), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (input events)"); return; } struct _cb_input_event_pack *pack = malloc(sizeof(struct _cb_input_event_pack)); if (!pack) { g_warning("Failed allocating callback pack (input events)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_input_events, pack); if (!l) { g_warning("Failed to register callback for input events"); } else { if (!callbacks_input_events) { callbacks_input_events = l; g_debug("Registered a callback for input events"); } } } void phoneui_info_register_backlight_power(void (*callback)(void *, int), void *data) { GList *l; if (!callback) { g_debug("Not registering an empty callback (backlight power)"); return; } struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); if (!pack) { g_warning("Failed allocating callback pack (backlight power)"); return; } pack->callback = callback; pack->data = data; l = g_list_append(callbacks_backlight_power, pack); if (!l) { g_warning("Failed to register callback for backlight power"); } else { if (!callbacks_backlight_power) { callbacks_backlight_power = l; g_debug("Registered a callback for backlight power"); } } } void phoneui_info_request_backlight_power(void (*callback)(void *, int), void *data) { if (!fso.display) return; struct _cb_int_pack *pack = malloc(sizeof(struct _cb_int_pack)); pack->callback = callback; pack->data = data; free_smartphone_device_display_get_backlight_power(fso.display, (GAsyncReadyCallback)_get_backlight_power_callback, pack); } void phoneui_info_register_and_request_backlight_power(void (*callback)(void *, int), void *data) { phoneui_info_register_backlight_power(callback, data); phoneui_info_request_backlight_power(callback, data); } /* --- signal handlers --- */ static void _pim_missed_calls_handler(GObject* source, int amount, gpointer data) { (void) source; (void) data; g_debug("_missed_calls_handler: %d missed calls", amount); _execute_int_callbacks(callbacks_missed_calls, amount); } static void _pim_new_call_handler(GObject *source, char *path, gpointer data) { (void) source; (void) data; _execute_pim_changed_callbacks(callbacks_call_changes, path, PHONEUI_INFO_CHANGE_NEW); } static void _pim_unread_messages_handler(GObject* source, int amount, gpointer data) { (void) source; (void) data; g_debug("_unread_messages_handler: %d unread messages", amount); _execute_int_callbacks(callbacks_unread_messages, amount); } static void _pim_unfinished_tasks_handler(GObject* source, int amount, gpointer data) { (void) source; (void) data; g_debug("_unfinished_tasks_handler: %d unfinished tasks", amount); _execute_int_callbacks(callbacks_unfinished_tasks, amount); } static void _resource_changed_handler(GObject *source, char *resource, gboolean state, GHashTable *properties, gpointer data) { (void) source; (void) data; g_debug("_resource_changed_handler: %s is now %s", resource, state ? "enabled" : "disabled"); _execute_resource_callbacks(callbacks_resource_changes, resource, state, properties); } static void _call_status_handler(GObject *source, int callid, FreeSmartphoneGSMCallStatus state, GHashTable *properties, gpointer data) { (void) source; (void) data; _execute_int_hashtable_callbacks(callbacks_call_status, state, properties); g_debug("_call_status_handler: call %d: %d", callid, state); } static void _profile_changed_handler(GObject* source, const char* profile, gpointer data) { (void) source; (void) data; g_debug("_profile_changed_handler: active profile is %s", profile); _execute_charp_callbacks(callbacks_profile_changes, profile); } //static void _alarm_changed_handler(const int time) //{ // g_debug("_alarm_changed_hanlder: alarm set to %d", time); // phoneui_idle_screen_update_alarm(time); //} static void _capacity_changed_handler(GObject* source, int energy, gpointer data) { (void) source; (void) data; g_debug("_capacity_changed_handler: capacity is %d", energy); _execute_int_callbacks(callbacks_capacity_changes, energy); } static void _network_status_handler(GObject* source, GHashTable* properties, gpointer data) { (void) source; (void) data; _execute_hashtable_callbacks(callbacks_network_status, properties); } static void _pdp_context_status_handler(GObject *source, FreeSmartphoneGSMContextStatus status, GHashTable *properties, gpointer data) { (void) source; (void) data; _execute_gsm_context_status_callbacks (callbacks_pdp_context_status, status, properties); } static void _signal_strength_handler(GObject* source, int signal, gpointer data) { (void) source; (void) data; g_debug("_signal_strength_handler: %d", signal); _execute_int_callbacks(callbacks_signal_strength, signal); } static void _idle_notifier_handler(GObject* source, FreeSmartphoneDeviceIdleState state, gpointer data) { (void) source; (void) data; g_debug("_idle_notifier_handler: idle state now %d", state); _execute_idle_callbacks(callbacks_idle_notifier, state); } static void _backlight_power_handler(GObject* source, int state, gpointer data) { (void) source; (void) data; g_debug("_backlight_power_handler: state now %d", state); _execute_int_callbacks(callbacks_backlight_power, state); } static void _pim_contact_new_handler(GObject* source, const char* path, gpointer data) { (void) source; (void) data; g_debug("New contact %s got added", path); _execute_pim_changed_callbacks(callbacks_contact_changes, path, PHONEUI_INFO_CHANGE_NEW); } static void _pim_contact_updated_handler(GObject* source, const char* path, GHashTable* content, gpointer data) { (void) source; (void) data; (void) content; g_debug("Contact %s got updated", path); _execute_pim_changed_callbacks(callbacks_contact_changes, path, PHONEUI_INFO_CHANGE_UPDATE); } static void _pim_contact_deleted_handler(GObject* source, const char* path, gpointer data) { (void) source; (void) data; g_debug("Contact %s got deleted", path); _execute_pim_changed_callbacks(callbacks_contact_changes, path, PHONEUI_INFO_CHANGE_DELETE); } static void _pim_single_contact_updated_handler(GObject *source, GHashTable *content, gpointer data) { (void) source; (void) content; struct _single_pim_changes_pack *pack; int entryid = GPOINTER_TO_INT(data); g_debug("Handling update of single contact %d", entryid); if (!single_contact_changes) { g_warning("No listener for changes of single PIM Contacts!"); return; } pack = g_hash_table_lookup(single_contact_changes, &entryid); if (!pack) { g_warning("No listener for changes of PIM Contact %d", entryid); return; } _execute_pim_single_changed_callbacks(pack->callbacks, entryid, PHONEUI_INFO_CHANGE_UPDATE); } static void _pim_single_contact_deleted_handler(GObject *source, gpointer data) { (void) source; struct _single_pim_changes_pack *pack; int entryid = GPOINTER_TO_INT(data); g_debug("Handling deletion of single contact %d", entryid); if (!single_contact_changes) { g_warning("No listener for changes of single PIM Contacts!"); return; } pack = g_hash_table_lookup(single_contact_changes, &entryid); if (!pack) { g_warning("No listener for changes of PIM Contact %d", entryid); return; } _execute_pim_single_changed_callbacks(pack->callbacks, entryid, PHONEUI_INFO_CHANGE_DELETE); } static void _pim_message_new_handler(GObject* source, const char* path, gpointer data) { (void) source; (void) data; g_debug("New message %s got added", path); _execute_pim_changed_callbacks(callbacks_message_changes, path, PHONEUI_INFO_CHANGE_NEW); } static void _pim_message_updated_handler(GObject* source, const char* path, GHashTable* content, gpointer data) { (void) source; (void) data; (void) content; g_debug("Message %s got updated", path); _execute_pim_changed_callbacks(callbacks_message_changes, path, PHONEUI_INFO_CHANGE_UPDATE); } static void _pim_message_deleted_handler(GObject* source, const char* path, gpointer data) { (void) source; (void) data; g_debug("Message %s got deleted", path); _execute_pim_changed_callbacks(callbacks_message_changes, path, PHONEUI_INFO_CHANGE_DELETE); } static void _device_input_event_handler(GObject* source, char* input_source, FreeSmartphoneDeviceInputState action, int duration, gpointer data) { (void) source; (void) data; _execute_input_event_callbacks(callbacks_input_events, input_source, action, duration); } /* callbacks for request of data */ static void _pim_missed_calls_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; int amount; amount = free_smartphone_pim_calls_get_new_missed_calls_finish (fso.pim_calls, res, &error); if (error) { g_message("_missed_calls_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } if (data) { struct _cb_int_pack *pack = data; pack->callback(pack->data, amount); free(pack); } } static void _pim_unread_messages_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; int amount; amount = free_smartphone_pim_messages_get_unread_messages_finish (fso.pim_messages, res, &error); if (error) { g_message("_unread_messages_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } if (data) { struct _cb_int_pack *pack = data; pack->callback(pack->data, amount); free(pack); } } // static void // _pim_unfinished_tasks_callback(GError *error, int amount, gpointer userdata) // { // struct _cb_int_pack *pack; // // if (error) { // g_message("_pim_unfinished_tasks_callback: error% d: %s", // error->code, error->message); // return; // } // if (userdata) { // pack = userdata; // pack->callback(pack->data, amount); // free(pack); // } // } static void _list_resources_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; char **resources; int count; resources = free_smartphone_usage_get_resource_users_finish (fso.usage, res, &count, &error); struct _resource_status_request_pack *pack; struct _cb_resource_changes_pack *packpack; if (error) { g_message("_list_resources_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } packpack = data; if (resources) { int i = 0; while (resources[i] != NULL) { pack = malloc(sizeof(struct _resource_status_request_pack)); pack->resource = resources[i]; pack->pack.callback = packpack->callback; pack->pack.data = packpack->data; free_smartphone_usage_get_resource_state(fso.usage, resources[i], _resource_state_callback, pack); i++; } } free(packpack); } static void _resource_state_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; gboolean state; state = free_smartphone_usage_get_resource_state_finish (fso.usage, res, &error); if (error) { g_message("_resource_state_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } if (data) { struct _resource_status_request_pack *pack = data; pack->pack.callback(pack->pack.data, pack->resource, state, NULL); // FIXME: do we have to free pack->resource ??? free(pack); } } static void _get_profile_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; char *profile; profile = free_smartphone_preferences_get_profile_finish (fso.preferences, res, &error); if (error) { g_message("_get_profile_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } if (data) { struct _cb_charp_pack *pack = data; pack->callback(pack->data, profile); free(pack); } } static void _get_capacity_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; int energy; energy = free_smartphone_device_power_supply_get_capacity_finish (fso.power_supply, res, &error); if (error) { g_message("_get_capacity_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } if (data) { struct _cb_int_pack *pack = data; pack->callback(pack->data, energy); free(pack); } } static void _get_network_status_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; GHashTable *properties = NULL; properties = free_smartphone_gsm_network_get_status_finish (fso.gsm_network, res, &error); g_debug("_get_network_status_callback"); if (error) { g_message("_get_network_status_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } if (data) { struct _cb_hashtable_pack *pack = data; pack->callback(pack->data, properties); free(pack); } g_debug("_get_network_status_callback DONE"); } static void _get_pdp_context_status_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; FreeSmartphoneGSMContextStatus status; GHashTable *properties = NULL; struct _cb_gsm_context_status_pack *pack = data; g_debug("_get_pdp_context_status_callback"); free_smartphone_gsm_pdp_get_context_status_finish (fso.gsm_pdp, res, &status, &properties, &error); if (error) { g_message("_get_pdp_context_status_callback: error %d: %s", error->code, error->message); g_error_free(error); } else if (pack->callback) { pack->callback(pack->data, status, properties); } if (properties) { g_hash_table_destroy(properties); } if (pack) { free(pack); } g_debug("_get_pdp_context_status_callback DONE"); } static void _get_signal_strength_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; int signal; g_debug("_get_signal_strength_callback"); signal = free_smartphone_gsm_network_get_signal_strength_finish (fso.gsm_network, res, &error); if (error) { g_message("_get_signal_strength_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } if (data) { struct _cb_int_pack *pack = data; g_debug("calling signal callback"); pack->callback(pack->data, signal); free(pack); } g_debug("_get_signal_strength_callback DONE"); } static void _get_backlight_power_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; int signal; g_debug("_get_backlight_power_callback"); signal = free_smartphone_device_display_get_backlight_power_finish (fso.display, res, &error); if (error) { g_message("_get_backlight_power_callback: error %d: %s", error->code, error->message); g_error_free(error); return; } if (data) { struct _cb_int_pack *pack = data; g_debug("calling signal callback"); pack->callback(pack->data, signal); free(pack); } g_debug("_get_backlight_power_callback DONE"); } //static void _get_alarm_callback(GError *error, // const int time, gpointer userdata) //{ // (void)userdata; // // if (error) { // g_message("_get_alarm_callback: error %d: %s", // error->code, error->message); // return; // } // phoneui_idle_screen_update_alarm(time); //} #if 0 static void _name_owner_changed(DBusGProxy *proxy, const char *name, const char *prev, const char *new, gpointer data) { (void) proxy; (void) new; (void) data; if (prev && *prev && !strcmp(name, FSO_FRAMEWORK_GSM_ServiceDBusName)) { _execute_hashtable_callbacks(callbacks_network_status, NULL); _execute_gsm_context_status_callbacks (callbacks_pdp_context_status, FREE_SMARTPHONE_GSM_CONTEXT_STATUS_UNKNOWN, NULL); _execute_int_callbacks(callbacks_signal_strength, 0); } } #endif static void _execute_pim_changed_callbacks(GList *cbs, const char *path, enum PhoneuiInfoChangeType type) { GList *cb; if (!cbs) { g_debug("No callbacks registered"); return; } g_debug("Running all callbacks"); for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_pim_changes_pack *pack = (struct _cb_pim_changes_pack *)cb->data; pack->callback(pack->data, path, type); } } static void _execute_pim_single_changed_callbacks(GList *cbs, int entryid, enum PhoneuiInfoChangeType type) { GList *cb; if (!cbs) { g_debug("No callbacks registered"); return; } for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_pim_single_changes_pack *pack = cb->data; pack->callback(pack->data, entryid, type); } } static void _execute_int_callbacks(GList *cbs, int value) { GList *cb; if (!cbs) return; for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_int_pack *pack = (struct _cb_int_pack *)cb->data; pack->callback(pack->data, value); } } static void _execute_idle_callbacks(GList *cbs, FreeSmartphoneDeviceIdleState value) { GList *cb; if (!cbs) return; for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_idle_pack *pack = (struct _cb_idle_pack *)cb->data; pack->callback(pack->data, value); } } static void _execute_input_event_callbacks(GList *cbs, const char *value1, FreeSmartphoneDeviceInputState value2, int value3) { GList *cb; if (!cbs) return; for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_input_event_pack *pack = cb->data; pack->callback(pack->data, value1, value2, value3); } } static void _execute_hashtable_callbacks(GList *cbs, GHashTable *properties) { GList *cb; if (!cbs) return; for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_hashtable_pack *pack = (struct _cb_hashtable_pack *)cb->data; pack->callback(pack->data, properties); } } static void _execute_charp_callbacks(GList* cbs, const char* value) { GList *cb; if (!cbs) return; for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_charp_pack *pack = (struct _cb_charp_pack *)cb->data; pack->callback(pack->data, value); } } static void _execute_resource_callbacks(GList *cbs, const char *resource, gboolean state, GHashTable *properties) { GList *cb; if (!cbs) return; for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_resource_changes_pack *pack = (struct _cb_resource_changes_pack *)cb->data; pack->callback(pack->data, resource, state, properties); } } static void _execute_int_hashtable_callbacks(GList *cbs, int val1, GHashTable *val2) { GList *cb; if (!cbs) return; for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_int_hashtable_pack *pack = cb->data; pack->callback(pack->data, val1, val2); } } static void _execute_gsm_context_status_callbacks(GList *cbs, FreeSmartphoneGSMContextStatus val1, GHashTable *val2) { GList *cb; if (!cbs) return; for (cb = g_list_first(cbs); cb; cb = g_list_next(cb)) { struct _cb_gsm_context_status_pack *pack = cb->data; pack->callback(pack->data, val1, val2); } } libphone-ui-0.0.1+git20110825/src/phoneui-info.h000066400000000000000000000116111162551416000206660ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_INFO_H #define _PHONEUI_INFO_H #include enum PhoneuiInfoChangeType { PHONEUI_INFO_CHANGE_NEW = 0, PHONEUI_INFO_CHANGE_UPDATE, PHONEUI_INFO_CHANGE_DELETE }; int phoneui_info_init(); void phoneui_info_deinit(); void phoneui_info_trigger(); void phoneui_info_register_contact_changes(void (*_cb)(void *, const char *, enum PhoneuiInfoChangeType), void *data); void phoneui_info_register_single_contact_changes(int entryid, void (*_cb)(void *, int, enum PhoneuiInfoChangeType), void *data); void phoneui_info_unregister_single_contact_changes(int entryid, void (*callback)(void *, int, enum PhoneuiInfoChangeType)); void phoneui_info_register_message_changes(void (*_cb)(void *, const char *, enum PhoneuiInfoChangeType), void *data); void phoneui_info_register_call_changes(void (*_cb)(void *, const char *, enum PhoneuiInfoChangeType), void *data); void phoneui_info_register_call_status_changes(void (*_cb)(void *, int, GHashTable *), void *data); void phoneui_info_register_profile_changes(void (*_cb)(void *, const char *), void *data); void phoneui_info_request_profile(void (*_cb)(void *, const char *), void *data); void phoneui_info_register_and_request_profile_changes(void (*_cb)(void *, const char *), void *data); void phoneui_info_register_capacity_changes(void (*_cb)(void *, int), void *data); void phoneui_info_request_capacity(void (*_cb)(void *, int), void *data); void phoneui_info_register_and_request_capacity_changes(void (*_cb)(void *, int), void *data); void phoneui_info_register_missed_calls(void (*_cb)(void *, int), void *data); void phoneui_info_request_missed_calls(void (*_cb)(void *, int), void *data); void phoneui_info_register_and_request_missed_calls(void (*_cb)(void *, int), void *data); void phoneui_info_register_unread_messages(void (*_cb)(void *, int), void *data); void phoneui_info_request_unread_messages(void (*_cb)(void *, int), void *data); void phoneui_info_register_and_request_unread_messages(void (*_cb)(void *, int), void *data); void phoneui_info_register_unfinished_tasks(void (*_cb)(void *, int), void *data); void phoneui_info_request_unfinished_tasks(void (*_cb)(void *, int), void *data); void phoneui_info_register_and_request_unfinished_tasks(void (*_cb)(void *, int), void *data); void phoneui_info_register_resource_status(void (*_cb)(void *, const char *, gboolean, GHashTable *), void *data); void phoneui_info_request_resource_status(void (*_cb)(void *, const char *, gboolean, GHashTable *), void *data); void phoneui_info_register_and_request_resource_status(void (*_cb)(void *, const char *, gboolean, GHashTable *), void *data); // TODO register/request alarm void phoneui_info_register_network_status(void (*_cb)(void *, GHashTable *), void *data); void phoneui_info_request_network_status(void (*_cb)(void *, GHashTable *), void *data); void phoneui_info_register_and_request_network_status(void (*_cb)(void *, GHashTable *), void *data); void phoneui_info_register_pdp_context_status(void (*_cb)(void *, FreeSmartphoneGSMContextStatus, GHashTable*), void *data); void phoneui_info_request_pdp_context_status(void (*_cb)(void *, FreeSmartphoneGSMContextStatus, GHashTable*), void *data); void phoneui_info_register_and_request_pdp_context_status(void (*_cb)(void *, FreeSmartphoneGSMContextStatus, GHashTable *), void *data); void phoneui_info_register_signal_strength(void (*_cb)(void *, int), void *data); void phoneui_info_request_signal_strength(void (*_cb)(void *, int), void *data); void phoneui_info_register_and_request_signal_strength(void (*_cb)(void *, int), void *data); void phoneui_info_register_idle_notifier(void (*_cb)(void *, FreeSmartphoneDeviceIdleState), void *data); void phoneui_info_register_input_events(void (*_cb)(void *, const char *, FreeSmartphoneDeviceInputState, int), void *data); void phoneui_info_register_backlight_power(void (*_cb)(void *, int), void *data); void phoneui_info_request_backlight_power(void (*_cb)(void *, int), void *data); void phoneui_info_register_and_request_backlight_power(void (*_cb)(void *, int), void *data); #endif libphone-ui-0.0.1+git20110825/src/phoneui-utils-calls.c000066400000000000000000000151101162551416000221600ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include "phoneui-utils-calls.h" #include "dbus.h" #include "helpers.h" struct _call_pack { void (*callback)(GError *, int, gpointer); gpointer data; }; struct _empty_pack { void (*callback)(GError *, gpointer); gpointer data; }; struct _network_pack { void (*callback)(GError *, gpointer); gpointer data; }; static void _call_initiate_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; int callid; struct _call_pack *pack = data; callid = free_smartphone_gsm_call_initiate_finish ((FreeSmartphoneGSMCall *)source, res, &error); if (pack->callback) { pack->callback(error, callid, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_call_initiate(const char *_number, void (*callback)(GError *, int, gpointer), gpointer userdata) { FreeSmartphoneGSMCall *proxy; struct _call_pack *pack; char *number; g_message("Inititating a call to %s\n", _number); pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _fso_gsm_call(); number = strdup(_number); phone_utils_remove_filler_chars(number); free_smartphone_gsm_call_initiate (proxy, number, "voice", _call_initiate_callback, pack); return 0; } static void _call_release_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _empty_pack *pack = data; // free_smartphone_gsm_call_release_finish(pack->call, res, &error); free_smartphone_gsm_call_release_all_finish ((FreeSmartphoneGSMCall *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_critical("Failed to release a call: (%d) %s", error->code, error->message); g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_call_release(int call_id, void (*callback)(GError *, gpointer), gpointer data) { (void) call_id; FreeSmartphoneGSMCall *proxy; struct _empty_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_call(); free_smartphone_gsm_call_release (proxy, call_id, _call_release_callback, pack); return 0; } static void _call_activate_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _empty_pack *pack = data; free_smartphone_gsm_call_activate_finish ((FreeSmartphoneGSMCall *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_call_activate(int call_id, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphoneGSMCall *proxy; struct _empty_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_call(); free_smartphone_gsm_call_activate (proxy, call_id, _call_activate_callback, pack); return 0; } static void _send_dtmf_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _empty_pack *pack = data; free_smartphone_gsm_call_send_dtmf_finish ((FreeSmartphoneGSMCall *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_warning("Sending DMF failed: (%d) %s", error->code, error->message); g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_call_send_dtmf(const char *tones, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphoneGSMCall *proxy; struct _empty_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_call(); free_smartphone_gsm_call_send_dtmf (proxy, tones, _send_dtmf_callback, pack); return 0; } static void _phoneui_utils_dial_call_cb(GError *error, int id_call, gpointer data) { struct _call_pack *pack = data; /*can never be null */ if (pack->callback) { pack->callback(error, id_call, pack->data); } free(pack); } static void _phoneui_utils_dial_ussd_cb(GError *error, gpointer data) { struct _call_pack *pack = data; /*can never be null */ if (pack->callback) { pack->callback(error, 0, pack->data); } free(pack); } /* Starts either a call or an ussd request * expects a valid number*/ int phoneui_utils_dial(const char *number, void (*callback)(GError *, int, gpointer), gpointer userdata) { struct _call_pack *pack; pack = malloc(sizeof(*pack)); if (!pack) { g_critical("Failed to allocate memory %s:%d", __FUNCTION__, __LINE__); return 1; } pack->data = userdata; pack->callback = callback; if (phone_utils_gsm_number_is_ussd(number)) { phoneui_utils_ussd_initiate(number, _phoneui_utils_dial_ussd_cb, pack); } else { phoneui_utils_call_initiate(number, _phoneui_utils_dial_call_cb, pack); } return 0; } static void _ussd_initiate_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _network_pack *pack = data; free_smartphone_gsm_network_send_ussd_request_finish ((FreeSmartphoneGSMNetwork *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_ussd_initiate(const char *request, void (*callback)(GError *, gpointer), void *data) { FreeSmartphoneGSMNetwork *proxy; struct _network_pack *pack; g_message("Inititating a USSD request %s\n", request); pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_network(); free_smartphone_gsm_network_send_ussd_request (proxy, request, _ussd_initiate_callback, pack); return 0; } libphone-ui-0.0.1+git20110825/src/phoneui-utils-calls.h000066400000000000000000000031611162551416000221700ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_UTILS_CALLS_H #define _PHONEUI_UTILS_CALLS_H #include int phoneui_utils_call_initiate(const char *number, void (*callback)(GError *, int id_call, gpointer), gpointer userdata); int phoneui_utils_call_release(int call_id, void (*callback)(GError *, gpointer), gpointer userdata); int phoneui_utils_call_activate(int call_id, void (*callback)(GError *, gpointer), gpointer userdata); int phoneui_utils_call_send_dtmf(const char *tones, void (*callback)(GError *, gpointer), gpointer userdata); int phoneui_utils_dial(const char *number, void (*callback)(GError *, int id_call, gpointer), gpointer userdata); int phoneui_utils_ussd_initiate(const char *request, void (*callback)(GError *, gpointer), gpointer userdata); #endif libphone-ui-0.0.1+git20110825/src/phoneui-utils-contacts.c000066400000000000000000000435561162551416000227170ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * Marco Trevisan (Treviño) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include #include #include "helpers.h" #include "dbus.h" #include "phoneui-utils.h" #include "phoneui-utils-contacts.h" struct _query_pack { int *count; void (*callback)(gpointer, gpointer); gpointer data; }; struct _field_type_pack { gpointer data; void (*callback)(GError *, char *, gpointer); }; struct _fields_pack { gpointer data; void (*callback)(GError *, GHashTable *, gpointer); }; struct _fields_with_type_pack { gpointer data; void (*callback)(GError *, char **, int, gpointer); }; struct _field_pack { gpointer data; void (*callback)(GError *, gpointer); }; struct _contact_lookup_pack { gpointer *data; void (*callback)(GError *, GHashTable *, gpointer); }; struct _contact_add_pack { void (*callback)(GError *, char *, gpointer); gpointer data; }; struct _contact_pack { void (*callback)(GError *, gpointer); gpointer data; }; struct _contact_get_pack { gpointer data; void (*callback)(GError *, GHashTable *, gpointer); }; static int _compare_func(gconstpointer a, gconstpointer b) { return phoneui_utils_contact_compare(*((GHashTable **)a), *((GHashTable **)b)); } void phoneui_utils_contacts_query(const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, const GHashTable *options, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data) { phoneui_utils_pim_query(PHONEUI_PIM_DOMAIN_CONTACTS, sortby, sortdesc, disjunction, limit_start, limit, FALSE, options, callback, data); } void phoneui_utils_contacts_get_full(const char *sortby, gboolean sortdesc, int limit_start, int limit, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer userdata) { phoneui_utils_contacts_query(sortby, sortdesc, FALSE, limit_start, limit, NULL, callback, userdata); } static void _contacts_parse(GError *error, GHashTable **messages, int count, gpointer data) { int i; GPtrArray *contacts; struct _query_pack *pack = data; if (pack->count) *pack->count = count; if (error) goto exit; contacts = g_ptr_array_sized_new(count); for (i = 0; i < count; i++) g_ptr_array_add(contacts, messages[i]); g_ptr_array_sort(contacts, _compare_func); g_ptr_array_foreach(contacts, pack->callback, pack->data); g_ptr_array_unref(contacts); exit: free(pack); } void phoneui_utils_contacts_get(int *count, void (*callback)(gpointer, gpointer), gpointer userdata) { struct _query_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; pack->count = count; if (count) *count = 0; phoneui_utils_contacts_get_full(NULL, FALSE, 0, -1, _contacts_parse, pack); } static void _contacts_field_type_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) res; GError *error = NULL; char *type = NULL; struct _field_type_pack *pack = data; type = free_smartphone_pim_fields_get_type__finish ((FreeSmartphonePIMFields *)source, res, &error); if (pack->callback) { pack->callback(error, type, pack->data); } if (type) { free(type); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_contacts_field_type_get(const char *name, void (*callback)(GError *, char *, gpointer), gpointer data) { FreeSmartphonePIMFields *proxy; struct _field_type_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_fields(FSO_FRAMEWORK_PIM_ContactsServicePath); free_smartphone_pim_fields_get_type_ (proxy, name, _contacts_field_type_callback, pack); } static void _fields_strip_system_fields(GHashTable *fields) { /* Remove the system fields */ g_hash_table_remove(fields, "Path"); } static void _fields_get_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; GHashTable *fields; struct _fields_pack *pack = data; g_debug("_fields_get_callback"); fields = free_smartphone_pim_fields_list_fields_finish ((FreeSmartphonePIMFields *)source, res, &error); if (pack->callback) { if (fields) { g_debug("Stripping system fields"); _fields_strip_system_fields(fields); } g_debug("Calling callback"); pack->callback(error, fields, pack->data); } if (fields) { g_hash_table_unref(fields); } if (error) { g_error_free(error); } g_debug("Freeing stuff"); g_object_unref(source); free(pack); g_debug("_fields_get_callback done"); } void phoneui_utils_contacts_fields_get(void (*callback)(GError *, GHashTable *, gpointer), gpointer data) { struct _fields_pack *pack; FreeSmartphonePIMFields *proxy; g_debug("phoneui_utils_contacts_fields_get START"); pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_fields(FSO_FRAMEWORK_PIM_ContactsServicePath); free_smartphone_pim_fields_list_fields (proxy, _fields_get_callback, pack); g_debug("phoneui_utils_contacts_fields_get DONE"); } static void _fields_get_with_type_cb(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; char **fields; int count; struct _fields_with_type_pack *pack = data; fields = free_smartphone_pim_fields_list_fields_with_type_finish ((FreeSmartphonePIMFields *)source, res, &count, &error); if (pack->callback) { pack->callback(error, fields, count, pack->data); } if (error) { g_error_free(error); } // FIXME: free fields here? g_object_unref(source); free(pack); } void phoneui_utils_contacts_fields_get_with_type(const char *type, void (*callback)(GError *, char **, int, gpointer), gpointer data) { FreeSmartphonePIMFields *proxy; struct _fields_with_type_pack *pack = malloc(sizeof(struct _fields_with_type_pack)); pack->data = data; pack->callback = callback; proxy = _fso_pim_fields(FSO_FRAMEWORK_PIM_ContactsServicePath); free_smartphone_pim_fields_list_fields_with_type (proxy, type, _fields_get_with_type_cb, pack); } static void _field_add_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _field_pack *pack = data; free_smartphone_pim_fields_add_field_finish ((FreeSmartphonePIMFields *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } g_object_unref(source); free(pack); } void phoneui_utils_contacts_field_add(const char *name, const char *type, void (*callback)(GError *, gpointer), void *data) { FreeSmartphonePIMFields *proxy; struct _field_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_fields(FSO_FRAMEWORK_PIM_ContactsServicePath); free_smartphone_pim_fields_add_field (proxy, name, type, _field_add_callback, pack); } static void _field_remove_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; struct _field_pack *pack = data; free_smartphone_pim_fields_delete_field_finish ((FreeSmartphonePIMFields *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } g_object_unref(source); free(pack); } void phoneui_utils_contacts_field_remove(const char *name, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphonePIMFields *proxy; struct _field_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_fields(FSO_FRAMEWORK_PIM_ContactsServicePath); free_smartphone_pim_fields_delete_field (proxy, name, _field_remove_callback, pack); } static void _contact_lookup_callback(GError *error, GHashTable **messages, int count, gpointer data) { struct _contact_lookup_pack *pack = data; GVariant *tmp; const char *path; if (count != 1 || !(tmp = g_hash_table_lookup(messages[0], "Path")) || error) { pack->callback(error, NULL, pack->data); return; } path = g_variant_get_string(tmp, NULL); phoneui_utils_contact_get(path, pack->callback, pack->data); g_hash_table_unref(messages[0]); free(pack); } int phoneui_utils_contact_lookup(const char *number, void (*callback)(GError *, GHashTable *, gpointer), gpointer data) { GVariant *value; GHashTable *query; struct _contact_lookup_pack *pack; /* makes no sense to continue without callback */ if (!callback) { g_message("phoneui_utils_contact_lookup without callback?"); return 1; } pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; query = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, _helpers_free_gvariant); value = g_variant_new_string(number); if (!value) { g_hash_table_destroy(query); // FIXME: create a nice error and pass it pack->callback(NULL, NULL, pack->data); free(pack); return 1; } g_hash_table_insert(query, "$phonenumber", g_variant_ref_sink(value)); phoneui_utils_contacts_query(NULL, FALSE, FALSE, 0, 1, query, _contact_lookup_callback, pack); g_hash_table_unref(query); return 0; } static void _contact_delete_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _contact_pack *pack = data; free_smartphone_pim_contact_delete_finish ((FreeSmartphonePIMContact *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_contact_delete(const char *path, void (*callback) (GError *, gpointer), void *data) { FreeSmartphonePIMContact *proxy; struct _contact_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_contact(path); free_smartphone_pim_contact_delete(proxy, _contact_delete_callback, pack); return 0; } static void _contact_update_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _contact_pack *pack = data; free_smartphone_pim_contact_update_finish ((FreeSmartphonePIMContact *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } free(pack); if (error) g_error_free(error); g_object_unref(source); } int phoneui_utils_contact_update(const char *path, GHashTable *contact_data, void (*callback)(GError *, gpointer), void* data) { FreeSmartphonePIMContact *proxy; struct _contact_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_contact(path); free_smartphone_pim_contact_update (proxy, contact_data, _contact_update_callback, pack); return 0; } static void _contact_add_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _contact_add_pack *pack = data; gchar *path; path = free_smartphone_pim_contacts_add_finish ((FreeSmartphonePIMContacts *)source, res, &error); if (pack->callback) { pack->callback(error, path, pack->data); } if (path) g_free(path); if (error) g_error_free(error); g_object_unref(source); } int phoneui_utils_contact_add(GHashTable *contact_data, void (*callback)(GError*, char *, gpointer), void* data) { FreeSmartphonePIMContacts *proxy; struct _contact_add_pack *pack; pack = malloc(sizeof(*pack)); pack->data = data; pack->callback = callback; proxy = _fso_pim_contacts(); free_smartphone_pim_contacts_add (proxy, contact_data, _contact_add_callback, pack); return 0; } static void _contact_get_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _contact_get_pack *pack = data; GHashTable *contact; contact = free_smartphone_pim_contact_get_content_finish ((FreeSmartphonePIMContact *)source, res, &error); if (pack->callback) { pack->callback(error, contact, pack->data); } free(pack); g_object_unref(source); } int phoneui_utils_contact_get(const char *contact_path, void (*callback)(GError *, GHashTable *, gpointer), gpointer data) { FreeSmartphonePIMContact *proxy; struct _contact_get_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_contact(contact_path); free_smartphone_pim_contact_get_content (proxy, _contact_get_callback, pack); return 0; } void phoneui_utils_contact_get_fields_for_type(const char* contact_path, const char* type, void (*callback)(GError *, GHashTable *, gpointer), void *data) { FreeSmartphonePIMContact *proxy; struct _contact_get_pack *pack; char *_type = calloc(sizeof(char), strlen(type)+2); _type[0] = '$'; strcat(_type, type); pack = malloc(sizeof(*pack)); pack->data = data; pack->callback = callback; proxy = _fso_pim_contact(contact_path); free_smartphone_pim_contact_get_multiple_fields (proxy, _type, _contact_get_callback, pack); free(_type); } char * phoneui_utils_contact_display_phone_get(GHashTable *properties) { const char *phone = NULL; gpointer _key, _val; GHashTableIter iter; g_hash_table_iter_init(&iter, properties); while (g_hash_table_iter_next(&iter, &_key, &_val)) { const char *key = (const char *)_key; GVariant *val = (GVariant *) _val; if (!val) { g_debug(" hmm... field has no value?"); continue; } /* Use the types mechanism */ /* sanitize phone numbers */ if (strstr(key, "Phone") || strstr(key, "phone")) { const char *s_val; const gchar **strv; if (g_variant_is_of_type(val, G_VARIANT_TYPE_STRING)) { s_val = g_variant_get_string(val, NULL); } else if (g_variant_is_of_type(val, G_VARIANT_TYPE_STRING_ARRAY)) { strv = g_variant_get_strv(val, NULL); s_val = strv[0]; free(strv); } else { g_debug("Value for field %s is neither string nor strv :(", key); continue; } /* if key is exactly 'Phone' we want that is default * phone number for this contact */ if (strcmp(key, "Phone")) { phone = s_val; } /* otherwise we take it as default if it is the * first phone number we see ... */ else if (!phone) { phone = s_val; } } } return (phone) ? strdup(phone) : NULL; } char * phoneui_utils_contact_display_name_get(GHashTable *properties) { gpointer _key, _val; const char *name = NULL, *surname = NULL; const char *middlename = NULL, *nickname = NULL; const char *affiliation = NULL; char *displayname = NULL; GHashTableIter iter; g_hash_table_iter_init(&iter, properties); while (g_hash_table_iter_next(&iter, &_key, &_val)) { const char *key = (const char *)_key; GVariant *val = (GVariant *) _val; if (!val) { g_debug(" hmm... field has no value?"); continue; } if (!strcmp(key, "Name")) { const char *s_val = g_variant_get_string(val, NULL); name = s_val; } else if (!strcmp(key, "Surname")) { const char *s_val = g_variant_get_string(val, NULL); surname = s_val; } else if (!strcmp(key, "Middlename")) { const char *s_val = g_variant_get_string(val, NULL); middlename = s_val; } else if (!strcmp(key, "Nickname")) { const char *s_val = g_variant_get_string(val, NULL); nickname = s_val; } else if (!strcmp(key, "Affiliation")) { affiliation = g_variant_get_string(val, NULL); } } /* construct some sane display name from the fields */ if (name && nickname && surname && affiliation) { displayname = g_strdup_printf("%s '%s' %s (%s)", name, nickname, surname, affiliation); } else if (name && nickname && surname) { displayname = g_strdup_printf("%s '%s' %s", name, nickname, surname); } else if (name && middlename && surname && affiliation) { displayname = g_strdup_printf("%s %s %s (%s)", name, middlename, surname, affiliation); } else if (name && middlename && surname) { displayname = g_strdup_printf("%s %s %s", name, middlename, surname); } else if (name && surname && affiliation) { displayname = g_strdup_printf("%s %s (%s)", name, surname, affiliation); } else if (name && surname) { displayname = g_strdup_printf("%s %s", name, surname); } else if (nickname && affiliation) { displayname = g_strdup_printf("%s (%s)", nickname, affiliation); } else if (nickname) { displayname = g_strdup(nickname); } else if (name && affiliation) { displayname = g_strdup_printf("%s (%s)", name, affiliation); } else if (name) { displayname = g_strdup(name); } else if (surname && affiliation) { displayname = g_strdup_printf("%s (%s)", surname, affiliation); } else if (surname) { displayname = g_strdup(surname); } else if (affiliation) { displayname = g_strdup(affiliation); } return displayname; } int phoneui_utils_contact_compare(GHashTable *contact1, GHashTable *contact2) { int ret; char *name1 = phoneui_utils_contact_display_name_get(contact1); if (!name1) return -1; char *name2 = phoneui_utils_contact_display_name_get(contact2); if (!name2) { free (name1); return 1; } ret = strcoll(name1, name2); free(name1); free(name2); return ret; } char * phoneui_utils_contact_get_dbus_path(int entryid) { /* 15 = 1 for '\0', 1 for '/' and 13 for max possible int size */ int len = strlen(FSO_FRAMEWORK_PIM_ContactsServicePath) + 15; char *ret = calloc(sizeof(char), len); if (!ret) { return NULL; } snprintf(ret, len-1, "%s/%d", FSO_FRAMEWORK_PIM_ContactsServicePath, entryid); return ret; } libphone-ui-0.0.1+git20110825/src/phoneui-utils-contacts.h000066400000000000000000000061301162551416000227070ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * Marco Trevisan (Treviño) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_UTILS_CONTACTS_H #define _PHONEUI_UTILS_CONTACTS_H #include void phoneui_utils_contacts_query(const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, const GHashTable *options, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data); void phoneui_utils_contacts_get_full(const char *sortby, gboolean sortdesc, int limit_start, int limit, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data); void phoneui_utils_contacts_get(int *count, void (*callback)(gpointer , gpointer), gpointer data); void phoneui_utils_contacts_field_type_get(const char *name, void (*callback)(GError *, char *, gpointer), gpointer user_data); void phoneui_utils_contacts_fields_get(void (*callback)(GError *, GHashTable *, gpointer), gpointer data); void phoneui_utils_contacts_fields_get_with_type(const char *type, void (*callback)(GError *, char **, int, gpointer), gpointer data); void phoneui_utils_contacts_field_add(const char *name, const char *type, void (*callback)(GError *, gpointer), gpointer data); void phoneui_utils_contacts_field_remove(const char *name, void (*callback)(GError *, gpointer), gpointer data); int phoneui_utils_contact_lookup(const char *_number, void (*_callback) (GError *, GHashTable *, gpointer), gpointer data); int phoneui_utils_contact_delete(const char *path, void (*name_callback) (GError *, gpointer), gpointer data); int phoneui_utils_contact_update(const char *path, GHashTable *contact_data, void (*callback)(GError *, gpointer), gpointer data); int phoneui_utils_contact_add(GHashTable *contact_data, void (*callback)(GError*, char *, gpointer), gpointer data); int phoneui_utils_contact_get(const char *contact_path, void (*callback)(GError *, GHashTable*, gpointer), gpointer data); void phoneui_utils_contact_get_fields_for_type(const char *contact_path, const char *type, void (*callback)(GError *, GHashTable *, gpointer), gpointer data); char *phoneui_utils_contact_display_phone_get(GHashTable *properties); char *phoneui_utils_contact_display_name_get(GHashTable *properties); int phoneui_utils_contact_compare(GHashTable *contact1, GHashTable *contact2); char *phoneui_utils_contact_get_dbus_path(int entryid); #endif libphone-ui-0.0.1+git20110825/src/phoneui-utils-device.c000066400000000000000000000074511162551416000223320ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * Maksim 'max_posedon' Melnikau * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include #include #include #include #include #include static const char *device_vibrator = NULL; struct VibrationData { int fd; int duration; int repeat; int pause; char systring[5]; }; static int _vibration_on(gpointer data); static int _vibration_off(gpointer data); int phoneui_utils_device_init(GKeyFile *keyfile) { const char *vibrator = g_key_file_get_string(keyfile, "device", "vibrator", NULL); if (vibrator) { g_debug("using %s for vibration", vibrator); device_vibrator = strdup(vibrator); } else { g_message("no vibrator configured - turning vibration off"); } return 0; } static int _vibration_on(gpointer data) { struct VibrationData *vdata = (struct VibrationData *)data; ssize_t len = write(vdata->fd, vdata->systring, strlen(vdata->systring)); g_return_val_if_fail(len != -1, 1); g_timeout_add(vdata->duration, _vibration_off, vdata); return 0; } static int _vibration_off(gpointer data) { struct VibrationData *vdata = (struct VibrationData *)data; ssize_t len = write(vdata->fd, "0\n", 2); g_return_val_if_fail(len != -1, 1); if (vdata->repeat > 0) { vdata->repeat--; g_timeout_add(vdata->pause, _vibration_on, vdata); } else { close(vdata->fd); free(vdata); } return 0; } void phoneui_utils_device_vibrate(int duration, int intensity, int repeat, int pause) { int fd; if (!device_vibrator) return; fd = open(device_vibrator, O_WRONLY); if (fd == -1) { g_warning("vibrate error %d: %s", errno, strerror(errno)); return; } struct VibrationData *vdata = malloc(sizeof(struct VibrationData)); vdata->fd = fd; vdata->duration = duration; vdata->repeat = repeat; vdata->pause = pause; snprintf(vdata->systring, 4, "%d\n", intensity); ssize_t len = write(fd, vdata->systring, strlen(vdata->systring)); g_return_if_fail(len != -1); g_timeout_add(duration, _vibration_off, vdata); } void phoneui_utils_device_flash(int duration, int intensity, int repeat, int pause) { (void)duration; (void)intensity; (void)repeat; (void)pause; // TODO } void phoneui_utils_device_sound(const char *sound) { (void)sound; // TODO } static void _set_screensaver(int mode) { int timeout, interval, prefer_blank, allow_exp; Display* dpy = XOpenDisplay(getenv("DISPLAY")); /*FIXME: should do it only once */ g_return_if_fail(dpy != NULL); if (mode == ScreenSaverActive) { XGetScreenSaver(dpy, &timeout, &interval, &prefer_blank, &allow_exp); prefer_blank = PreferBlanking; XSetScreenSaver(dpy, timeout, interval, prefer_blank, allow_exp); } XForceScreenSaver(dpy, mode); XCloseDisplay(dpy); } void phoneui_utils_device_activate_screensaver(void) { _set_screensaver(ScreenSaverActive); } void phoneui_utils_device_deactivate_screensaver(void) { _set_screensaver(ScreenSaverReset); } libphone-ui-0.0.1+git20110825/src/phoneui-utils-device.h000066400000000000000000000024711162551416000223340ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_UTILS_DEVICE_H #define _PHONEUI_UTILS_DEVICE_H #include int phoneui_utils_device_init(GKeyFile *keyfile); void phoneui_utils_device_vibrate(int duration, int intensity, int repeat, int pause); void phoneui_utils_device_flash(int duration, int intensity, int repeat, int pause); void phoneui_utils_device_sound(const char *sound); void phoneui_utils_device_activate_screensaver(void); void phoneui_utils_device_deactivate_screensaver(void); #endif libphone-ui-0.0.1+git20110825/src/phoneui-utils-feedback.c000066400000000000000000000146671162551416000226260ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include #include #include "phoneui-utils-feedback.h" #include "phoneui-utils-device.h" struct FeedbackControl { int vibration_duration; int vibration_intensity; int vibration_repeat; int vibration_pause; int flash_duration; int flash_intensity; int flash_repeat; int flash_pause; char *sound; }; static struct FeedbackControl feedback[FEEDBACK_ACTION_END]; const char *_action2name(enum FeedbackAction action) { switch (action) { case FEEDBACK_ACTION_ERROR: return ("error"); break; case FEEDBACK_ACTION_WARNING: return ("warning"); break; case FEEDBACK_ACTION_NOTICE: return ("notice"); break; case FEEDBACK_ACTION_CLICK: return ("click"); break; case FEEDBACK_ACTION_END: break; } return (""); } static void _parse_vibrate_config(enum FeedbackAction action, const char *config) { /* sane default values (no vibration) */ feedback[action].flash_duration = 0; feedback[action].flash_intensity = FEEDBACK_VIBRATE_DEFAULT_INTENSITY; feedback[action].flash_repeat = 0; feedback[action].flash_pause = FEEDBACK_VIBRATE_DEFAULT_PAUSE; if (!config || !*config) { g_debug("feedback: no flash configured for action %s", _action2name(action)); return; } gchar **vals = g_strsplit(config, ",", 0); if (!vals) { g_message("feedback: invalid flash config for action %s", _action2name(action)); return; } if (vals[0]) { feedback[action].flash_duration = atoi(vals[0]); /* enforce minimum value for duration */ if (feedback[action].flash_duration < 10) { feedback[action].flash_duration = 10; } } if (vals[1]) feedback[action].flash_intensity = atoi(vals[1]); if (vals[2]) feedback[action].flash_repeat = atoi(vals[2]); if (vals[3]) feedback[action].flash_pause = atoi(vals[3]); g_strfreev(vals); g_debug("feedback: configured flashd,%d,%d,%d,%d for action %s", feedback[action].flash_duration, feedback[action].flash_intensity, feedback[action].flash_repeat, feedback[action].flash_pause, _action2name(action)); } static void _parse_sound_config(enum FeedbackAction action, const char *config) { struct stat s; /* sane default values (no vibration) */ feedback[action].sound = NULL; if (!config || !*config) { g_debug("feedback: no sound configured for action %s", _action2name(action)); return; } if (stat(config, &s) == -1) { g_message("feedback: invalid sound config for action %s", _action2name(action)); return; } if (!S_ISREG(s.st_mode)) { g_message("feedback: sound config for action %s is no regular file", _action2name(action)); return; } strcpy(feedback[action].sound, config); g_debug("feedback: configured sound=%s for action %s", feedback[action].sound, _action2name(action)); } static void _parse_flash_config(enum FeedbackAction action, const char *config) { /* sane default values (no vibration) */ feedback[action].vibration_duration = 0; feedback[action].vibration_intensity = 100; feedback[action].vibration_repeat = 0; feedback[action].vibration_pause = 0; if (!config || !*config) { g_debug("feedback: no vibrate configured for action %s", _action2name(action)); return; } gchar **vals = g_strsplit(config, ",", 0); if (!vals) { g_message("feedback: invalid vibrate config for action %s", _action2name(action)); return; } if (vals[0]) feedback[action].vibration_duration = atoi(vals[0]); if (vals[1]) feedback[action].vibration_intensity = atoi(vals[1]); if (vals[2]) feedback[action].vibration_repeat = atoi(vals[2]); if (vals[3]) feedback[action].vibration_pause = atoi(vals[3]); g_strfreev(vals); g_debug("feedback: configured vibrate=%d,%d,%d,%d for action %s", feedback[action].vibration_duration, feedback[action].vibration_intensity, feedback[action].vibration_repeat, feedback[action].vibration_pause, _action2name(action)); } static void _phoneui_utils_feedback_init_action(GKeyFile *keyfile, const char *_field, enum FeedbackAction action) { char *field; const char *vibrate; const char *sound; const char *flash; field = malloc(strlen(_field) + strlen("feedback_") + 1); if (field) { strcpy(field, "feedback_"); strcat(field, _field); vibrate = g_key_file_get_string(keyfile, field, "vibrate", NULL); _parse_vibrate_config(action, vibrate); sound = g_key_file_get_string(keyfile, field, "sound", NULL); _parse_sound_config(action, sound); flash = g_key_file_get_string(keyfile, field, "flash", NULL); _parse_flash_config(action, flash); } free(field); } int phoneui_utils_feedback_init(GKeyFile *keyfile) { _phoneui_utils_feedback_init_action(keyfile, "error", FEEDBACK_ACTION_ERROR); _phoneui_utils_feedback_init_action(keyfile, "warning", FEEDBACK_ACTION_WARNING); _phoneui_utils_feedback_init_action(keyfile, "notice", FEEDBACK_ACTION_NOTICE); _phoneui_utils_feedback_init_action(keyfile, "click", FEEDBACK_ACTION_CLICK); return 0; } void phoneui_utils_feedback_action(enum FeedbackAction action, enum FeedbackLevel level) { if (level > feedback_level) return; if (feedback[action].vibration_duration > 0) { phoneui_utils_device_vibrate( feedback[action].vibration_duration, feedback[action].vibration_intensity, feedback[action].vibration_repeat, feedback[action].vibration_pause); } if (feedback[action].flash_duration > 0) { phoneui_utils_device_flash( feedback[action].flash_duration, feedback[action].flash_intensity, feedback[action].flash_repeat, feedback[action].flash_pause); } if (feedback[action].sound) { phoneui_utils_device_sound(feedback[action].sound); } } libphone-ui-0.0.1+git20110825/src/phoneui-utils-feedback.h000066400000000000000000000031201162551416000226110ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_UTILS_FEEDBACK_H #define _PHONEUI_UTILS_FEEDBACK_H #define FEEDBACK_VIBRATE_MIN_DURATION 10 #define FEEDBACK_VIBRATE_DEFAULT_INTENSITY 500 #define FEEDBACK_VIBRATE_DEFAULT_PAUSE 10 #define FEEDBACK_FLASH_MIN_DURATION 10 #define FEEDBACK_FLASH_DEFAULT_INTENSITY 500 enum FeedbackAction { FEEDBACK_ACTION_CLICK = 0, FEEDBACK_ACTION_NOTICE, FEEDBACK_ACTION_WARNING, FEEDBACK_ACTION_ERROR, FEEDBACK_ACTION_END /* must be last */ }; enum FeedbackLevel { FEEDBACK_LEVEL_OFF = 0, FEEDBACK_LEVEL_LOW, FEEDBACK_LEVEL_MEDIUM, FEEDBACK_LEVEL_HIGH }; enum FeedbackLevel feedback_level; int phoneui_utils_feedback_init(GKeyFile *keyfile); void phoneui_utils_feedback_action(enum FeedbackAction action, enum FeedbackLevel level); #endif libphone-ui-0.0.1+git20110825/src/phoneui-utils-messages.c000066400000000000000000000242151162551416000226770ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * Marco Trevisan (Treviño) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include "phoneui-utils.h" #include "phoneui-utils-messages.h" #include "dbus.h" #include "helpers.h" struct _message_pack { void (*callback)(GError *, gpointer); gpointer data; }; struct _message_add_pack { void (*callback)(GError *, char *, gpointer); gpointer data; }; struct _message_get_pack { void (*callback)(GError *, GHashTable *, gpointer); gpointer data; }; struct _message_query_list_pack { gpointer data; void (*callback)(GError *, GHashTable **, int, gpointer); FreeSmartphonePIMMessageQuery *query; FreeSmartphonePIMMessages *messages; }; static GHashTable * _message_hashtable_get(const char *direction, long timestamp, const char *content, const char *source, gboolean is_new, const char *peer, int reference) { GHashTable *message; GVariant *tmp; message = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, _helpers_free_gvariant); if (!message) return NULL; if (direction && (!strcmp(direction, "in") || !strcmp(direction, "out"))) { tmp = g_variant_new_string(direction); g_hash_table_insert(message, "Direction", g_variant_ref_sink(tmp)); } if (timestamp > 0) { tmp = g_variant_new_int32(timestamp); g_hash_table_insert(message, "Timestamp", g_variant_ref_sink(tmp)); } if (content) { tmp = g_variant_new_string(content); g_hash_table_insert(message, "Content", g_variant_ref_sink(tmp)); } if (source) { tmp = g_variant_new_string(source); g_hash_table_insert(message, "Source", g_variant_ref_sink(tmp)); } tmp = g_variant_new_boolean(is_new); g_hash_table_insert(message, "New", g_variant_ref_sink(tmp)); if (peer) { tmp = g_variant_new_string(peer); g_hash_table_insert(message, "Peer", g_variant_ref_sink(tmp)); } if (reference > 0) { tmp = g_variant_new_int32(reference); g_hash_table_insert(message, "SMS-message-reference", g_variant_ref_sink(tmp)); } return message; } static void _message_add_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; struct _message_add_pack *pack = data; char *new_path; new_path = free_smartphone_pim_messages_add_finish ((FreeSmartphonePIMMessages *)source, res, &error); if (pack->callback) { pack->callback(error, new_path, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_message_add(GHashTable *message, void (*callback)(GError *, char *, gpointer), gpointer data) { FreeSmartphonePIMMessages *proxy; struct _message_add_pack *pack; if (!message) return 1; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_messages(); free_smartphone_pim_messages_add (proxy, message, _message_add_callback, pack); return 0; } int phoneui_utils_message_add_fields(const char *direction, long timestamp, const char *content, const char *source, gboolean is_new, const char *peer, int reference, void (*callback)(GError *, char *msgpath, gpointer), gpointer data) { GHashTable *message; int ret; message = _message_hashtable_get(direction, timestamp, content, source, is_new, peer, reference); if (!message) return 1; ret = phoneui_utils_message_add(message, callback, data); g_hash_table_unref(message); return ret; } static void _message_update_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _message_pack *pack = data; free_smartphone_pim_message_update_finish ((FreeSmartphonePIMMessage *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_message_update(const char *path, GHashTable *message, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphonePIMMessage *proxy; struct _message_pack *pack; if (!message || !path) return 1; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_message(path); free_smartphone_pim_message_update (proxy, message, _message_update_callback, pack); return 0; } int phoneui_utils_message_update_fields(const char *path, const char *direction, long timestamp, const char *content, const char *source, gboolean is_new, const char *peer, int reference, void (*callback)(GError *, gpointer), gpointer data) { GHashTable *message; int ret; if (!path) return 1; message = _message_hashtable_get(direction, timestamp, content, source, is_new, peer, reference); if (!message) return 1; ret = phoneui_utils_message_update(path, message, callback, data); g_hash_table_unref(message); return ret; } static void _message_delete_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _message_pack *pack = data; free_smartphone_pim_message_delete_finish ((FreeSmartphonePIMMessage *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } int phoneui_utils_message_delete(const char *path, void (*callback)(GError *, gpointer), void *data) { FreeSmartphonePIMMessage *proxy; struct _message_pack *pack; if (!path) return 1; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_pim_message(path); free_smartphone_pim_message_delete (proxy, _message_delete_callback, pack); return 0; } int phoneui_utils_message_set_new_status(const char *path, gboolean new, void (*callback) (GError *, gpointer), gpointer data) { return phoneui_utils_message_update_fields(path, NULL, 0, NULL, NULL, new, NULL, 0, callback, data); } int phoneui_utils_message_set_read_status(const char *path, int read, void (*callback) (GError *, gpointer), gpointer data) { return phoneui_utils_message_set_new_status(path, !read, callback, data); } int phoneui_utils_message_set_sent_status(const char *path, int sent, void (*callback) (GError *, gpointer), gpointer data) { return phoneui_utils_message_set_new_status(path, !sent, callback, data); } static void _message_get_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; GHashTable *message_data; struct _message_get_pack *pack = data; message_data = free_smartphone_pim_message_get_content_finish ((FreeSmartphonePIMMessage *)source, res, &error); if (pack->callback) { pack->callback(error, message_data, pack->data); } if (error) { /*FIXME: print error*/ g_error_free(error); goto end; } if (message_data) { g_hash_table_unref(message_data); } end: g_object_unref(source); free(pack); } int phoneui_utils_message_get(const char *message_path, void (*callback)(GError *, GHashTable *, gpointer), gpointer data) { FreeSmartphonePIMMessage *proxy; struct _message_get_pack *pack; if (!message_path) return 1; pack = malloc(sizeof(*pack)); pack->data = data; pack->callback = callback; proxy = _fso_pim_message(message_path); g_debug("Getting data of message with path: %s", message_path); free_smartphone_pim_message_get_content (proxy, _message_get_callback, pack); return (0); } void phoneui_utils_messages_query(const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, gboolean resolve_number, const GHashTable *options, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data) { phoneui_utils_pim_query(PHONEUI_PIM_DOMAIN_MESSAGES, sortby, sortdesc, disjunction, limit_start, limit, resolve_number, options, callback, data); } void phoneui_utils_messages_query_full(const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, gboolean resolve_number, const char *direction, long timestamp, const char *content, const char *source, gboolean is_new, const char *peer, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data) { GHashTable *query; query = _message_hashtable_get(direction, timestamp, content, source, is_new, peer, 0); phoneui_utils_messages_query(sortby, sortdesc, disjunction, limit_start, limit, resolve_number, query, callback, data); g_hash_table_unref(query); } void phoneui_utils_messages_get_full(const char *sortby, gboolean sortdesc, int limit_start, int limit, gboolean resolve_number, const char *direction, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data) { GHashTable *query; GVariant *tmp; g_debug("Retrieving messages"); query = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, _helpers_free_gvariant); if (direction && (!strcmp(direction, "in") || !strcmp(direction, "out"))) { tmp = g_variant_new_string(direction); g_hash_table_insert(query, "Direction", g_variant_ref_sink(tmp)); } phoneui_utils_messages_query(sortby, sortdesc, FALSE, limit_start, limit, resolve_number, query, callback, data); g_hash_table_unref(query); } void phoneui_utils_messages_get(void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data) { phoneui_utils_messages_get_full("Timestamp", TRUE, 0, -1, TRUE, NULL, callback, data); } libphone-ui-0.0.1+git20110825/src/phoneui-utils-messages.h000066400000000000000000000063031162551416000227020ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * Marco Trevisan (Treviño) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_UTILS_MESSAGES_H #define _PHONEUI_UTILS_MESSAGES_H #include int phoneui_utils_message_add(GHashTable *message, void (*callback)(GError *, char *msgpath, gpointer), gpointer data); int phoneui_utils_message_add_fields(const char *direction, long timestamp, const char *content, const char *source, gboolean is_new, const char *peer, int reference, void (*callback)(GError *, char *msgpath, gpointer), gpointer data); int phoneui_utils_message_update(const char *path, GHashTable *message, void (*callback) (GError *, gpointer), gpointer data); int phoneui_utils_message_update_fields(const char *path, const char *direction, long timestamp, const char *content, const char *source, gboolean is_new, const char *peer, int reference, void (*callback) (GError *, gpointer), gpointer data); int phoneui_utils_message_delete(const char *message_path, void (*callback)(GError *, gpointer), gpointer data); int phoneui_utils_message_set_new_status(const char *path, gboolean is_new, void (*callback) (GError *, gpointer), gpointer data); int phoneui_utils_message_set_read_status(const char *path, int read, void (*callback) (GError *, gpointer), gpointer data); int phoneui_utils_message_set_sent_status(const char *path, int sent, void (*callback) (GError *, gpointer), gpointer data); int phoneui_utils_message_get(const char *message_path, void (*callback)(GError *, GHashTable *, gpointer), gpointer data); void phoneui_utils_messages_query(const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, gboolean resolve_number, const GHashTable *options, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data); void phoneui_utils_messages_query_full(const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, gboolean resolve_number, const char *direction, long timestamp, const char *content, const char *source, gboolean is_new, const char *peer, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data); void phoneui_utils_messages_get_full(const char *sortby, gboolean sortdesc, int limit_start, int limit, gboolean resolve_number, const char *direction, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data); void phoneui_utils_messages_get(void (*callback) (GError *, GHashTable **, int, void *), gpointer data); #endif libphone-ui-0.0.1+git20110825/src/phoneui-utils-sim.c000066400000000000000000000225041162551416000216570ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include "phoneui-utils-sim.h" #include "dbus.h" #include "helpers.h" struct _sim_pack { void (*callback)(GError *, gpointer); gpointer data; }; struct _sim_pb_info_pack { void (*callback)(GError *, int, int, int, gpointer); gpointer data; }; struct _sim_contact_get_pack { void (*callback)(GError *, const char *, const char *, gpointer); gpointer data; }; struct _sim_contacts_get_pack { void (*callback)(GError *, FreeSmartphoneGSMSIMEntry *, int, gpointer); gpointer data; }; struct _sim_auth_status_pack { gpointer data; void (*callback)(GError *, FreeSmartphoneGSMSIMAuthStatus, gpointer); }; static void _sim_contact_delete_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _sim_pack *pack = data; free_smartphone_gsm_sim_delete_entry_finish ((FreeSmartphoneGSMSIM *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } /* * Deletes contact index from SIM */ int phoneui_utils_sim_contact_delete(const char *category, const int index, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphoneGSMSIM *proxy; struct _sim_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_sim(); free_smartphone_gsm_sim_delete_entry (proxy, category, index, _sim_contact_delete_callback, data); return 0; } static void _sim_contact_store_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _sim_pack *pack = data; free_smartphone_gsm_sim_store_entry_finish ((FreeSmartphoneGSMSIM *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } /* * Stores contact (name, number) for category to SIM at index */ int phoneui_utils_sim_contact_store(const char *category, const int index, const char *name, const char *number, void (*callback) (GError *, gpointer), gpointer data) { FreeSmartphoneGSMSIM *proxy; struct _sim_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_sim(); free_smartphone_gsm_sim_store_entry(proxy, category, index, name, number, _sim_contact_store_callback, pack); return 0; } static void _sim_retrieve_phonebook_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; int count; FreeSmartphoneGSMSIMEntry *contacts; struct _sim_contacts_get_pack *pack = data; contacts = free_smartphone_gsm_sim_retrieve_phonebook_finish ((FreeSmartphoneGSMSIM *)source, res, &count, &error); pack->callback(error, contacts, count, pack->data); // FIXME: free contacts !!! if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_sim_contacts_get(const char *category, void (*callback) (GError *, FreeSmartphoneGSMSIMEntry *, int, gpointer), gpointer data) { FreeSmartphoneGSMSIM *proxy; struct _sim_contacts_get_pack *pack; if (!callback) { g_warning("phoneui_utils_sim_contacts_get without a callback!"); return; } pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_sim(); g_message("Probing for contacts"); /* as we don't know the exact max index... we just cheat and assume there won't be SIMs with more than 1000 entries */ free_smartphone_gsm_sim_retrieve_phonebook(proxy, category, 1, 1000, _sim_retrieve_phonebook_callback, pack); } static void _sim_pb_info_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; int slots, number_length, name_length; struct _sim_pb_info_pack *pack = data; free_smartphone_gsm_sim_get_phonebook_info_finish ((FreeSmartphoneGSMSIM *)source, res, &slots, &number_length, &name_length, &error); pack->callback(error, slots, number_length, name_length, pack->data); if (error) { g_error_free(error); } g_object_unref(source); free(pack); } /* * Returns a GHashTable with the following values: * ("min_index", int:value) = lowest entry index for given phonebook on the SIM, * ("max_index", int:value) = highest entry index for given phonebook on the SIM, * ("number_length", int:value) = maximum length for the number, * ("name_length", int:value) = maximum length for the name. */ void phoneui_utils_sim_phonebook_info_get(const char *category, void (*callback) (GError *, int, int, int, gpointer), gpointer data) { FreeSmartphoneGSMSIM *proxy; struct _sim_pb_info_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_sim(); free_smartphone_gsm_sim_get_phonebook_info (proxy, category, _sim_pb_info_callback, pack); } static void _sim_contact_get_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; int count; FreeSmartphoneGSMSIMEntry *contacts; struct _sim_contact_get_pack *pack = data; contacts = free_smartphone_gsm_sim_retrieve_phonebook_finish ((FreeSmartphoneGSMSIM *)source, res, &count, &error); if (contacts) { pack->callback(error, contacts[0].name, contacts[0].number, pack->data); } else { pack->callback(error, NULL, NULL, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } /* * Gets phonebook entry with index */ void phoneui_utils_sim_phonebook_entry_get(const char *category, const int index, void (*callback) (GError *, const char *name, const char *number, gpointer), gpointer data) { FreeSmartphoneGSMSIM *proxy; struct _sim_contact_get_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_gsm_sim(); free_smartphone_gsm_sim_retrieve_phonebook (proxy, category, index, index, _sim_contact_get_callback, pack); } static void _pin_send_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _sim_pack *pack = data; free_smartphone_gsm_sim_send_auth_code_finish ((FreeSmartphoneGSMSIM *)source, res, &error); g_debug("_auth_send_callback(%s)", error ? "ERROR" : "OK"); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_debug("_auth_send_callback: (%d) %s", error->code, error->message); g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_sim_pin_send(const char *pin, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphoneGSMSIM *proxy; struct _sim_pack *pack; g_message("Trying PIN"); pack = malloc(sizeof(*pack)); pack->data = data; pack->callback = callback; proxy = _fso_gsm_sim(); free_smartphone_gsm_sim_send_auth_code (proxy, pin, _pin_send_callback, pack); } static void _puk_send_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _sim_pack *pack = data; free_smartphone_gsm_sim_unlock_finish ((FreeSmartphoneGSMSIM *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_warning("Sending PUK failed: (%d) %s", error->code, error->message); g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_sim_puk_send(const char *puk, const char *new_pin, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphoneGSMSIM *proxy; struct _sim_pack *pack; g_debug("Trying PUK"); pack = malloc(sizeof(*pack)); pack->data = data; pack->callback = callback; proxy = _fso_gsm_sim(); free_smartphone_gsm_sim_unlock (proxy, puk, new_pin, _puk_send_callback, pack); } static void _get_auth_status_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _sim_auth_status_pack *pack = data; FreeSmartphoneGSMSIMAuthStatus status; status = free_smartphone_gsm_sim_get_auth_status_finish ((FreeSmartphoneGSMSIM *)source, res, &error); if (pack->callback) { pack->callback(error, status, pack->data); } if (error) { g_critical("Failed to get SIMAuthStatus: (%d) %s", error->code, error->message); g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_sim_auth_status_get(void (*callback)(GError *, FreeSmartphoneGSMSIMAuthStatus, gpointer), gpointer data) { FreeSmartphoneGSMSIM *proxy; struct _sim_auth_status_pack *pack; pack = malloc(sizeof(*pack)); pack->data = data; pack->callback = callback; proxy = _fso_gsm_sim(); free_smartphone_gsm_sim_get_auth_status (proxy, _get_auth_status_callback, pack); } libphone-ui-0.0.1+git20110825/src/phoneui-utils-sim.h000066400000000000000000000040771162551416000216710ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_UTILS_SIM_H #define _PHONEUI_UTILS_SIM_H #include #include #define SIM_CONTACTS_CATEGORY "contacts" int phoneui_utils_sim_contact_delete(const char *category, const int index, void (*callback)(GError *, gpointer), gpointer data); int phoneui_utils_sim_contact_store(const char *category, int index, const char *name, const char *number, void (*callback) (GError *, gpointer), gpointer data); void phoneui_utils_sim_contacts_get(const char *category, void (*callback) (GError *, FreeSmartphoneGSMSIMEntry *, int, gpointer), gpointer data); void phoneui_utils_sim_phonebook_info_get(const char *category, void (*callback) (GError *, int, int, int, gpointer), gpointer data); void phoneui_utils_sim_phonebook_entry_get(const char *, const int index, void (*callback) (GError *, const char *name, const char *number, gpointer), gpointer data); void phoneui_utils_sim_pin_send(const char *pin, void (*callback)(GError *, gpointer), gpointer data); void phoneui_utils_sim_puk_send(const char *puk, const char *new_pin, void (*callback)(GError *, gpointer), gpointer data); void phoneui_utils_sim_auth_status_get(void (*callback)(GError *, FreeSmartphoneGSMSIMAuthStatus, gpointer), gpointer data); #endif libphone-ui-0.0.1+git20110825/src/phoneui-utils-sound.c000066400000000000000000000621471162551416000222260ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include #include #include "phoneui-utils-sound.h" #include "phoneui-info.h" #include "dbus.h" /* The sound state */ static enum SoundState sound_state = SOUND_STATE_IDLE; static enum SoundStateType sound_state_type = SOUND_STATE_TYPE_DEFAULT; static GSource *source_alsa_poll; /* This is the index of the current sound state */ #define STATE_INDEX calc_state_index(sound_state, sound_state_type) /* Controlling sound */ struct SoundControl { char *name; snd_hctl_elem_t *element; snd_hctl_elem_t *mute_element; long min; long max; unsigned int count; /*number of channels*/ }; /*This is a bit too big, but that's better for simplicity (because of sound_init and calc_state_index) - This value is also used in code. */ #define CONTROLS_LEN (SOUND_STATE_TYPE_NULL * SOUND_STATE_NULL) static struct SoundControl controls[CONTROLS_LEN][CONTROL_END]; static FreeSmartphoneDeviceAudio *fso_audio = NULL; /* The sound cards hardware control */ static snd_hctl_t *hctl = NULL; static void (*_phoneui_utils_sound_volume_changed_callback) (enum SoundControlType type, int volume, void *userdata); static void *_phoneui_utils_sound_volume_changed_userdata = NULL; static void (*_phoneui_utils_sound_volume_mute_changed_callback) (enum SoundControlType type, int mute, void *userdata); static void *_phoneui_utils_sound_volume_mute_changed_userdata = NULL; static int poll_fd_count = 0; static struct pollfd *poll_fds = NULL; static int _phoneui_utils_sound_volume_changed_cb(snd_hctl_elem_t *elem, unsigned int mask); static int _phoneui_utils_sound_volume_mute_changed_cb(snd_hctl_elem_t *elem, unsigned int mask); static void free_sound_control(struct SoundControl *ctl) { free(ctl->name); } int calc_state_index(enum SoundState state, enum SoundStateType type) { if (state == SOUND_STATE_IDLE) { switch (type) { case SOUND_STATE_TYPE_BLUETOOTH: case SOUND_STATE_TYPE_HANDSET: return ((state * SOUND_STATE_TYPE_NULL) + SOUND_STATE_TYPE_HANDSET); break; default: break; } } else if (state == SOUND_STATE_SPEAKER) { /* All are actually one */ return ((state * SOUND_STATE_TYPE_NULL) + SOUND_STATE_TYPE_HANDSET); } return ((state * SOUND_STATE_TYPE_NULL) + type); } static const char * scenario_name_from_state(enum SoundState state, enum SoundStateType type) { const char *scenario = ""; /* Should make it saner */ switch (state) { case SOUND_STATE_CALL: switch (type) { case SOUND_STATE_TYPE_HEADSET: scenario = "gsmheadset"; break; case SOUND_STATE_TYPE_HANDSET: scenario = "gsmhandset"; break; case SOUND_STATE_TYPE_BLUETOOTH: scenario = "gsmbluetooth"; break; default: g_critical("Unknown sound state type (%d), not saving. Please inform developers.\n", (int) type); break; } break; case SOUND_STATE_IDLE: switch (type) { case SOUND_STATE_TYPE_BLUETOOTH: case SOUND_STATE_TYPE_HANDSET: scenario = "stereoout"; break; case SOUND_STATE_TYPE_HEADSET: scenario = "headset"; break; default: g_critical("Unknown sound state type (%d), not saving. Please inform developers.\n", (int) type); break; } break; case SOUND_STATE_SPEAKER: scenario = "gsmspeaker"; break; default: g_critical("Unknown sound state (%d), not saving. Please inform developers.\n", (int) state); break; } return scenario; } static int _phoneui_utils_sound_volume_load_stats(struct SoundControl *control) { int err; if (!control->element) return -1; //snd_ctl_elem_type_t element_type; snd_ctl_elem_info_t *info; snd_hctl_elem_t *elem; elem = control->element; snd_ctl_elem_info_alloca(&info); err = snd_hctl_elem_info(elem, info); if (err < 0) { g_warning("%s", snd_strerror(err)); return -1; } /* verify type == integer */ //element_type = snd_ctl_elem_info_get_type(info); control->min = snd_ctl_elem_info_get_min(info); control->max = snd_ctl_elem_info_get_max(info); control->count = snd_ctl_elem_info_get_count(info); return 0; } long phoneui_utils_sound_volume_raw_get(enum SoundControlType type) { int err; long value; unsigned int i,count; snd_ctl_elem_value_t *control; snd_ctl_elem_value_alloca(&control); snd_hctl_elem_t *elem; count = controls[STATE_INDEX][type].count; elem = controls[STATE_INDEX][type].element; if (!elem || !count) { return 0; } err = snd_hctl_elem_read(elem, control); if (err < 0) { g_warning("%s", snd_strerror(err)); return -1; } value = 0; /* FIXME: possible long overflow */ for (i = 0 ; i < count ; i++) { value += snd_ctl_elem_value_get_integer(control, i); } value /= count; return value; } int phoneui_utils_sound_volume_get(enum SoundControlType type) { long value; long min, max; if (!controls[STATE_INDEX][type].element) { return 0; } min = controls[STATE_INDEX][type].min; max = controls[STATE_INDEX][type].max; value = phoneui_utils_sound_volume_raw_get(type); if (value <= min) { value = 0; } else if (value >= max) { value = 100; } else { value = ((double) (value - min) / (max - min)) * 100.0; } g_debug("Probing volume of control '%s' returned %d", controls[STATE_INDEX][type].name, (int) value); return value; } int phoneui_utils_sound_volume_raw_set(enum SoundControlType type, long value) { int err; unsigned int i, count; snd_hctl_elem_t *elem; snd_ctl_elem_value_t *control; elem = controls[STATE_INDEX][type].element; if (!elem) { return -1; } snd_ctl_elem_value_alloca(&control); count = controls[STATE_INDEX][type].count; for (i = 0 ; i < count ; i++) { snd_ctl_elem_value_set_integer(control, i, value); } err = snd_hctl_elem_write(elem, control); if (err) { g_warning("%s", snd_strerror(err)); return -1; } /* FIXME put it somewhere else, this is not the correct place! */ phoneui_utils_sound_volume_save(type); return 0; } int phoneui_utils_sound_volume_mute_get(enum SoundControlType type) { int err; snd_ctl_elem_value_t *control; snd_ctl_elem_value_alloca(&control); snd_hctl_elem_t *elem; elem = controls[STATE_INDEX][type].mute_element; if (!elem) { return -1; } err = snd_hctl_elem_read(elem, control); if (err < 0) { g_warning("%s", snd_strerror(err)); return -1; } return !snd_ctl_elem_value_get_boolean(control, 0); } int phoneui_utils_sound_volume_mute_set(enum SoundControlType type, int mute) { int err; snd_hctl_elem_t *elem; snd_ctl_elem_value_t *control; elem = controls[STATE_INDEX][type].mute_element; if (!elem) { return -1; } snd_ctl_elem_value_alloca(&control); snd_ctl_elem_value_set_boolean(control, 0, !mute); err = snd_hctl_elem_write(elem, control); if (err) { g_warning("%s", snd_strerror(err)); return -1; } g_debug("Set control %d to %d", type, mute); return 0; } int phoneui_utils_sound_volume_set(enum SoundControlType type, int percent) { long min, max, value; snd_hctl_elem_t *elem; snd_ctl_elem_value_t *control; elem = controls[STATE_INDEX][type].element; if (!elem) { return -1; } snd_ctl_elem_value_alloca(&control); min = controls[STATE_INDEX][type].min; max = controls[STATE_INDEX][type].max; value = min + ((max - min) * percent) / 100; phoneui_utils_sound_volume_raw_set(type, value); g_debug("Setting volume for control %s to %d", controls[STATE_INDEX][type].name, percent); return 0; } int phoneui_utils_sound_volume_save(enum SoundControlType type) { const char *scenario=""; (void) type; /*FIXME: when it's possible to save only type, use it*/ if (!fso_audio) { return -1; } scenario = scenario_name_from_state(sound_state, sound_state_type); /*FIXME: handle failures*/ free_smartphone_device_audio_save_scenario(fso_audio, scenario, NULL, NULL); return 0; } static snd_hctl_elem_t * _phoneui_utils_sound_init_get_control_by_name(const char *ctl_name) { snd_ctl_elem_id_t *id; snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); snd_ctl_elem_id_set_name(id, ctl_name); return snd_hctl_find_elem(hctl, id); } static void _phoneui_utils_sound_init_set_volume_control(enum SoundState state, enum SoundStateType type, enum SoundControlType control_type) { const char *ctl_name = controls[calc_state_index(state, type)][control_type].name; snd_hctl_elem_t *elem; /*if an empty string, return */ if (*ctl_name == '\0') { controls[calc_state_index(state, type)][control_type].element = NULL; return; } elem = controls[calc_state_index(state, type)][control_type].element = _phoneui_utils_sound_init_get_control_by_name(ctl_name); if (elem) { snd_hctl_elem_set_callback(elem, _phoneui_utils_sound_volume_changed_cb); } else { g_critical("ALSA: No control named '%s' found - " "Sound state: %d control type: %d", ctl_name, state, control_type); } } static void _phoneui_utils_sound_init_set_volume_mute_control(enum SoundState state, enum SoundStateType type, enum SoundControlType control_type, const char *ctl_name) { snd_hctl_elem_t *elem; /*if an empty string, return */ if (*ctl_name == '\0') { controls[calc_state_index(state, type)][control_type].mute_element = NULL; return; } elem = controls[calc_state_index(state, type)][control_type].mute_element = _phoneui_utils_sound_init_get_control_by_name(ctl_name); if (elem) { snd_hctl_elem_set_callback(elem, _phoneui_utils_sound_volume_mute_changed_cb); } else { g_critical("ALSA: No control named '%s' found - " "Sound state: %d type: %d", ctl_name, state, control_type); } } static void _phoneui_utils_sound_init_set_control(GKeyFile *keyfile, const char *_field, enum SoundState state, enum SoundStateType type) { char *field; char *speaker = NULL; char *microphone = NULL; char *speaker_mute = NULL; char *microphone_mute = NULL; int state_index = calc_state_index(state, type); if (controls[state_index][CONTROL_SPEAKER].name) { g_warning("Trying to allocate already allocated index %d.", state_index); return; } /*FIXME: split to a generic function for both speaker and microphone */ field = malloc(strlen(_field) + strlen("alsa_control_") + 1); if (field) { /* init for now and for the next if */ strcpy(field, "alsa_control_"); strcat(field, _field); speaker = g_key_file_get_string(keyfile, field, "speaker", NULL); microphone = g_key_file_get_string(keyfile, field, "microphone", NULL); speaker_mute = g_key_file_get_string(keyfile, field, "speaker_mute", NULL); microphone_mute = g_key_file_get_string(keyfile, field, "microphone_mute", NULL); /* does not yet free field because of the next if */ } if (!speaker) { g_message("No speaker value for %s found, using none", _field); speaker = strdup(""); } if (!microphone) { g_message("No microphone value for %s found, using none", _field); microphone = strdup(""); } controls[state_index][CONTROL_SPEAKER].mute_element = NULL; controls[state_index][CONTROL_MICROPHONE].mute_element = NULL; if (speaker_mute) { _phoneui_utils_sound_init_set_volume_mute_control(state, type, CONTROL_SPEAKER, speaker_mute); free(speaker_mute); } if (microphone_mute) { _phoneui_utils_sound_init_set_volume_mute_control(state, type, CONTROL_MICROPHONE, microphone_mute); free(microphone_mute); } controls[state_index][CONTROL_SPEAKER].name = speaker; controls[state_index][CONTROL_MICROPHONE].name = microphone; _phoneui_utils_sound_init_set_volume_control(state, type, CONTROL_SPEAKER); _phoneui_utils_sound_init_set_volume_control(state, type, CONTROL_MICROPHONE); /* Load min, max and count from alsa and init to zero before instead * of handling errors, hackish but fast. */ controls[state_index][CONTROL_SPEAKER].min = controls[state_index][CONTROL_SPEAKER].max = 0; controls[state_index][CONTROL_MICROPHONE].min = controls[state_index][CONTROL_MICROPHONE].max = 0; controls[state_index][CONTROL_MICROPHONE].count = 0; /* The function handles the case where the control has no element */ _phoneui_utils_sound_volume_load_stats(&controls[state_index][CONTROL_SPEAKER]); _phoneui_utils_sound_volume_load_stats(&controls[state_index][CONTROL_MICROPHONE]); if (field) { int tmp; /* If the user specifies his own min and max for that control, * check values for sanity and then apply them. */ if (g_key_file_has_key(keyfile, field, "microphone_min", NULL)) { tmp = g_key_file_get_integer(keyfile, field, "microphone_min", NULL); if (tmp > controls[state_index][CONTROL_MICROPHONE].min && tmp < controls[state_index][CONTROL_MICROPHONE].max) { controls[state_index][CONTROL_MICROPHONE].min = tmp; } } if (g_key_file_has_key(keyfile, field, "microphone_max", NULL)) { tmp = g_key_file_get_integer(keyfile, field, "microphone_max", NULL); if (tmp > controls[state][CONTROL_MICROPHONE].min && tmp < controls[state_index][CONTROL_MICROPHONE].max) { controls[state_index][CONTROL_MICROPHONE].max = tmp; } } if (g_key_file_has_key(keyfile, field, "speaker_min", NULL)) { tmp = g_key_file_get_integer(keyfile, field, "speaker_min", NULL); if (tmp > controls[state_index][CONTROL_SPEAKER].min && tmp < controls[state_index][CONTROL_SPEAKER].max) { controls[state_index][CONTROL_SPEAKER].min = tmp; g_debug("settisg speaker_min to %d", (int) tmp); } } if (g_key_file_has_key(keyfile, field, "speaker_max", NULL)) { tmp = g_key_file_get_integer(keyfile, field, "speaker_max", NULL); if (tmp > controls[state_index][CONTROL_SPEAKER].min && tmp < controls[state_index][CONTROL_SPEAKER].max) { controls[state_index][CONTROL_SPEAKER].max = tmp; } } free(field); } } static gboolean _sourcefunc_prepare(GSource *source, gint *timeout) { (void) source; (void) timeout; return (FALSE); } static gboolean _sourcefunc_check(GSource *source) { int f; (void) source; for (f = 0; f < poll_fd_count; f++) { if (poll_fds[f].revents & G_IO_IN) return (TRUE); } return (FALSE); } static gboolean _sourcefunc_dispatch(GSource *source, GSourceFunc callback, gpointer userdata) { (void) source; (void) callback; (void) userdata; snd_hctl_handle_events(hctl); return (TRUE); } static void _input_events_cb(void *error, const char *name, FreeSmartphoneDeviceInputState action, int duration) { (void) duration; if (error) { return; } if (!strcmp(name, "HEADSET")) { if (action == FREE_SMARTPHONE_DEVICE_INPUT_STATE_PRESSED) { g_message("Headset connected"); phoneui_utils_sound_state_set(SOUND_STATE_NULL, SOUND_STATE_TYPE_HEADSET); } else if (action == FREE_SMARTPHONE_DEVICE_INPUT_STATE_RELEASED) { g_message("Headset disconnected"); phoneui_utils_sound_state_set(SOUND_STATE_NULL, SOUND_STATE_TYPE_HANDSET); } } } int phoneui_utils_sound_init(GKeyFile *keyfile) { int err, f; char *device_name; static GSourceFuncs funcs = { _sourcefunc_prepare, _sourcefunc_check, _sourcefunc_dispatch, 0, 0, 0 }; sound_state = SOUND_STATE_IDLE; sound_state_type = SOUND_STATE_TYPE_DEFAULT; device_name = g_key_file_get_string(keyfile, "alsa", "hardware_control_name", NULL); if (!device_name) { g_message("No hw control found, using default"); device_name = strdup("hw:0"); } if (hctl) { snd_hctl_close(hctl); } err = snd_hctl_open(&hctl, device_name, 0); free(device_name); if (err) { g_critical("%s", snd_strerror(err)); return err; } err = snd_hctl_load(hctl); if (err) { g_critical("%s", snd_strerror(err)); } /*FIXME: add idle bt */ _phoneui_utils_sound_init_set_control(keyfile, "idle", SOUND_STATE_IDLE, SOUND_STATE_TYPE_HANDSET); _phoneui_utils_sound_init_set_control(keyfile, "bluetooth", SOUND_STATE_CALL, SOUND_STATE_TYPE_BLUETOOTH); _phoneui_utils_sound_init_set_control(keyfile, "handset", SOUND_STATE_CALL, SOUND_STATE_TYPE_HANDSET); _phoneui_utils_sound_init_set_control(keyfile, "headset", SOUND_STATE_CALL, SOUND_STATE_TYPE_HEADSET); _phoneui_utils_sound_init_set_control(keyfile, "speaker", SOUND_STATE_SPEAKER, SOUND_STATE_TYPE_HANDSET); snd_hctl_nonblock(hctl, 1); poll_fd_count = snd_hctl_poll_descriptors_count(hctl); poll_fds = malloc(sizeof(struct pollfd) * poll_fd_count); snd_hctl_poll_descriptors(hctl, poll_fds, poll_fd_count); source_alsa_poll = g_source_new(&funcs, sizeof(GSource)); for (f = 0; f < poll_fd_count; f++) { g_source_add_poll(source_alsa_poll, (GPollFD *)&poll_fds[f]); } g_source_attach(source_alsa_poll, NULL); /*Register for HEADPHONE insertion */ phoneui_info_register_input_events(_input_events_cb, NULL); fso_audio = (FreeSmartphoneDeviceAudio *)_fso (FREE_SMARTPHONE_DEVICE_TYPE_AUDIO_PROXY, FSO_FRAMEWORK_DEVICE_ServiceDBusName, FSO_FRAMEWORK_DEVICE_AudioServicePath, FSO_FRAMEWORK_DEVICE_AudioServiceFace); return err; } int phoneui_utils_sound_deinit() { int i, j; sound_state = SOUND_STATE_IDLE; sound_state_type = SOUND_STATE_TYPE_DEFAULT; /*FIXME: add freeing the controls array properly */ for (i = 0 ; i < CONTROLS_LEN ; i++) { for (j = 0 ; j < CONTROL_END ; j++) { if (controls[i][j].name) { /* Just a way to check if init, should probably change */ free_sound_control(&controls[i][j]); } } } snd_hctl_close(hctl); g_source_destroy(source_alsa_poll); free(poll_fds); poll_fd_count = 0; hctl = NULL; return 0; } int phoneui_utils_sound_state_set(enum SoundState state, enum SoundStateType type) { const char *scenario = NULL; /* if there's nothing to do, abort */ if (state == sound_state && type == sound_state_type) { return 0; } if (!fso_audio) { return -1; } /* If NULL use current */ if (state == SOUND_STATE_NULL) { state = sound_state; } if (type == SOUND_STATE_TYPE_NULL) { type = sound_state_type; } scenario = scenario_name_from_state(state, type); g_debug("Setting sound state to %s %d:%d", scenario, state, type); free_smartphone_device_audio_set_scenario(fso_audio, scenario, NULL, NULL); sound_state = state; sound_state_type = type; return 0; } enum SoundState phoneui_utils_sound_state_get() { return sound_state; } enum SoundStateType phoneui_utils_sound_state_type_get() { return sound_state_type; } static enum SoundControlType _phoneui_utils_sound_volume_element_to_type(snd_hctl_elem_t *elem) { int i; for (i = 0 ; i < CONTROL_END ; i++) { if (controls[STATE_INDEX][i].element == elem) { return i; } } return CONTROL_END; } static enum SoundControlType _phoneui_utils_sound_volume_mute_element_to_type(snd_hctl_elem_t *elem) { int i; for (i = 0 ; i < CONTROL_END ; i++) { if (controls[STATE_INDEX][i].mute_element == elem) { return i; } } return CONTROL_END; } static int _phoneui_utils_sound_volume_changed_cb(snd_hctl_elem_t *elem, unsigned int mask) { snd_ctl_elem_value_t *control; enum SoundControlType type; int volume; if (mask == SND_CTL_EVENT_MASK_REMOVE) return 0; if (mask & SND_CTL_EVENT_MASK_VALUE) { snd_ctl_elem_value_alloca(&control); snd_hctl_elem_read(elem, control); type = _phoneui_utils_sound_volume_element_to_type(elem); if (type != CONTROL_END) { volume = phoneui_utils_sound_volume_get(type); g_debug("Got alsa volume change for control '%s', new value: %d%%", controls[STATE_INDEX][type].name, volume); if (_phoneui_utils_sound_volume_changed_callback) { _phoneui_utils_sound_volume_changed_callback(type, volume, _phoneui_utils_sound_volume_changed_userdata); } } } return 0; } static int _phoneui_utils_sound_volume_mute_changed_cb(snd_hctl_elem_t *elem, unsigned int mask) { snd_ctl_elem_value_t *control; enum SoundControlType type; int mute; if (mask == SND_CTL_EVENT_MASK_REMOVE) return 0; if (mask & SND_CTL_EVENT_MASK_VALUE) { snd_ctl_elem_value_alloca(&control); snd_hctl_elem_read(elem, control); type = _phoneui_utils_sound_volume_mute_element_to_type(elem); if (type != CONTROL_END) { mute = phoneui_utils_sound_volume_mute_get(type); g_debug("Got alsa mute change for control type '%d', new value: %d", type, mute); if (_phoneui_utils_sound_volume_mute_changed_callback) { _phoneui_utils_sound_volume_mute_changed_callback(type, mute, _phoneui_utils_sound_volume_mute_changed_userdata); } } } return 0; } int phoneui_utils_sound_volume_change_callback_set(void (*cb)(enum SoundControlType, int, void *), void *userdata) { _phoneui_utils_sound_volume_changed_callback = cb; _phoneui_utils_sound_volume_changed_userdata = userdata; return 0; } int phoneui_utils_sound_volume_mute_change_callback_set(void (*cb)(enum SoundControlType, int, void *), void *userdata) { _phoneui_utils_sound_volume_mute_changed_callback = cb; _phoneui_utils_sound_volume_mute_changed_userdata = userdata; return 0; } struct _list_profiles_pack { void (*callback)(GError *, char **, int, gpointer); gpointer data; }; static void _list_profiles_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; int count; char **profiles; struct _list_profiles_pack *pack = data; profiles = free_smartphone_preferences_get_profiles_finish ((FreeSmartphonePreferences *)source, res, &count, &error); if (pack->callback) { pack->callback(error, profiles, count, pack->data); } // FIXME: free profiles free(pack); } void phoneui_utils_sound_profile_list(void (*callback)(GError *, char **, int, gpointer), void *userdata) { FreeSmartphonePreferences *proxy; struct _list_profiles_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _fso(FREE_SMARTPHONE_TYPE_PREFERENCES_PROXY, FSO_FRAMEWORK_PREFERENCES_ServiceDBusName, FSO_FRAMEWORK_PREFERENCES_ServicePathPrefix, FSO_FRAMEWORK_PREFERENCES_ServiceFacePrefix); free_smartphone_preferences_get_profiles (proxy, _list_profiles_callback, pack); } struct _set_profile_pack { void (*callback)(GError *, gpointer); gpointer data; }; static void _set_profile_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _set_profile_pack *pack = data; free_smartphone_preferences_set_profile_finish ((FreeSmartphonePreferences *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_critical("SetProfile error: (%d) %s", error->code, error->message); g_error_free(error); } else { g_debug("Profile successfully set"); } g_object_unref(source); free (pack); } void phoneui_utils_sound_profile_set(const char *profile, void (*callback)(GError *, gpointer), void *userdata) { (void) callback; (void) userdata; struct _set_profile_pack *pack; FreeSmartphonePreferences *proxy; g_debug("Setting profile to '%s'", profile); pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _fso(FREE_SMARTPHONE_TYPE_PREFERENCES_PROXY, FSO_FRAMEWORK_PREFERENCES_ServiceDBusName, FSO_FRAMEWORK_PREFERENCES_ServicePathPrefix, FSO_FRAMEWORK_PREFERENCES_ServiceFacePrefix); free_smartphone_preferences_set_profile(proxy, profile, _set_profile_callback, pack); } struct _get_profile_pack { FreeSmartphonePreferences *preferences; void (*callback)(GError *, char *, gpointer); gpointer data; }; static void _get_profile_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; char *profile; struct _get_profile_pack *pack = data; profile = free_smartphone_preferences_get_profile_finish ((FreeSmartphonePreferences *)source, res, &error); if (pack->callback) { pack->callback(error, profile, pack->data); } free(pack); } void phoneui_utils_sound_profile_get(void (*callback)(GError *, char *, gpointer), void *userdata) { FreeSmartphonePreferences *proxy; struct _get_profile_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _fso(FREE_SMARTPHONE_TYPE_PREFERENCES_PROXY, FSO_FRAMEWORK_PREFERENCES_ServiceDBusName, FSO_FRAMEWORK_PREFERENCES_ServicePathPrefix, FSO_FRAMEWORK_PREFERENCES_ServiceFacePrefix); free_smartphone_preferences_get_profile (proxy, _get_profile_callback, pack); } void phoneui_utils_sound_play(const char *name, int loop, int length, void (*callback)(GError *, gpointer), void *userdata) { (void) name; (void) loop; (void) length; (void) callback; (void) userdata; /*FIXME: stub*/ } void phoneui_utils_sound_stop(const char *name, void (*callback)(GError *, gpointer), void *userdata) { (void) name; (void) callback; (void) userdata; /*FIXME: stub*/ } libphone-ui-0.0.1+git20110825/src/phoneui-utils-sound.h000066400000000000000000000056521162551416000222310ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_UTILS_SOUND_H #define _PHONEUI_UTILS_SOUND_H #include enum SoundControlType { CONTROL_SPEAKER = 0, CONTROL_MICROPHONE, CONTROL_END /* used to mark end */ }; enum SoundState { SOUND_STATE_CALL = 0, SOUND_STATE_IDLE, SOUND_STATE_SPEAKER, SOUND_STATE_NULL /* MUST BE LAST */ }; enum SoundStateType { SOUND_STATE_TYPE_DEFAULT = 0, /*make HANDSET the default*/ SOUND_STATE_TYPE_HANDSET = 0, SOUND_STATE_TYPE_HEADSET, SOUND_STATE_TYPE_BLUETOOTH, SOUND_STATE_TYPE_NULL /* MUST BE LAST */ }; int phoneui_utils_sound_volume_get(enum SoundControlType type); long phoneui_utils_sound_volume_raw_get(enum SoundControlType type); int phoneui_utils_sound_volume_set(enum SoundControlType type, int percent); int phoneui_utils_sound_volume_raw_set(enum SoundControlType type, long value); int phoneui_utils_sound_volume_mute_get(enum SoundControlType type); int phoneui_utils_sound_volume_mute_set(enum SoundControlType type, int mute); int phoneui_utils_sound_volume_change_callback_set(void (*cb)(enum SoundControlType, int, void *), void *userdata); int phoneui_utils_sound_volume_mute_change_callback_set(void (*cb)(enum SoundControlType, int, void *), void *userdata); int phoneui_utils_sound_volume_save(enum SoundControlType type); int phoneui_utils_sound_init(GKeyFile *keyfile); int phoneui_utils_sound_deinit(); int phoneui_utils_sound_state_set(enum SoundState state, enum SoundStateType type); enum SoundState phoneui_utils_sound_state_get(); enum SoundStateType phoneui_utils_sound_state_type_get(); void phoneui_utils_sound_profile_list(void (*callback)(GError *, char **, int, gpointer), void *userdata); void phoneui_utils_sound_profile_set(const char *profile, void (*callback)(GError *, gpointer), void *userdata); void phoneui_utils_sound_profile_get(void (*callback)(GError *, char *, gpointer), void *userdata); void phoneui_utils_sound_play(const char *name, int loop, int length, void (*callback)(GError *, gpointer), void *userdata); void phoneui_utils_sound_stop(const char *name, void (*callback)(GError *, gpointer), void *userdata); #endif libphone-ui-0.0.1+git20110825/src/phoneui-utils.c000066400000000000000000001023071162551416000210710ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * Marco Trevisan (Treviño) * Thomas Zimmermann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include #include #include #include #include "phoneui.h" #include "phoneui-utils.h" #include "phoneui-utils-sound.h" #include "phoneui-utils-device.h" #include "phoneui-utils-feedback.h" #include "phoneui-utils-contacts.h" #include "phoneui-utils-messages.h" #include "dbus.h" #include "helpers.h" #define PIM_DOMAIN_PROXY(func) (void *(*)(DBusGConnection*, const char*, const char*)) func #define PIM_QUERY_FUNCTION(func) (void (*)(void *, GHashTable *, GAsyncReadyCallback, gpointer)) func #define PIM_QUERY_RESULTS(func) (void (*)(void *, int, GAsyncReadyCallback, gpointer)) func #define PIM_QUERY_RESULTS_FINISH(func) (GHashTable** (*)(void*, GAsyncResult*, int*, GError**)) func #define PIM_QUERY_COUNT(func) (void (*)(void *, GAsyncReadyCallback, gpointer)) func #define PIM_QUERY_PROXY(func) (void *(*)(DBusGConnection*, const char*, const char*)) func #define PIM_QUERY_DISPOSE(func) (void (*)(void *query, GAsyncReadyCallback, gpointer)) func struct _usage_pack { void (*callback)(GError *, gpointer); gpointer data; }; struct _usage_policy_pack { void (*callback)(GError *, FreeSmartphoneUsageResourcePolicy, gpointer); gpointer data; }; struct _idle_pack { void (*callback)(GError *, gpointer); gpointer data; }; struct _sms_send_pack { FreeSmartphoneGSMSMS *sms; FreeSmartphonePIMMessages *pim_messages; char *number; const char *message; char *pim_path; void (*callback)(GError *, int, const char *, gpointer); gpointer data; }; struct _query_pack { enum PhoneUiPimDomain domain_type; void *query; void (*callback)(GError *, GHashTable **, int, gpointer); gpointer data; }; struct _call_get_pack { FreeSmartphonePIMCall *call; void (*callback)(GError *, GHashTable *, gpointer); gpointer data; }; struct _pdp_pack { void (*callback)(GError *, gpointer); gpointer data; }; struct _pdp_credentials_pack { void (*callback)(GError *, const char *, const char *, const char *, gpointer); gpointer data; }; struct _network_pack { FreeSmartphoneNetwork *network; void (*callback)(GError *, gpointer); gpointer data; }; struct _get_offline_mode_pack { void (*callback)(GError *, gboolean, gpointer); gpointer data; }; struct _set_offline_mode_pack { void (*callback)(GError *, gpointer); gpointer data; }; struct _set_pin_pack { void (*callback)(GError *, gpointer); gpointer data; }; static gboolean request_message_receipt = FALSE; int phoneui_utils_init(GKeyFile *keyfile) { GError *error = NULL; request_message_receipt = g_key_file_get_integer(keyfile, "messages", "request_message_receipt", &error); if (error) { request_message_receipt = FALSE; g_error_free(error); } phoneui_utils_sound_init(keyfile); phoneui_utils_device_init(keyfile); phoneui_utils_feedback_init(keyfile); return 0; } void phoneui_utils_deinit() { /*FIXME: stub*/ phoneui_utils_sound_deinit(); } static void _pim_query_results_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; int count; GHashTable **results; GError *error = NULL; struct _query_pack *pack = data; switch (pack->domain_type) { case PHONEUI_PIM_DOMAIN_CALLS: results = free_smartphone_pim_call_query_get_multiple_results_finish ((FreeSmartphonePIMCallQuery *)source, res, &count, &error); free_smartphone_pim_call_query_dispose_ ((FreeSmartphonePIMCallQuery *)source, NULL, NULL); break; case PHONEUI_PIM_DOMAIN_CONTACTS: results = free_smartphone_pim_contact_query_get_multiple_results_finish ((FreeSmartphonePIMContactQuery *)source, res, &count, &error); free_smartphone_pim_contact_query_dispose_ ((FreeSmartphonePIMContactQuery *)source, NULL, NULL); break; case PHONEUI_PIM_DOMAIN_DATES: results = free_smartphone_pim_date_query_get_multiple_results_finish ((FreeSmartphonePIMDateQuery *)source, res, &count, &error); free_smartphone_pim_date_query_dispose_ ((FreeSmartphonePIMDateQuery *)source, NULL, NULL); break; case PHONEUI_PIM_DOMAIN_MESSAGES: results = free_smartphone_pim_message_query_get_multiple_results_finish ((FreeSmartphonePIMMessageQuery *)source, res, &count, &error); free_smartphone_pim_message_query_dispose_ ((FreeSmartphonePIMMessageQuery *)source, NULL, NULL); break; case PHONEUI_PIM_DOMAIN_NOTES: results = free_smartphone_pim_note_query_get_multiple_results_finish ((FreeSmartphonePIMNoteQuery *)source, res, &count, &error); free_smartphone_pim_note_query_dispose_ ((FreeSmartphonePIMNoteQuery *)source, NULL, NULL); break; /* FIXME, re-enable it when libfsoframework supports it again case PHONEUI_PIM_DOMAIN_TASKS: results = free_smartphone_pim_task_query_get_multiple_results_finish ((FreeSmartphonePIMTaskQuery *)source, res, &count, &error); free_smartphone_pim_task_query_dispose_ ((FreeSmartphonePIMTaskQuery *)source, NULL, NULL); break; */ default: g_object_unref(source); free(pack); return; } g_object_unref(source); g_debug("Query gave %d entries", count); if (pack->callback) { pack->callback(error, results, count, pack->data); } if (error) { g_error_free(error); } free(pack); } static void _pim_query_callback(GObject *source, GAsyncResult *res, gpointer data) { char *query_path = NULL; GError *error = NULL; struct _query_pack *pack = data; g_debug("_pim_query_callback"); switch (pack->domain_type) { case PHONEUI_PIM_DOMAIN_CALLS: query_path = free_smartphone_pim_calls_query_finish ((FreeSmartphonePIMCalls *)source, res, &error); break; case PHONEUI_PIM_DOMAIN_CONTACTS: query_path = free_smartphone_pim_contacts_query_finish ((FreeSmartphonePIMContacts *)source, res, &error); break; case PHONEUI_PIM_DOMAIN_DATES: query_path = free_smartphone_pim_dates_query_finish ((FreeSmartphonePIMDates *)source, res, &error); break; case PHONEUI_PIM_DOMAIN_MESSAGES: query_path = free_smartphone_pim_messages_query_finish ((FreeSmartphonePIMMessages *)source, res, &error); break; case PHONEUI_PIM_DOMAIN_NOTES: query_path = free_smartphone_pim_notes_query_finish ((FreeSmartphonePIMNotes *)source, res, &error); break; /* FIXME, re-enable it when libfsoframework supports it again case PHONEUI_PIM_DOMAIN_TASKS: query_path = free_smartphone_pim_tasks_query_finish ((FreeSmartphonePIMTasks *)source, res, &error); break; */ default: goto exit; } g_object_unref(source); if (error) { g_warning("Query error: (%d) %s", error->code, error->message); pack->callback(error, NULL, 0, pack->data); g_error_free(error); goto exit; } if (pack->domain_type == PHONEUI_PIM_DOMAIN_CALLS) { FreeSmartphonePIMCallQuery *proxy = _fso(FREE_SMARTPHONE_PIM_TYPE_CALL_QUERY_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, query_path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".CallQuery"); free_smartphone_pim_call_query_get_multiple_results (proxy, -1, _pim_query_results_callback, pack); } else if (pack->domain_type == PHONEUI_PIM_DOMAIN_CONTACTS) { FreeSmartphonePIMContactQuery *proxy = _fso(FREE_SMARTPHONE_PIM_TYPE_CONTACT_QUERY_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, query_path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".ContactQuery"); free_smartphone_pim_contact_query_get_multiple_results (proxy, -1, _pim_query_results_callback, pack); } else if (pack->domain_type == PHONEUI_PIM_DOMAIN_DATES) { FreeSmartphonePIMDateQuery *proxy = _fso(FREE_SMARTPHONE_PIM_TYPE_DATE_QUERY_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, query_path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".DateQuery"); free_smartphone_pim_date_query_get_multiple_results (proxy, -1, _pim_query_results_callback, pack); } else if (pack->domain_type == PHONEUI_PIM_DOMAIN_MESSAGES) { FreeSmartphonePIMMessageQuery *proxy = _fso(FREE_SMARTPHONE_PIM_TYPE_MESSAGE_QUERY_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, query_path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".MessageQuery"); free_smartphone_pim_message_query_get_multiple_results (proxy, -1, _pim_query_results_callback, pack); } else if (pack->domain_type == PHONEUI_PIM_DOMAIN_NOTES) { FreeSmartphonePIMNoteQuery *proxy = _fso(FREE_SMARTPHONE_PIM_TYPE_NOTE_QUERY_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, query_path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".NoteQuery"); free_smartphone_pim_note_query_get_multiple_results (proxy, -1, _pim_query_results_callback, pack); } /* FIXME, re-enable it when libfsoframework supports it again else if (pack->domain_type == PHONEUI_PIM_DOMAIN_TASKS) { FreeSmartphonePIMTaskQuery *proxy = _fso(FREE_SMARTPHONE_PIM_TYPE_TASK_QUERY_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, query_path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".TaskQuery"); free_smartphone_pim_task_query_get_multiple_results (proxy, -1, _pim_query_results_callback, pack); } */ if (query_path) free(query_path); return; exit: if (query_path) free(query_path); free(pack); } static void _pim_query_hashtable_clone_foreach_callback(void *k, void *v, void *data) { GHashTable *query = ((GHashTable *)data); char *key = (char *)k; GVariant *value = (GVariant *)v; if (key && key[0] != '_') { g_debug("adding key %s to query", key); g_hash_table_insert(query, strdup(key), g_variant_ref(value)); } } void phoneui_utils_pim_query(enum PhoneUiPimDomain domain, const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, gboolean resolve_number, const GHashTable *options, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data) { struct _query_pack *pack; GHashTable *query; GVariant *tmp; query = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _helpers_free_gvariant); if (!query) return; if (sortby && strlen(sortby)) { tmp = g_variant_new_string(sortby); g_hash_table_insert(query, strdup("_sortby"), g_variant_ref_sink(tmp)); } if (sortdesc) { tmp = g_variant_new_boolean(TRUE); g_hash_table_insert(query, strdup("_sortdesc"), g_variant_ref_sink(tmp)); } if (disjunction) { tmp = g_variant_new_boolean(TRUE); g_hash_table_insert(query, strdup("_at_least_one"), g_variant_ref_sink(tmp)); } if (resolve_number) { tmp = g_variant_new_boolean(TRUE); g_hash_table_insert(query, strdup("_resolve_phonenumber"), g_variant_ref_sink(tmp)); } tmp = g_variant_new_int32(limit_start); g_hash_table_insert(query, strdup("_limit_start"), g_variant_ref_sink(tmp)); tmp = g_variant_new_int32(limit); g_hash_table_insert(query, strdup("_limit"), g_variant_ref_sink(tmp)); if (options) { g_hash_table_foreach((GHashTable *)options, _pim_query_hashtable_clone_foreach_callback, query); } pack = malloc(sizeof(*pack)); pack->domain_type = domain; pack->callback = callback; pack->data = data; pack->query = NULL; g_debug("Done constructing PIM query"); if (domain == PHONEUI_PIM_DOMAIN_CALLS) { free_smartphone_pim_calls_query(_fso_pim_calls(), query, _pim_query_callback, pack); } else if (domain == PHONEUI_PIM_DOMAIN_CONTACTS) { free_smartphone_pim_contacts_query(_fso_pim_contacts(), query, _pim_query_callback, pack); } else if (domain == PHONEUI_PIM_DOMAIN_DATES) { free_smartphone_pim_dates_query(_fso_pim_dates(), query, _pim_query_callback, pack); } else if (domain == PHONEUI_PIM_DOMAIN_MESSAGES) { g_debug("starting the message query"); free_smartphone_pim_messages_query(_fso_pim_messages(), query, _pim_query_callback, pack); } else if (domain == PHONEUI_PIM_DOMAIN_NOTES) { free_smartphone_pim_notes_query(_fso_pim_notes(), query, _pim_query_callback, pack); } /* FIXME, re-enable it when libfsoframework supports it again else if (domain == PHONEUI_PIM_DOMAIN_TASKS) { free_smartphone_pim_tasks_query(_fso_pim_tasks(), query, _pim_query_callback, pack); }*/ else g_warning("unhandled PIM domain !!!"); g_debug("done... unrefing query"); g_hash_table_unref(query); } static void _write_config_value_boolean(const char *section, const char *name, gboolean value) { GError *error = NULL; GKeyFile *keyfile; GKeyFileFlags flags; gsize size; char *config_data; keyfile = g_key_file_new(); flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS; g_key_file_load_from_file(keyfile, PHONEUI_CONFIG, flags, &error); if (error) { g_message("failed loading the config to write [%s] %s: %s", section, name, error->message); g_error_free(error); return; } g_key_file_set_boolean(keyfile, section, name, value); config_data = g_key_file_to_data(keyfile, &size, &error); if (error) { g_message("could not convert config data to write [%s] %s: %s", section, name, error->message); g_error_free(error); return; } g_file_set_contents(PHONEUI_CONFIG, config_data, size, &error); if (error) { g_message("failed writing [%s] %s: %s", section, name, error->message); g_error_free(error); } if (config_data) g_free(config_data); if (keyfile) g_key_file_free(keyfile); } void phoneui_utils_set_message_receipt(gboolean _request_message_receipt) { request_message_receipt = _request_message_receipt; _write_config_value_boolean("messages", "request_message_receipt", request_message_receipt); } gboolean phoneui_utils_get_message_receipt(void) { return request_message_receipt; } static GHashTable * _create_opimd_message(const char *number, const char *message) { /* TODO: add timezone */ GHashTable *message_opimd = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, _helpers_free_gvariant); GVariant *tmp; tmp = g_variant_new_string(number); g_hash_table_insert(message_opimd, "Peer", g_variant_ref_sink(tmp)); tmp = g_variant_new_string("out"); g_hash_table_insert(message_opimd, "Direction", g_variant_ref_sink(tmp)); tmp = g_variant_new_string("SMS"); g_hash_table_insert(message_opimd, "Source", g_variant_ref_sink(tmp)); tmp = g_variant_new_string(message); g_hash_table_insert(message_opimd, "Content", g_variant_ref_sink(tmp)); tmp = g_variant_new_boolean(TRUE); g_hash_table_insert(message_opimd, "New", g_variant_ref_sink(tmp)); tmp = g_variant_new_int32(time(NULL)); g_hash_table_insert(message_opimd, "Timestamp", g_variant_ref_sink(tmp)); return message_opimd; } static void _sms_send_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; char *timestamp = NULL; struct _sms_send_pack *pack = data; int reference; free_smartphone_gsm_sms_send_text_message_finish(pack->sms, res, &reference, ×tamp, &error); if (pack->pim_path) { phoneui_utils_message_update_fields(pack->pim_path, NULL, 0, NULL, NULL, FALSE, NULL, reference, NULL, NULL); free(pack->pim_path); } if (pack->callback) { pack->callback(error, reference, timestamp, pack->data); } if (timestamp) { free(timestamp); } if (error) { g_warning("Error %d sending message: %s\n", error->code, error->message); g_error_free(error); } g_object_unref(pack->pim_messages); g_object_unref(pack->sms); free(pack->number); free(pack); } static void _opimd_message_added(GObject *source_object, GAsyncResult *res, gpointer user_data) { (void)source_object; struct _sms_send_pack *pack = user_data; char *msg_path = NULL; GError *error = NULL; /*FIXME: ATM it just saves it as saved and tell the user everything * is ok, even if it didn't save. We really need to fix that, * we should verify if glib's callbacks work */ msg_path = free_smartphone_pim_messages_add_finish(pack->pim_messages, res, &error); if (!error && msg_path) pack->pim_path = msg_path; else if (error) { g_warning("Error %d saving message: %s\n", error->code, error->message); g_error_free(error); /*TODO redirect the error to the send_text_message function, adding it * to the pack; then do the proper callback. */ } free_smartphone_gsm_sms_send_text_message(pack->sms, pack->number, pack->message, request_message_receipt, _sms_send_callback, pack); } static void _sms_message_send(struct _sms_send_pack *pack) { if (pack->pim_messages) { GHashTable *message_opimd = _create_opimd_message(pack->number, pack->message); free_smartphone_pim_messages_add(pack->pim_messages, message_opimd, _opimd_message_added, pack); g_hash_table_unref(message_opimd); } else { free_smartphone_gsm_sms_send_text_message(pack->sms, pack->number, pack->message, request_message_receipt, _sms_send_callback, pack); } } int phoneui_utils_sms_send(const char *message, GPtrArray * recipients, void (*callback) (GError *, int transaction_index, const char *timestamp, gpointer), gpointer data) { unsigned int i; struct _sms_send_pack *pack; FreeSmartphoneGSMSMS *sms; FreeSmartphonePIMMessages *pim_messages; GHashTable *properties; char *number; if (!recipients) { return 1; } sms = _fso(FREE_SMARTPHONE_GSM_TYPE_SMS_PROXY, FSO_FRAMEWORK_GSM_ServiceDBusName, FSO_FRAMEWORK_GSM_DeviceServicePath, FSO_FRAMEWORK_GSM_ServiceFacePrefix ".SMS"); pim_messages = _fso(FREE_SMARTPHONE_PIM_TYPE_MESSAGES_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, FSO_FRAMEWORK_PIM_MessagesServicePath, FSO_FRAMEWORK_PIM_MessagesServiceFace); /* cycle through all the recipients */ for (i = 0; i < recipients->len; i++) { properties = g_ptr_array_index(recipients, i); number = phoneui_utils_contact_display_phone_get(properties); phone_utils_remove_filler_chars(number); if (!number) { continue; } g_message("%d.\t%s", i + 1, number); pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; pack->sms = g_object_ref(sms); pack->pim_messages = g_object_ref(pim_messages); pack->pim_path = NULL; pack->message = message; pack->number = number; _sms_message_send(pack); } g_object_unref(sms); g_object_unref(pim_messages); return 0; } int phoneui_utils_resource_policy_set(enum PhoneUiResource resource, enum PhoneUiResourcePolicy policy) { (void) policy; switch (resource) { case PHONEUI_RESOURCE_GSM: break; case PHONEUI_RESOURCE_BLUETOOTH: break; case PHONEUI_RESOURCE_WIFI: break; case PHONEUI_RESOURCE_DISPLAY: break; case PHONEUI_RESOURCE_CPU: break; default: return 1; break; } return 0; } enum PhoneUiResourcePolicy phoneui_utils_resource_policy_get(enum PhoneUiResource resource) { switch (resource) { case PHONEUI_RESOURCE_GSM: break; case PHONEUI_RESOURCE_BLUETOOTH: break; case PHONEUI_RESOURCE_WIFI: break; case PHONEUI_RESOURCE_DISPLAY: break; case PHONEUI_RESOURCE_CPU: break; default: break; } return PHONEUI_RESOURCE_POLICY_ERROR; } void phoneui_utils_fields_types_get(void *callback, void *userdata) { /*FIXME stub*/ (void) callback; (void) userdata; return; } static void _suspend_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _usage_pack *pack = data; free_smartphone_usage_suspend_finish ((FreeSmartphoneUsage *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_usage_suspend(void (*callback) (GError *, gpointer), gpointer data) { FreeSmartphoneUsage *proxy; struct _usage_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_usage(); free_smartphone_usage_suspend(proxy, _suspend_callback, pack); } static void _shutdown_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _usage_pack *pack = data; free_smartphone_usage_shutdown_finish ((FreeSmartphoneUsage *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_usage_shutdown(void (*callback) (GError *, gpointer), gpointer data) { FreeSmartphoneUsage *proxy; struct _usage_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_usage(); free_smartphone_usage_shutdown(proxy, _shutdown_callback, pack); } static void _set_idle_state_callback(GObject *source, GAsyncResult *res, gpointer data) { (void) source; GError *error = NULL; struct _idle_pack *pack = data; free_smartphone_device_idle_notifier_set_state_finish ((FreeSmartphoneDeviceIdleNotifier *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_idle_set_state(FreeSmartphoneDeviceIdleState state, void (*callback) (GError *, gpointer), gpointer data) { FreeSmartphoneDeviceIdleNotifier *proxy; struct _idle_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso(FREE_SMARTPHONE_DEVICE_TYPE_IDLE_NOTIFIER_PROXY, FSO_FRAMEWORK_DEVICE_ServiceDBusName, FSO_FRAMEWORK_DEVICE_IdleNotifierServicePath"/0", FSO_FRAMEWORK_DEVICE_IdleNotifierServiceFace); free_smartphone_device_idle_notifier_set_state (proxy, state, _set_idle_state_callback, pack); } static void _get_policy_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; FreeSmartphoneUsageResourcePolicy policy; struct _usage_policy_pack *pack = data; policy = free_smartphone_usage_get_resource_policy_finish ((FreeSmartphoneUsage *)source, res, &error); pack->callback(error, policy, pack->data); if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_resources_get_resource_policy(const char *name, void (*callback) (GError *, FreeSmartphoneUsageResourcePolicy, gpointer), gpointer data) { FreeSmartphoneUsage *proxy; struct _usage_policy_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_usage(); free_smartphone_usage_get_resource_policy (proxy, name, _get_policy_callback, pack); } static void _set_policy_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _usage_pack *pack = data; free_smartphone_usage_set_resource_policy_finish ((FreeSmartphoneUsage *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_resources_set_resource_policy(const char *name, FreeSmartphoneUsageResourcePolicy policy, void (*callback) (GError *, gpointer), gpointer data) { FreeSmartphoneUsage *proxy; struct _usage_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso_usage(); free_smartphone_usage_set_resource_policy (proxy, name, policy, _set_policy_callback, pack); } void phoneui_utils_calls_query(const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, gboolean resolve_number, const GHashTable *options, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data) { phoneui_utils_pim_query(PHONEUI_PIM_DOMAIN_CALLS, sortby, sortdesc, disjunction, limit_start, limit, resolve_number, options, callback, data); } void phoneui_utils_calls_get_full(const char *sortby, gboolean sortdesc, int limit_start, int limit, gboolean resolve_number, const char *direction, int answered, void (*callback) (GError *, GHashTable **, int, gpointer), gpointer data) { GHashTable *qry = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, _helpers_free_gvariant); if (direction && (!strcmp(direction, "in") || !strcmp(direction, "out"))) { g_hash_table_insert(qry, "Direction", g_variant_ref_sink(g_variant_new_string(direction))); } if (answered > -1) { g_hash_table_insert(qry, "Answered", g_variant_ref_sink(g_variant_new_boolean(answered))); } phoneui_utils_calls_query(sortby, sortdesc, FALSE, limit_start, limit, resolve_number, qry, callback, data); g_hash_table_unref(qry); } void phoneui_utils_calls_get(int *count, void (*callback) (GError *, GHashTable **, int, gpointer), gpointer data) { int limit = (count && *count > 0) ? *count : -1; phoneui_utils_calls_get_full("Timestamp", TRUE, 0, limit, TRUE, NULL, -1, callback, data); } static void _call_get_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; GHashTable *content; struct _call_get_pack *pack = data; content = free_smartphone_pim_call_get_content_finish ((FreeSmartphonePIMCall *)source, res, &error); pack->callback(error, content, pack->data); if (error) { g_error_free(error); } if (content) { g_hash_table_unref(content); } g_object_unref(source); free(pack); } int phoneui_utils_call_get(const char *call_path, void (*callback)(GError *, GHashTable*, gpointer), gpointer data) { FreeSmartphonePIMCall *proxy; struct _call_get_pack *pack; pack = malloc(sizeof(*pack)); pack->data = data; pack->callback = callback; proxy = _fso(FREE_SMARTPHONE_PIM_TYPE_CALL_PROXY, FSO_FRAMEWORK_PIM_ServiceDBusName, call_path, FSO_FRAMEWORK_PIM_ServiceFacePrefix ".Call"); g_debug("Getting data of call with path: %s", call_path); free_smartphone_pim_call_get_content(proxy, _call_get_callback, pack); return (0); } static void _pdp_activate_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _pdp_pack *pack = data; free_smartphone_gsm_pdp_activate_context_finish ((FreeSmartphoneGSMPDP *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } static void _pdp_deactivate_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _pdp_pack *pack = data; free_smartphone_gsm_pdp_deactivate_context_finish ((FreeSmartphoneGSMPDP *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_pdp_activate_context(void (*callback)(GError *, gpointer), gpointer userdata) { FreeSmartphoneGSMPDP *proxy; struct _pdp_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _fso(FREE_SMARTPHONE_GSM_TYPE_PDP_PROXY, FSO_FRAMEWORK_GSM_ServiceDBusName, FSO_FRAMEWORK_GSM_DeviceServicePath, FSO_FRAMEWORK_GSM_DeviceServiceFace); free_smartphone_gsm_pdp_activate_context (proxy, _pdp_activate_callback, pack); } void phoneui_utils_pdp_deactivate_context(void (*callback)(GError *, gpointer), gpointer userdata) { FreeSmartphoneGSMPDP *proxy; struct _pdp_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _fso(FREE_SMARTPHONE_GSM_TYPE_PDP_PROXY, FSO_FRAMEWORK_GSM_ServiceDBusName, FSO_FRAMEWORK_GSM_DeviceServicePath, FSO_FRAMEWORK_GSM_DeviceServiceFace); free_smartphone_gsm_pdp_deactivate_context (proxy, _pdp_deactivate_callback, pack); } static void _pdp_get_credentials_cb(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _pdp_credentials_pack *pack = data; char *apn, *user, *pw; free_smartphone_gsm_pdp_get_credentials_finish ((FreeSmartphoneGSMPDP *)source, res, &apn, &user, &pw, &error); if (pack->callback) { pack->callback(error, apn, user, pw, pack->data); } if (error) { g_error_free(error); } g_object_unref(source); free(pack); } void phoneui_utils_pdp_get_credentials(void (*callback)(GError *, const char *, const char *, const char *, gpointer), gpointer data) { FreeSmartphoneGSMPDP *proxy; struct _pdp_credentials_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso(FREE_SMARTPHONE_GSM_TYPE_PDP_PROXY, FSO_FRAMEWORK_GSM_ServiceDBusName, FSO_FRAMEWORK_GSM_DeviceServicePath, FSO_FRAMEWORK_GSM_ServiceFacePrefix ".PDP"); free_smartphone_gsm_pdp_get_credentials (proxy, _pdp_get_credentials_cb, pack); } static void _network_start_sharing_cb(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _network_pack *pack = data; free_smartphone_network_start_connection_sharing_with_interface_finish ((FreeSmartphoneNetwork *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } g_object_unref(source); } void phoneui_utils_network_start_connection_sharing(const char *iface, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphoneNetwork *proxy; struct _network_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso(FREE_SMARTPHONE_TYPE_NETWORK_PROXY, FSO_FRAMEWORK_NETWORK_ServiceDBusName, FSO_FRAMEWORK_NETWORK_ServicePathPrefix, FSO_FRAMEWORK_NETWORK_ServiceFacePrefix); free_smartphone_network_start_connection_sharing_with_interface (proxy, iface, _network_start_sharing_cb, pack); } static void _network_stop_sharing_cb(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _network_pack *pack = data; free_smartphone_network_stop_connection_sharing_with_interface_finish ((FreeSmartphoneNetwork *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } } void phoneui_utils_network_stop_connection_sharing(const char *iface, void (*callback)(GError *, gpointer), gpointer data) { FreeSmartphoneNetwork *proxy; struct _network_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = data; proxy = _fso(FREE_SMARTPHONE_TYPE_NETWORK_PROXY, FSO_FRAMEWORK_NETWORK_ServiceDBusName, FSO_FRAMEWORK_NETWORK_ServicePathPrefix, FSO_FRAMEWORK_NETWORK_ServiceFacePrefix); free_smartphone_network_stop_connection_sharing_with_interface (proxy, iface, _network_stop_sharing_cb, pack); } static void _get_offline_mode_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _get_offline_mode_pack *pack = data; gboolean offline; phonefso_usage_call_get_offline_mode_finish ((PhonefsoUsage *)source, &offline, res, &error); if (pack->callback) { pack->callback(error, offline, pack->data); } if (error) g_error_free(error); free(pack); } void phoneui_utils_get_offline_mode(void (*callback)(GError *, gboolean, gpointer), gpointer userdata) { PhonefsoUsage *proxy; struct _get_offline_mode_pack *pack; GError *error = NULL; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _phonefso(&error); if (error) { callback(error, FALSE, userdata); g_error_free(error); return; } phonefso_usage_call_get_offline_mode (proxy, NULL, _get_offline_mode_callback, pack); } static void _set_offline_mode_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _set_offline_mode_pack *pack = data; phonefso_usage_call_set_offline_mode_finish ((PhonefsoUsage *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) g_error_free(error); free(pack); } void phoneui_utils_set_offline_mode(gboolean offline, void (*callback)(GError *, gpointer), gpointer userdata) { PhonefsoUsage *proxy; GError *error = NULL; struct _set_offline_mode_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _phonefso(&error); if (error) { callback(error, userdata); g_error_free(error); return; } phonefso_usage_call_set_offline_mode (proxy, offline, NULL, _set_offline_mode_callback, pack); } static void _set_pin_callback(GObject *source, GAsyncResult *res, gpointer data) { GError *error = NULL; struct _set_pin_pack *pack = data; phonefso_usage_call_set_pin_finish((PhonefsoUsage *)source, res, &error); if (pack->callback) { pack->callback(error, pack->data); } if (error) g_error_free(error); free(pack); } void phoneui_utils_set_pin(const char *pin, gboolean save, void (*callback)(GError *, gpointer), gpointer userdata) { (void) save; PhonefsoUsage *proxy; GError *error = NULL; struct _set_pin_pack *pack; pack = malloc(sizeof(*pack)); pack->callback = callback; pack->data = userdata; proxy = _phonefso(&error); if (error) { callback(error, userdata); g_error_free(error); return; } phonefso_usage_call_set_pin(proxy, pin, NULL, _set_pin_callback, pack); } libphone-ui-0.0.1+git20110825/src/phoneui-utils.h000066400000000000000000000127061162551416000211010ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * Marco Trevisan (Treviño) * Thomas Zimmermann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_UTILS_H #define _PHONEUI_UTILS_H #include #include #include #include "phoneui-utils-sound.h" enum PhoneUiDialogType { PHONEUI_DIALOG_ERROR_DO_NOT_USE = 0, // This value is used for checking if we get a wrong pointer out of a HashTable. // So do not use it, and leave it first in this enum. ( because 0 == NULL ) PHONEUI_DIALOG_MESSAGE_STORAGE_FULL, PHONEUI_DIALOG_SIM_NOT_PRESENT }; enum PhoneuiSimStatus { PHONEUI_SIM_UNKNOWN, PHONEUI_SIM_READY, PHONEUI_SIM_PIN_REQUIRED, PHONEUI_SIM_PUK_REQUIRED, PHONEUI_SIM_PIN2_REQUIRED, PHONEUI_SIM_PUK2_REQUIRED }; enum PhoneUiResource { PHONEUI_RESOURCE_GSM, PHONEUI_RESOURCE_BLUETOOTH, PHONEUI_RESOURCE_WIFI, PHONEUI_RESOURCE_DISPLAY, PHONEUI_RESOURCE_CPU, PHONEUI_RESOURCE_END /* must be last */ }; enum PhoneUiResourcePolicy { PHONEUI_RESOURCE_POLICY_ERROR, PHONEUI_RESOURCE_POLICY_DISABLED, PHONEUI_RESOURCE_POLICY_ENABLED, PHONEUI_RESOURCE_POLICY_AUTO }; enum PhoneUiDeviceIdleState { PHONEUI_DEVICE_IDLE_STATE_BUSY, PHONEUI_DEVICE_IDLE_STATE_IDLE, PHONEUI_DEVICE_IDLE_STATE_IDLE_DIM, PHONEUI_DEVICE_IDLE_STATE_PRELOCK, PHONEUI_DEVICE_IDLE_STATE_LOCK, PHONEUI_DEVICE_IDLE_STATE_SUSPEND, PHONEUI_DEVICE_IDLE_STATE_AWAKE }; enum PhoneUiPimDomain { PHONEUI_PIM_DOMAIN_CALLS, PHONEUI_PIM_DOMAIN_CONTACTS, PHONEUI_PIM_DOMAIN_DATES, PHONEUI_PIM_DOMAIN_MESSAGES, PHONEUI_PIM_DOMAIN_NOTES, PHONEUI_PIM_DOMAIN_TASKS, }; void phoneui_utils_pim_query(enum PhoneUiPimDomain, const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, gboolean resolve_number, const GHashTable *options, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data); gchar *phoneui_utils_get_user_home_prefix(); gchar *phoneui_utils_get_user_home_code(); void phoneui_utils_set_message_receipt(gboolean _request_message_receipt); gboolean phoneui_utils_get_message_receipt(void); int phoneui_utils_sms_send(const char *message, GPtrArray * recipients, void (*callback) (GError *, int transaction_index, const char *timestamp, gpointer), void *userdata); void phoneui_utils_fields_types_get(void *callback, void *userdata); void phoneui_utils_usage_suspend(void (*callback) (GError *, gpointer), void *userdata); void phoneui_utils_usage_shutdown(void (*callback) (GError *, gpointer), void *userdata); void phoneui_utils_idle_set_state(FreeSmartphoneDeviceIdleState state, void (*callback) (GError *, gpointer), gpointer userdata); void phoneui_utils_resources_get_resource_policy(const char *name, void (*callback) (GError *, FreeSmartphoneUsageResourcePolicy, gpointer), gpointer userdata); void phoneui_utils_resources_set_resource_policy(const char *name, FreeSmartphoneUsageResourcePolicy policy, void (*callback) (GError *, gpointer), gpointer userdata); void phoneui_utils_calls_query(const char *sortby, gboolean sortdesc, gboolean disjunction, int limit_start, int limit, gboolean resolve_number, const GHashTable *options, void (*callback)(GError *, GHashTable **, int, gpointer), gpointer data); void phoneui_utils_calls_get_full(const char *sortby, gboolean sortdesc, int limit_start, int limit, gboolean resolve_number, const char *direction, int answered, void (*callback) (GError *, GHashTable **, int, gpointer), gpointer data); void phoneui_utils_calls_get(int *count, void (*callback) (GError *, GHashTable **, int, gpointer), void *_data); int phoneui_utils_call_get(const char *call_path, void (*callback)(GError *, GHashTable*, gpointer), void *data); void phoneui_utils_set_offline_mode(gboolean onoff, void (*callback)(GError *, gpointer userdata), gpointer userdata); void phoneui_utils_get_offline_mode(void (*callback)(GError *, gboolean, gpointer userdata), gpointer userdata); void phoneui_utils_pdp_activate_context(void (*callback)(GError *, gpointer userdata), gpointer userdata); void phoneui_utils_pdp_deactivate_context(void (*callback)(GError *, gpointer userdata), gpointer userdata); void phoneui_utils_pdp_get_credentials(void (*callback)(GError *, const char *, const char *, const char *, gpointer), gpointer data); void phoneui_utils_set_pin(const char *pin, gboolean save, void (*callback)(GError *, gpointer), gpointer userdata); void phoneui_utils_network_start_connection_sharing(const char *iface, void (*callback)(GError *, gpointer), gpointer data); void phoneui_utils_network_stop_connection_sharing(const char *iface, void (*callback)(GError *, gpointer), gpointer data); int phoneui_utils_init(GKeyFile *keyfile); void phoneui_utils_deinit(); #endif libphone-ui-0.0.1+git20110825/src/phoneui.c000066400000000000000000000301641162551416000177340ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * Maksim 'max_posedon' Melnikau * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #include #include #include #include #include #include #include #include "phoneui.h" #include "phoneui-info.h" #include "phoneui-utils-sound.h" /* How to add another function: * add a CONNECT_HELPER line to phoneui_connect * add a declaration just below this comment * add a function wrapper at the end of this file (using PHONEUI_FUNCTION_CONTENT) * add the function declaration to phoneui.h(.in) */ #define CONNECT_HELPER(name, type) _phoneui_ ## name = \ phoneui_get_function("phoneui_backend_" #name, \ backends[type].library) #define PHONEUI_FUNCTION_CONTENT(name, ...) \ if (_phoneui_ ## name) \ _phoneui_ ## name (__VA_ARGS__); \ else \ g_warning("can't find function %s", __FUNCTION__); /* Calls */ static void (*_phoneui_incoming_call_show) (const int id, const int status, const char *number) = NULL; static void (*_phoneui_incoming_call_hide) (const int id) = NULL; static void (*_phoneui_outgoing_call_show) (const int id, const int status, const char *number) = NULL; static void (*_phoneui_outgoing_call_hide) (const int id) = NULL; /* Contacts */ static void (*_phoneui_contacts_show) () = NULL; static void (*_phoneui_contacts_contact_show) (const char *path) = NULL; static void (*_phoneui_contacts_contact_new) (GHashTable *values) = NULL; static void (*_phoneui_contacts_contact_edit) (const char *path) = NULL; /* Messages */ static void (*_phoneui_messages_show) () = NULL; static void (*_phoneui_messages_message_show) (const char *path) = NULL; static void (*_phoneui_messages_message_new) (GHashTable *options) = NULL; /* Dialer */ static void (*_phoneui_dialer_show) () = NULL; /* Notifications */ static void (*_phoneui_dialog_show) (const int type) = NULL; static void (*_phoneui_sim_auth_show) (const int status) = NULL; static void (*_phoneui_sim_auth_hide) (const int status) = NULL; static void (*_phoneui_ussd_show) (int mode, const char *message) = NULL; /* Quick Settings */ static void (*_phoneui_quick_settings_show) () = NULL; static void (*_phoneui_quick_settings_hide) () = NULL; /* Idle Screen */ static void (*_phoneui_idle_screen_show) () = NULL; static void (*_phoneui_idle_screen_hide) () = NULL; static void (*_phoneui_idle_screen_toggle) () = NULL; /* Phone Log */ static void (*_phoneui_phone_log_show) () = NULL; static void (*_phoneui_phone_log_hide) () = NULL; /* SIM Manager */ static void (*_phoneui_sim_manager_show) () = NULL; static void (*_phoneui_sim_manager_hide) () = NULL; /* got to be in the same order as in the backends array */ enum BackendType { BACKEND_DIALER = 0, BACKEND_MESSAGES, BACKEND_CONTACTS, BACKEND_CALLS, BACKEND_PHONELOG, BACKEND_NOTIFICATION, BACKEND_IDLE_SCREEN, BACKEND_SETTINGS, BACKEND_NO /* must be last, means the null */ }; struct BackendInfo { void *library; const char *name; }; static struct BackendInfo backends[] = { {NULL, "dialer"}, {NULL, "messages"}, {NULL, "contacts"}, {NULL, "calls"}, {NULL, "phonelog"}, {NULL, "notification"}, {NULL, "idle_screen"}, {NULL, "settings"}, {NULL, NULL} }; static void phoneui_connect(); static void phoneui_load_backend(GKeyFile *keyfile, enum BackendType type) { char *library; library = g_key_file_get_string(keyfile, backends[type].name, "module", NULL); /* Load library */ if (library) { /*FIXME: drop the hardcoded .so*/ char *library_path = malloc(strlen(library) + strlen(".so") + strlen(PHONEUI_MODULES_PATH) + 1); if (!library_path) { g_error("Loading %s failed, no memory", library); } strcpy(library_path, PHONEUI_MODULES_PATH); strcat(library_path, library); strcat(library_path, ".so"); backends[type].library = dlopen(library_path, RTLD_LOCAL | RTLD_LAZY); if (!backends[type].library) { g_error("Loading %s failed: %s", library_path, dlerror()); } free(library); free(library_path); } else { g_error("Loading failed. library not set."); } } void phoneui_load(const char *application_name) { g_message("Loading %s", application_name); int i; GKeyFile *keyfile; GKeyFileFlags flags; GError *error = NULL; keyfile = g_key_file_new(); flags = G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS; if (!g_key_file_load_from_file (keyfile, PHONEUI_CONFIG, flags, &error)) { g_error("%s", error->message); return; } for (i = 0 ; i < BACKEND_NO ; i++) { phoneui_load_backend(keyfile, i); } phoneui_connect(); /* init phone utils */ /*FIXME: should be in init, does it cause problems?*/ phone_utils_init(); phoneui_utils_init(keyfile); g_key_file_free(keyfile); } void * phoneui_get_function(const char *name, void *phoneui_library) { if (phoneui_library == NULL) { g_error("phoneui library not loaded"); } void *pointer = dlsym(phoneui_library, name); char *error; if ((error = dlerror()) != NULL) { g_warning("Symbol not found: %s", error); } return pointer; } static void phoneui_connect() { CONNECT_HELPER(incoming_call_show, BACKEND_CALLS); CONNECT_HELPER(incoming_call_hide, BACKEND_CALLS); CONNECT_HELPER(outgoing_call_show, BACKEND_CALLS); CONNECT_HELPER(outgoing_call_hide, BACKEND_CALLS); CONNECT_HELPER(contacts_show, BACKEND_CONTACTS); CONNECT_HELPER(contacts_contact_show, BACKEND_CONTACTS); CONNECT_HELPER(contacts_contact_new, BACKEND_CONTACTS); CONNECT_HELPER(contacts_contact_edit, BACKEND_CONTACTS); CONNECT_HELPER(dialer_show, BACKEND_DIALER); CONNECT_HELPER(dialog_show, BACKEND_NOTIFICATION); CONNECT_HELPER(messages_show, BACKEND_MESSAGES); CONNECT_HELPER(messages_message_show, BACKEND_MESSAGES); CONNECT_HELPER(messages_message_new, BACKEND_MESSAGES); CONNECT_HELPER(sim_auth_show, BACKEND_NOTIFICATION); CONNECT_HELPER(sim_auth_hide, BACKEND_NOTIFICATION); CONNECT_HELPER(ussd_show, BACKEND_NOTIFICATION); CONNECT_HELPER(quick_settings_show, BACKEND_SETTINGS); CONNECT_HELPER(quick_settings_hide, BACKEND_SETTINGS); CONNECT_HELPER(sim_manager_show, BACKEND_SETTINGS); CONNECT_HELPER(sim_manager_hide, BACKEND_SETTINGS); CONNECT_HELPER(idle_screen_show, BACKEND_IDLE_SCREEN); CONNECT_HELPER(idle_screen_hide, BACKEND_IDLE_SCREEN); CONNECT_HELPER(idle_screen_toggle, BACKEND_IDLE_SCREEN); CONNECT_HELPER(phone_log_show, BACKEND_PHONELOG); CONNECT_HELPER(phone_log_hide, BACKEND_PHONELOG); } static void _phoneui_backend_init(int argc, char **argv, void (*exit_cb) (), enum BackendType type) { void (*_phoneui_init) (int argc, char **argv, void (*exit_cb) ()); _phoneui_init = phoneui_get_function("phoneui_backend_init", backends[type].library); if (_phoneui_init) _phoneui_init(argc, argv, exit_cb); else g_warning("can't find function %s", __FUNCTION__); } static void _phoneui_backend_deinit(enum BackendType type) { void (*_phoneui_deinit) (); _phoneui_deinit = phoneui_get_function("phoneui_backend_deinit", backends[type].library); if (_phoneui_deinit) _phoneui_deinit(); else g_warning("can't find function %s", __FUNCTION__); } static void _phoneui_backend_loop(enum BackendType type) { void (*_phoneui_loop) (); _phoneui_loop = phoneui_get_function("phoneui_backend_loop", backends[type].library); if (_phoneui_loop) _phoneui_loop(); else g_warning("can't find function %s", __FUNCTION__); } /* Implementation prototypes */ void phoneui_init(int argc, char **argv, void (*exit_cb) ()) { /* the hash table is used to make sure we only init one backend once */ int i; GHashTable *inits; inits = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); for (i = 0 ; i < BACKEND_NO ; i++) { if (!g_hash_table_lookup(inits, backends[i].library)) { /* FIXME: the char * is a cast hack, since we won't change the content anyway */ g_hash_table_insert(inits, backends[i].library, (char *) backends[i].name); _phoneui_backend_init(argc, argv, exit_cb, i); } } g_hash_table_destroy(inits); phoneui_info_init(); } void phoneui_deinit() { /* the hash table is used to make sure we only init one backend once */ int i; GHashTable *inits; inits = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, NULL); for (i = 0 ; i < BACKEND_NO ; i++) { if (!g_hash_table_lookup(inits, backends[i].library)) { /* FIXME: the char * is a cast hack, since we won't change the content anyway */ g_hash_table_insert(inits, backends[i].library, (char *) backends[i].name); _phoneui_backend_deinit(i); } } g_hash_table_destroy(inits); phoneui_info_deinit(); phoneui_utils_deinit(); phone_utils_deinit(); } void phoneui_loop() { #if 0 int i; for (i = 0 ; i < BACKEND_NO ; i++) { _phoneui_backend_loop(i); } #else /* FIXME: until we add support for threads, run only one loop */ _phoneui_backend_loop(BACKEND_CALLS); #endif } /* Calls */ void phoneui_incoming_call_show(const int id, const int status, const char *number) { PHONEUI_FUNCTION_CONTENT(incoming_call_show, id, status, number); } void phoneui_incoming_call_hide(const int id) { PHONEUI_FUNCTION_CONTENT(incoming_call_hide, id); } void phoneui_outgoing_call_show(const int id, const int status, const char *number) { PHONEUI_FUNCTION_CONTENT(outgoing_call_show, id, status, number); } void phoneui_outgoing_call_hide(const int id) { PHONEUI_FUNCTION_CONTENT(outgoing_call_hide, id); } /* Contacts */ void phoneui_contacts_show() { PHONEUI_FUNCTION_CONTENT(contacts_show); } void phoneui_contacts_contact_show(const char *contact_path) { PHONEUI_FUNCTION_CONTENT(contacts_contact_show, contact_path); } void phoneui_contacts_contact_new(GHashTable *values) { PHONEUI_FUNCTION_CONTENT(contacts_contact_new, values); } void phoneui_contacts_contact_edit(const char *contact_path) { PHONEUI_FUNCTION_CONTENT(contacts_contact_edit, contact_path); } /* Messages */ void phoneui_messages_show() { PHONEUI_FUNCTION_CONTENT(messages_show); } void phoneui_messages_message_show(const char *path) { PHONEUI_FUNCTION_CONTENT(messages_message_show, path); } void phoneui_messages_message_new(GHashTable *options) { PHONEUI_FUNCTION_CONTENT(messages_message_new, options); } /* Dialer */ void phoneui_dialer_show() { PHONEUI_FUNCTION_CONTENT(dialer_show); } /* Notifications */ void phoneui_dialog_show(const int type) { PHONEUI_FUNCTION_CONTENT(dialog_show, type); } void phoneui_sim_auth_show(const int status) { PHONEUI_FUNCTION_CONTENT(sim_auth_show, status); } void phoneui_sim_auth_hide(const int status) { PHONEUI_FUNCTION_CONTENT(sim_auth_hide, status); } void phoneui_ussd_show(int mode, const char *message) { PHONEUI_FUNCTION_CONTENT(ussd_show, mode, message); } /* Quick Settings */ void phoneui_quick_settings_show() { PHONEUI_FUNCTION_CONTENT(quick_settings_show); } void phoneui_quick_settings_hide() { PHONEUI_FUNCTION_CONTENT(quick_settings_hide); } /* Idle Screen */ void phoneui_idle_screen_show() { PHONEUI_FUNCTION_CONTENT(idle_screen_show); } void phoneui_idle_screen_hide() { PHONEUI_FUNCTION_CONTENT(idle_screen_hide); } void phoneui_idle_screen_toggle() { PHONEUI_FUNCTION_CONTENT(idle_screen_toggle); } /* Phone Log */ void phoneui_phone_log_show() { PHONEUI_FUNCTION_CONTENT(phone_log_show); } void phoneui_phone_log_hide() { PHONEUI_FUNCTION_CONTENT(phone_log_hide); } /* SIM Manager */ void phoneui_sim_manager_show() { PHONEUI_FUNCTION_CONTENT(sim_manager_show); } void phoneui_sim_manager_hide() { PHONEUI_FUNCTION_CONTENT(sim_manager_hide); } libphone-ui-0.0.1+git20110825/src/phoneui.h.in000066400000000000000000000054551162551416000203530ustar00rootroot00000000000000/* * Copyright (C) 2009, 2010 * Authors (alphabetical) : * Tom "TAsn" Hacohen * Klaus 'mrmoku' Kurzmann * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 */ #ifndef _PHONEUI_H #define _PHONEUI_H #include #include #include "phoneui-utils.h" #define PHONEUI_CONFIG "@SYSCONFDIR@/libphoneui.conf" #define PHONEUI_MODULES_PATH "@LIBDIR@/phoneui/modules/" enum PhoneuiCallState { PHONEUI_CALL_STATE_INCOMING = 0, PHONEUI_CALL_STATE_OUTGOING, PHONEUI_CALL_STATE_ACTIVE, PHONEUI_CALL_STATE_HELD, PHONEUI_CALL_STATE_RELEASE }; void phoneui_load(const char *application_name); void *phoneui_get_function(const char *name, void *phoneui_library); /* Implementation prototypes */ void phoneui_init(int argc, char **argv, void (*exit_cb) ()); void phoneui_deinit(); void phoneui_loop(); /* Calls */ void phoneui_incoming_call_show(const int id, const int status, const char *number); void phoneui_incoming_call_hide(const int id); void phoneui_outgoing_call_show(const int id, const int status, const char *number); void phoneui_outgoing_call_hide(const int id); /* Contacts */ void phoneui_contacts_show(); void phoneui_contacts_contact_show(const char *contact_path); void phoneui_contacts_contact_new(GHashTable *values); void phoneui_contacts_contact_edit(const char *contact_path); /* Messages */ void phoneui_messages_show(); void phoneui_messages_message_show(const char *path); void phoneui_messages_message_new(GHashTable *options); /* Dialer */ void phoneui_dialer_show(); /* Notifications */ void phoneui_dialog_show(const int type); void phoneui_sim_auth_show(const int status); void phoneui_sim_auth_hide(const int status); void phoneui_ussd_show(int mode, const char *message); /* Quick settings */ void phoneui_quick_settings_show(); void phoneui_quick_settings_hide(); /* Idle Screen */ void phoneui_idle_screen_show(); void phoneui_idle_screen_hide(); void phoneui_idle_screen_toggle(); /* Phone Log */ void phoneui_phone_log_show(); void phoneui_phone_log_hide(); /* SIM Manager */ void phoneui_sim_manager_show(); void phoneui_sim_manager_hide(); #endif