diff options
39 files changed, 2171 insertions, 1125 deletions
@@ -1,675 +1,502 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 - Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + 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. - 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. +[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. - - 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 +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. - 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 + 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 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. - - <one line to give the program's name and a brief idea of what it does.> +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. + + <one line to give the library's name and a brief idea of what it does.> Copyright (C) <year> <name of author> - 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 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 program is distributed in the hope that it will be useful, + 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 General Public License for more details. + 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 General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. + 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. - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: +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: - <program> Copyright (C) <year> <name of author> - 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. + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. -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 -<http://www.gnu.org/licenses/>. - - 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 -<http://www.gnu.org/philosophy/why-not-lgpl.html>. + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice +That's all there is to it! diff --git a/Makefile.am b/Makefile.am index 727f4ea..056d414 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = gfbgraph tests +SUBDIRS = gfbgraph docs tests ACLOCAL_AMFLAGS = -I m4 libgfbgraphdocdir = ${prefix}/doc/libgfbgraph @@ -0,0 +1,61 @@ +================= +LibGFBGraph 0.2.3 +================= + +The major update in this version is the support fo the version 2.3 of +the Facebook Graph API. + +The changes include: + +- The tests has been improved to use the Facebook test API + (creating a test user). +- A node now can be linked to other (if allowed). This allow to + publish data to Facebook! For the moment just albums and photos. +- Bug #752380 Updated the API of Facebook Graph to version 2.3 due + deprecation of 1.0. +- The documentation has been polished and now respect parallel + installations. + +================= +LibGFBGraph 0.2.2 +================= + +Now with development documentation thanks to gtk-doc! + +Also the node base class includes the modification date. + +================= +LibGFBGraph 0.2.1 +================= + +This release is centered in a better control of the photos given by the +Facebook Graph API in order a better integration in GNOME Photos. + +Now it's possible to: + +- Get all the available sizes of a given photo. +- Get the higher resolution image available of a photo. +- Get the available image with a width or height nearest a given number.. + +Also, the introspection annotations has been enhanced. + +=============== +LibGFBGraph 0.2 +=============== + +Just releasing under LGPG v2.1 + +=============== +LibGFBGraph 0.1 +=============== + +This is the first release of GFBGraph library. + +With this library you can get: + + * a user node, knowing his node ID, + * the "me" user node. + * all albums owned by a user. + * all the photos in an album, and download the image default size. + +This version has a poor documentation and comes with a non-tested introspection. @@ -1,9 +1,5 @@ -ATENTION! - -This proyect was moved to the GNOME Git: https://git.gnome.org/browse/libgfbgraph. - -GFBGraph -============== +LibGFBGraph +=========== A GObject library for Facebook Graph API @@ -8,6 +8,14 @@ test -n "$srcdir" || srcdir=. olddir=`pwd` cd "$srcdir" +GTKDOCIZE=`which gtkdocize` +if test -z $GTKDOCIZE; then + echo "*** No GTK-Doc found, please install it ***" + exit 1 +else + gtkdocize || exit $? +fi + ACLOCAL="${ACLOCAL-aclocal} $ACLOCAL_FLAGS" autoreconf -v -i cd "$olddir" diff --git a/configure.ac b/configure.ac index 8a4f447..fd1231f 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,12 @@ m4_define([api_major], [0]) -m4_define([api_minor], [1]) +m4_define([api_minor], [2]) +m4_define([api_micro], [4]) -m4_define([gfbgraph_version], [api_major.api_minor]) +m4_define([gfbgraph_version], [api_major.api_minor.api_micro]) AC_PREREQ([2.63]) AC_INIT([gfbgraph], [gfbgraph_version], - [], + [https://bugzilla.gnome.org/enter_bug.cgi?product=gfbgraph], [gfbgraph], [https://github.com/alvaropg/libgfbgraph.git]) @@ -30,6 +31,13 @@ AC_PROG_CC LT_INIT +# check for gtk-doc +m4_ifdef([GTK_DOC_CHECK], [ +GTK_DOC_CHECK([1.14],[--flavour no-tmpl]) +],[ +AM_CONDITIONAL([ENABLE_GTK_DOC], false) +]) + GOBJECT_INTROSPECTION_CHECK([1.30.0]) PKG_CHECK_MODULES(LIBGFBGRAPH, [glib-2.0 gio-2.0 gobject-2.0 rest-0.7 json-glib-1.0]) @@ -45,5 +53,9 @@ AC_SUBST(GOA_API_CHANGE_CPPFLAGS) AC_OUTPUT([ Makefile libgfbgraph.pc +docs/Makefile +docs/reference/Makefile +docs/reference/apiversion.xml +docs/reference/version.xml gfbgraph/Makefile tests/Makefile]) diff --git a/docs/Makefile.am b/docs/Makefile.am new file mode 100644 index 0000000..034926c --- /dev/null +++ b/docs/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = reference + +-include $(top_srcdir)/git.mk diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am new file mode 100644 index 0000000..2707479 --- /dev/null +++ b/docs/reference/Makefile.am @@ -0,0 +1,105 @@ +## Process this file with automake to produce Makefile.in + +# We require automake 1.6 at least. +AUTOMAKE_OPTIONS = 1.6 + +# This is a blank Makefile.am for using gtk-doc. +# Copy this to your project's API docs directory and modify the variables to +# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples +# of using the various options. + +# The name of the module, e.g. 'glib'. +DOC_MODULE=gfbgraph + +# Uncomment for versioned docs and specify the version of the module, e.g. '2'. +DOC_MODULE_VERSION=@API_VERSION@ + + +# The top-level XML file (SGML in the past). You can change this if you want to. +DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml + +# Directories containing the source code. +# gtk-doc will search all .c and .h files beneath these paths +# for inline comments documenting functions and macros. +# e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk +DOC_SOURCE_DIR=$(top_srcdir)/gfbgraph + +# Extra options to pass to gtkdoc-scangobj. Not normally needed. +SCANGOBJ_OPTIONS= + +# Extra options to supply to gtkdoc-scan. +# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED" +SCAN_OPTIONS= + +# Extra options to supply to gtkdoc-mkdb. +# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml +MKDB_OPTIONS=--xml-mode --output-format=xml + +# Extra options to supply to gtkdoc-mktmpl +# e.g. MKTMPL_OPTIONS=--only-section-tmpl +MKTMPL_OPTIONS= + +# Extra options to supply to gtkdoc-mkhtml +MKHTML_OPTIONS= + +# Extra options to supply to gtkdoc-fixref. Not normally needed. +# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html +FIXXREF_OPTIONS= + +# Used for dependencies. The docs will be rebuilt if any of these change. +# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h +# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c +HFILE_GLOB=$(top_srcdir)/gfbgraph/*.h +CFILE_GLOB=$(top_srcdir)/gfbgraph/*.c + +# Extra header to include when scanning, which are not under DOC_SOURCE_DIR +# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h +EXTRA_HFILES= + +# Header files or dirs to ignore when scanning. Use base file/dir names +# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code +IGNORE_HFILES= + +# Images to copy into HTML directory. +# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png +HTML_IMAGES= + +# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE). +# e.g. content_files=running.sgml building.sgml changes-2.0.sgml +content_files= + +# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded +# These files must be listed here *and* in content_files +# e.g. expand_content_files=running.sgml +expand_content_files= + +# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library. +# Only needed if you are using gtkdoc-scangobj to dynamically query widget +# signals and properties. +# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS) +# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib) +GTKDOC_CFLAGS= +GTKDOC_LIBS=$(top_builddir)/gfbgraph/libgfbgraph-@API_VERSION@.la + +# This includes the standard gtk-doc make rules, copied by gtkdocize. +include $(top_srcdir)/gtk-doc.make + +# Other files to distribute +# e.g. EXTRA_DIST += version.xml.in +EXTRA_DIST += version.xml.in + +# Files not to distribute +# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types +# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt +#DISTCLEANFILES += + +# Comment this out if you want 'make check' to test you doc status +# and run some sanity checks +if ENABLE_GTK_DOC +TESTS_ENVIRONMENT = \ + DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \ + SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir) +#TESTS = $(GTKDOC_CHECK) +endif + +-include $(top_srcdir)/git.mk diff --git a/docs/reference/apiversion.xml.in b/docs/reference/apiversion.xml.in new file mode 100644 index 0000000..379630b --- /dev/null +++ b/docs/reference/apiversion.xml.in @@ -0,0 +1 @@ +@API_VERSION@ diff --git a/docs/reference/gfbgraph-docs.xml b/docs/reference/gfbgraph-docs.xml new file mode 100644 index 0000000..fb18578 --- /dev/null +++ b/docs/reference/gfbgraph-docs.xml @@ -0,0 +1,90 @@ +<?xml version="1.0"?> +<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" +[ + <!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'"> + <!ENTITY version SYSTEM "version.xml"> + <!ENTITY apiversion SYSTEM "apiversion.xml"> +]> +<book id="index"> + <bookinfo> + <title>GFBGraph &apiversion; Reference Manual</title> + <releaseinfo>Version &version;</releaseinfo> + <authorgroup> + <author> + <firstname>Álvaro</firstname> + <surname>Peña</surname> + <affiliation> + <address> + <email>alvaropg@gmail.org</email> + </address> + </affiliation> + </author> + </authorgroup> + + <copyright> + <year>2013</year> + <holder>The GFBGraph authors</holder> + </copyright> + + <legalnotice> + <para> + Permission is granted to copy, distribute and/or modify this + document under the terms of the <citetitle>GNU Free + Documentation License</citetitle>, Version 1.1 or any later + version published by the Free Software Foundation with no + Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. You may obtain a copy of the <citetitle>GNU Free + Documentation License</citetitle> from the Free Software + Foundation by visiting + <ulink type="http" url="http://www.fsf.org">their Web site + </ulink> or by writing to: + <address> + <street>51 Franklin Street</street>, Fifth Floor + <city>Boston</city>, + <state>MA</state> + <postcode>02110-1335</postcode> + <country>USA</country> + </address> + </para> + </legalnotice> + </bookinfo> + + <chapter> + <title>Authorization</title> + <xi:include href="xml/gfbgraph-authorizer.xml"/> + <xi:include href="xml/gfbgraph-simple-authorizer.xml"/> + <xi:include href="xml/gfbgraph-goa-authorizer.xml"/> + </chapter> + + <chapter> + <title>Nodes</title> + <xi:include href="xml/gfbgraph-album.xml"/> + <xi:include href="xml/gfbgraph-connectable.xml"/> + <xi:include href="xml/gfbgraph-node.xml"/> + <xi:include href="xml/gfbgraph-photo.xml"/> + <xi:include href="xml/gfbgraph-user.xml"/> + </chapter> + + <chapter> + <title>Other</title> + <xi:include href="xml/gfbgraph-common.xml"/> + </chapter> + + <chapter id="object-tree"> + <title>Object Hierarchy</title> + <xi:include href="xml/tree_index.sgml"/> + </chapter> + + <index id="api-index-full"> + <title>API Index</title> + <xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include> + </index> + + <index id="deprecated-api-index" role="deprecated"> + <title>Index of deprecated API</title> + <xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include> + </index> + + <xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include> +</book> diff --git a/docs/reference/gfbgraph-sections.txt b/docs/reference/gfbgraph-sections.txt new file mode 100644 index 0000000..2b8da6b --- /dev/null +++ b/docs/reference/gfbgraph-sections.txt @@ -0,0 +1,176 @@ +<SECTION> +<FILE>gfbgraph-album</FILE> +<TITLE>GFBGraphAlbum</TITLE> +GFBGraphAlbum +GFBGraphAlbumClass +gfbgraph_album_new +gfbgraph_album_new_from_id +gfbgraph_album_get_name +gfbgraph_album_get_description +gfbgraph_album_get_cover_photo_id +gfbgraph_album_get_count +<SUBSECTION Standard> +GFBGRAPH_ALBUM +GFBGRAPH_ALBUM_CLASS +GFBGRAPH_ALBUM_GET_CLASS +GFBGRAPH_IS_ALBUM +GFBGRAPH_IS_ALBUM_CLASS +GFBGRAPH_TYPE_ALBUM +GFBGraphAlbumPrivate +gfbgraph_album_get_type +</SECTION> + +<SECTION> +<FILE>gfbgraph-authorizer</FILE> +<TITLE>GFBGraphAuthorizer</TITLE> +GFBGraphAuthorizerInterface +gfbgraph_authorizer_process_call +gfbgraph_authorizer_process_message +gfbgraph_authorizer_refresh_authorization +<SUBSECTION Standard> +GFBGRAPH_AUTHORIZER +GFBGRAPH_AUTHORIZER_GET_IFACE +GFBGRAPH_IS_AUTHORIZER +GFBGRAPH_TYPE_AUTHORIZER +gfbgraph_authorizer_get_type +</SECTION> + +<SECTION> +<FILE>gfbgraph-common</FILE> +gfbgraph_new_rest_call +</SECTION> + +<SECTION> +<FILE>gfbgraph-connectable</FILE> +<TITLE>GFBGraphConnectable</TITLE> +GFBGraphConnectableInterface +gfbgraph_connectable_get_connection_post_params +gfbgraph_connectable_parse_connected_data +gfbgraph_connectable_is_connectable_to +gfbgraph_connectable_get_connection_path +gfbgraph_connectable_default_parse_connected_data +<SUBSECTION Standard> +GFBGRAPH_CONNECTABLE +GFBGRAPH_CONNECTABLE_CLASS +GFBGRAPH_CONNECTABLE_GET_IFACE +GFBGRAPH_IS_CONNECTABLE +GFBGRAPH_TYPE_CONNECTABLE +gfbgraph_connectable_get_type +</SECTION> + +<SECTION> +<FILE>gfbgraph-goa-authorizer</FILE> +<TITLE>GFBGraphGoaAuthorizer</TITLE> +GFBGraphGoaAuthorizer +GFBGraphGoaAuthorizerClass +gfbgraph_goa_authorizer_new +<SUBSECTION Standard> +GFBGRAPH_GOA_AUTHORIZER +GFBGRAPH_GOA_AUTHORIZER_CLASS +GFBGRAPH_GOA_AUTHORIZER_GET_CLASS +GFBGRAPH_IS_GOA_AUTHORIZER +GFBGRAPH_IS_GOA_AUTHORIZER_CLASS +GFBGRAPH_TYPE_GOA_AUTHORIZER +GFBGraphGoaAuthorizerPrivate +gfbgraph_goa_authorizer_get_type +</SECTION> + +<SECTION> +<FILE>gfbgraph-node</FILE> +<TITLE>GFBGraphNode</TITLE> +GFBGRAPH_NODE_ERROR +GFBGraphNode +GFBGraphNodeClass +GFBGraphNodeError +gfbgraph_node_error_quark +gfbgraph_node_new +gfbgraph_node_new_from_id +gfbgraph_node_get_id +gfbgraph_node_get_link +gfbgraph_node_get_created_time +gfbgraph_node_get_updated_time +gfbgraph_node_get_connection_nodes +gfbgraph_node_get_connection_nodes_async +gfbgraph_node_get_connection_nodes_async_finish +gfbgraph_node_append_connection +<SUBSECTION Standard> +GFBGRAPH_IS_NODE +GFBGRAPH_IS_NODE_CLASS +GFBGRAPH_NODE +GFBGRAPH_NODE_CLASS +GFBGRAPH_NODE_GET_CLASS +GFBGRAPH_TYPE_NODE +GFBGraphNodePrivate +gfbgraph_node_get_type +</SECTION> + +<SECTION> +<FILE>gfbgraph-photo</FILE> +<TITLE>GFBGraphPhoto</TITLE> +GFBGraphPhoto +GFBGraphPhotoClass +GFBGraphPhotoImage +gfbgraph_photo_new +gfbgraph_photo_new_from_id +gfbgraph_photo_download_default_size +gfbgraph_photo_get_name +gfbgraph_photo_get_default_source_uri +gfbgraph_photo_get_default_width +gfbgraph_photo_get_default_height +gfbgraph_photo_get_images +gfbgraph_photo_get_image_hires +gfbgraph_photo_get_image_near_width +gfbgraph_photo_get_image_near_height +<SUBSECTION Standard> +GFBGRAPH_IS_PHOTO +GFBGRAPH_IS_PHOTO_CLASS +GFBGRAPH_PHOTO +GFBGRAPH_PHOTO_CLASS +GFBGRAPH_PHOTO_GET_CLASS +GFBGRAPH_TYPE_PHOTO +GFBGraphPhotoPrivate +gfbgraph_photo_get_type +</SECTION> + +<SECTION> +<FILE>gfbgraph-simple-authorizer</FILE> +<TITLE>GFBGraphSimpleAuthorizer</TITLE> +GFBGraphSimpleAuthorizer +GFBGraphSimpleAuthorizerClass +gfbgraph_simple_authorizer_new +<SUBSECTION Standard> +GFBGRAPH_IS_SIMPLE_AUTHORIZER +GFBGRAPH_IS_SIMPLE_AUTHORIZER_CLASS +GFBGRAPH_SIMPLE_AUTHORIZER +GFBGRAPH_SIMPLE_AUTHORIZER_CLASS +GFBGRAPH_SIMPLE_AUTHORIZER_GET_CLASS +GFBGRAPH_TYPE_SIMPLE_AUTHORIZER +GFBGraphSimpleAuthorizerPrivate +gfbgraph_simple_authorizer_get_type +</SECTION> + +<SECTION> +<FILE>gfbgraph-user</FILE> +<TITLE>GFBGraphUser</TITLE> +GFBGraphUser +GFBGraphUserClass +gfbgraph_user_new +gfbgraph_user_new_from_id +gfbgraph_user_get_me +gfbgraph_user_get_me_async +gfbgraph_user_get_me_async_finish +gfbgraph_user_get_albums +gfbgraph_user_get_albums_async +gfbgraph_user_get_albums_async_finish +gfbgraph_user_get_name +<SUBSECTION Standard> +GFBGRAPH_IS_USER +GFBGRAPH_IS_USER_CLASS +GFBGRAPH_TYPE_USER +GFBGRAPH_USER +GFBGRAPH_USER_CLASS +GFBGRAPH_USER_GET_CLASS +GFBGraphUserPrivate +gfbgraph_user_get_type +</SECTION> + diff --git a/docs/reference/gfbgraph.types b/docs/reference/gfbgraph.types new file mode 100644 index 0000000..a20c799 --- /dev/null +++ b/docs/reference/gfbgraph.types @@ -0,0 +1,8 @@ +gfbgraph_album_get_type +gfbgraph_authorizer_get_type +gfbgraph_connectable_get_type +gfbgraph_goa_authorizer_get_type +gfbgraph_node_get_type +gfbgraph_photo_get_type +gfbgraph_simple_authorizer_get_type +gfbgraph_user_get_type diff --git a/docs/reference/version.xml.in b/docs/reference/version.xml.in new file mode 100644 index 0000000..d78bda9 --- /dev/null +++ b/docs/reference/version.xml.in @@ -0,0 +1 @@ +@VERSION@ diff --git a/gfbgraph/gfbgraph-album.c b/gfbgraph/gfbgraph-album.c index b3b5d8c..f280f11 100644 --- a/gfbgraph/gfbgraph-album.c +++ b/gfbgraph/gfbgraph-album.c @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -69,21 +69,21 @@ G_DEFINE_TYPE_WITH_CODE (GFBGraphAlbum, gfbgraph_album, GFBGRAPH_TYPE_NODE, static void gfbgraph_album_init (GFBGraphAlbum *obj) { - obj->priv = GFBGRAPH_ALBUM_GET_PRIVATE(obj); + obj->priv = GFBGRAPH_ALBUM_GET_PRIVATE(obj); } static void gfbgraph_album_class_init (GFBGraphAlbumClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); + parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = gfbgraph_album_finalize; + gobject_class->finalize = gfbgraph_album_finalize; gobject_class->set_property = gfbgraph_album_set_property; gobject_class->get_property = gfbgraph_album_get_property; - g_type_class_add_private (gobject_class, sizeof(GFBGraphAlbumPrivate)); + g_type_class_add_private (gobject_class, sizeof(GFBGraphAlbumPrivate)); /** * GFBGraphAlbum:name: @@ -138,7 +138,7 @@ gfbgraph_album_class_init (GFBGraphAlbumClass *klass) static void gfbgraph_album_finalize (GObject *obj) { - G_OBJECT_CLASS(parent_class)->finalize (obj); + G_OBJECT_CLASS(parent_class)->finalize (obj); } static void @@ -234,12 +234,12 @@ gfbgraph_album_get_connection_post_params (GFBGraphConnectable *self, GType node * * Creates a new #GFBGraphAlbum. * - * Returns: (transfer full): a new #GFBGraphAlbum; unref with g_object_unref() + * Returns: (transfer full): a new #GFBGraphAlbum; unref with g_object_unref() **/ GFBGraphAlbum* gfbgraph_album_new (void) { - return GFBGRAPH_ALBUM (g_object_new(GFBGRAPH_TYPE_ALBUM, NULL)); + return GFBGRAPH_ALBUM (g_object_new(GFBGRAPH_TYPE_ALBUM, NULL)); } /** @@ -257,3 +257,95 @@ gfbgraph_album_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GEr { return GFBGRAPH_ALBUM (gfbgraph_node_new_from_id (authorizer, id, GFBGRAPH_TYPE_ALBUM, error)); } + +/** + * gfbgraph_album_get_name: + * @album: a #GFBGraphAlbum. + * + * Returns: (transfer none): the @album name, or %NULL. + **/ +const gchar* +gfbgraph_album_get_name (GFBGraphAlbum *album) +{ + g_return_val_if_fail (GFBGRAPH_IS_ALBUM (album), NULL); + + return album->priv->name; +} + +/** + * gfbgraph_album_get_description: + * @album: a #GFBGraphAlbum. + * + * Returns: (transfer none): the @album description, or %NULL. + **/ +const gchar* +gfbgraph_album_get_description (GFBGraphAlbum *album) +{ + g_return_val_if_fail (GFBGRAPH_IS_ALBUM (album), NULL); + + return album->priv->description; +} + +/** + * gfbgraph_album_get_cover_photo: + * @album: a #GFBGraphAlbum. + * + * Returns: (transfer none): the cover photo node ID or %NULL. + **/ +const gchar* +gfbgraph_album_get_cover_photo_id (GFBGraphAlbum *album) +{ + g_return_val_if_fail (GFBGRAPH_IS_ALBUM (album), NULL); + + return album->priv->cover_photo; +} + +/** + * gfbgraph_album_get_count: + * @album: a #GFBGraphAlbum. + * + * Returns: (transfer none): the number of photos into the @album or -1 in case of error. + **/ +guint +gfbgraph_album_get_count (GFBGraphAlbum *album) +{ + g_return_val_if_fail (GFBGRAPH_IS_ALBUM (album), -1); + + return album->priv->count; +} + +/** + * gfbgraph_album_set_name: + * @album: a #GFBGraphAlbum. + * @name: a const pointer to a #gchar. + * + * Sets the name for the @album. + **/ +void +gfbgraph_album_set_name (GFBGraphAlbum *album, const gchar *name) +{ + g_return_if_fail (GFBGRAPH_IS_ALBUM (album)); + g_return_if_fail (name != NULL); + + g_object_set (G_OBJECT (album), + "name", name, + NULL); +} + +/** + * gfbgraph_album_set_description: + * @album: a #GFBGraphAlbum. + * @description: a const pointer to a #gchar. + * + * Sets the description for the @album. + **/ +void +gfbgraph_album_set_description (GFBGraphAlbum *album, const gchar *description) +{ + g_return_if_fail (GFBGRAPH_IS_ALBUM (album)); + g_return_if_fail (description != NULL); + + g_object_set (G_OBJECT (album), + "description", description, + NULL); +} diff --git a/gfbgraph/gfbgraph-album.h b/gfbgraph/gfbgraph-album.h index c78202a..88eb0c2 100644 --- a/gfbgraph/gfbgraph-album.h +++ b/gfbgraph/gfbgraph-album.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_ALBUM_H__ @@ -51,6 +51,14 @@ GType gfbgraph_album_get_type (void) G_GNUC_CONST; GFBGraphAlbum* gfbgraph_album_new (void); GFBGraphAlbum* gfbgraph_album_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GError **error); +const gchar* gfbgraph_album_get_name (GFBGraphAlbum *album); +const gchar* gfbgraph_album_get_description (GFBGraphAlbum *album); +const gchar* gfbgraph_album_get_cover_photo_id (GFBGraphAlbum *album); +guint gfbgraph_album_get_count (GFBGraphAlbum *album); + +void gfbgraph_album_set_name (GFBGraphAlbum *album, const gchar *name); +void gfbgraph_album_set_description (GFBGraphAlbum *album, const gchar *description); + G_END_DECLS #endif /* __GFBGRAPH_ALBUM_H__ */ diff --git a/gfbgraph/gfbgraph-authorizer.c b/gfbgraph/gfbgraph-authorizer.c index ce06133..95cf06e 100644 --- a/gfbgraph/gfbgraph-authorizer.c +++ b/gfbgraph/gfbgraph-authorizer.c @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ /** diff --git a/gfbgraph/gfbgraph-authorizer.h b/gfbgraph/gfbgraph-authorizer.h index c85c0f4..6100cbd 100644 --- a/gfbgraph/gfbgraph-authorizer.h +++ b/gfbgraph/gfbgraph-authorizer.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_AUTHORIZER_H__ diff --git a/gfbgraph/gfbgraph-common.c b/gfbgraph/gfbgraph-common.c index 2dc7f65..2da1ec4 100644 --- a/gfbgraph/gfbgraph-common.c +++ b/gfbgraph/gfbgraph-common.c @@ -1,27 +1,27 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */ /* * libgfbgraph - GObject library for Facebook Graph API - * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> + * Copyright (C) 2013-2015 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #include "gfbgraph-common.h" #include <rest/rest-proxy.h> -#define FACEBOOK_ENDPOINT "https://graph.facebook.com" +#define FACEBOOK_ENDPOINT "https://graph.facebook.com/v2.3" /** * gfbgraph_new_rest_call: diff --git a/gfbgraph/gfbgraph-common.h b/gfbgraph/gfbgraph-common.h index 764d4ef..b2bad18 100644 --- a/gfbgraph/gfbgraph-common.h +++ b/gfbgraph/gfbgraph-common.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_COMMON_H__ diff --git a/gfbgraph/gfbgraph-connectable.c b/gfbgraph/gfbgraph-connectable.c index edc5de4..82b0765 100644 --- a/gfbgraph/gfbgraph-connectable.c +++ b/gfbgraph/gfbgraph-connectable.c @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -25,7 +25,7 @@ * * #GFBGraphConnectable interface allow the connection between nodes. * You can see the posible (not necesary implemented) connections in - * the section "Connections" in any node object in the + * the section "Connections" in any node object in the * <ulink url="https://developers.facebook.com/docs/reference/api/">Facebook Graph API documentation</ulink> **/ @@ -91,12 +91,12 @@ gfbgraph_connectable_get_connection_post_params (GFBGraphConnectable *self, GTyp * gfbgraph_connectable_parse_connected_data: * @self: a #GFBGraphConnectable. * @payload: a const #gchar with the response string from the Facebook Graph API. - * @error: (allow-none) a #GError. + * @error: (allow-none): a #GError. * * Parse the response contained in @payload when a gfbgraph_node_get_connection_nodes() was * executed. * - * Returns: (transfer full): a #GList of #GFBGraphNode created from the @payload or %NULL. + * Returns: (element-type GFBGraphNode) (transfer full): a newly-allocated #GList of #GFBGraphNode created from the @payload or %NULL. **/ GList* gfbgraph_connectable_parse_connected_data (GFBGraphConnectable *self, const gchar *payload, GError **error) @@ -168,7 +168,7 @@ gfbgraph_connectable_get_connection_path (GFBGraphConnectable *self, GType node_ * gfbgraph_connectable_default_parse_connected_data: * @self: a #GFBGraphConnectable. * @payload: a const #gchar with the response string from the Facebook Graph API. - * @error: (allow-none) a #GError or %NULL. + * @error: (allow-none): a #GError or %NULL. * * In most cases, #GFBGraphConnectable implementers can use this function in order to parse * the response when a gfbgraph_node_get_connection_nodes() is executed and the @@ -177,7 +177,7 @@ gfbgraph_connectable_get_connection_path (GFBGraphConnectable *self, GType node_ * Normally, Facebook Graph API returns the connections in the same way, using JSON objects, * with a root object called "data". * - * Returns: (transfer full): a #GList of #GFBGraphNode with the same #GType as @self. + * Returns: (element-type GFBGraphNode) (transfer full): a newly-allocated #GList of #GFBGraphNode with the same #GType as @self. **/ GList* gfbgraph_connectable_default_parse_connected_data (GFBGraphConnectable *self, const gchar *payload, GError **error) diff --git a/gfbgraph/gfbgraph-connectable.h b/gfbgraph/gfbgraph-connectable.h index 1781b2b..8b8a601 100644 --- a/gfbgraph/gfbgraph-connectable.h +++ b/gfbgraph/gfbgraph-connectable.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_CONNECTABLE_H__ diff --git a/gfbgraph/gfbgraph-goa-authorizer.c b/gfbgraph/gfbgraph-goa-authorizer.c index 3a8d3b9..7d75244 100644 --- a/gfbgraph/gfbgraph-goa-authorizer.c +++ b/gfbgraph/gfbgraph-goa-authorizer.c @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -66,11 +66,11 @@ G_DEFINE_TYPE_WITH_CODE (GFBGraphGoaAuthorizer, gfbgraph_goa_authorizer, G_TYPE_ static void gfbgraph_goa_authorizer_class_init (GFBGraphGoaAuthorizerClass *klass) { - GObjectClass *gobject_class; - gobject_class = (GObjectClass*) klass; + GObjectClass *gobject_class; + gobject_class = (GObjectClass*) klass; - parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = gfbgraph_goa_authorizer_finalize; + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = gfbgraph_goa_authorizer_finalize; gobject_class->get_property = gfbgraph_goa_authorizer_get_property; gobject_class->set_property = gfbgraph_goa_authorizer_set_property; gobject_class->dispose = gfbgraph_goa_authorizer_dispose; @@ -89,20 +89,20 @@ gfbgraph_goa_authorizer_class_init (GFBGraphGoaAuthorizerClass *klass) GOA_TYPE_OBJECT, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); - g_type_class_add_private (gobject_class, sizeof(GFBGraphGoaAuthorizerPrivate)); + g_type_class_add_private (gobject_class, sizeof(GFBGraphGoaAuthorizerPrivate)); } static void gfbgraph_goa_authorizer_init (GFBGraphGoaAuthorizer *object) { - object->priv = GFBGRAPH_GOA_AUTHORIZER_GET_PRIVATE(object); + object->priv = GFBGRAPH_GOA_AUTHORIZER_GET_PRIVATE(object); g_mutex_init (&object->priv->mutex); } static void gfbgraph_goa_authorizer_finalize (GObject *object) { - G_OBJECT_CLASS(parent_class)->finalize (object); + G_OBJECT_CLASS(parent_class)->finalize (object); } static void @@ -247,5 +247,5 @@ gfbgraph_goa_authorizer_set_goa_object (GFBGraphGoaAuthorizer *self, GoaObject * GFBGraphGoaAuthorizer* gfbgraph_goa_authorizer_new (GoaObject *goa_object) { - return GFBGRAPH_GOA_AUTHORIZER (g_object_new (GFBGRAPH_TYPE_GOA_AUTHORIZER, "goa-object", goa_object, NULL)); + return GFBGRAPH_GOA_AUTHORIZER (g_object_new (GFBGRAPH_TYPE_GOA_AUTHORIZER, "goa-object", goa_object, NULL)); } diff --git a/gfbgraph/gfbgraph-goa-authorizer.h b/gfbgraph/gfbgraph-goa-authorizer.h index 499248f..fa0fc99 100644 --- a/gfbgraph/gfbgraph-goa-authorizer.h +++ b/gfbgraph/gfbgraph-goa-authorizer.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_GOA_AUTHORIZER_H__ diff --git a/gfbgraph/gfbgraph-node.c b/gfbgraph/gfbgraph-node.c index 69da087..84d0040 100644 --- a/gfbgraph/gfbgraph-node.c +++ b/gfbgraph/gfbgraph-node.c @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -43,12 +43,18 @@ enum { PROP_0, - PROP_ID + PROP_ID, + PROP_LINK, + PROP_CREATEDTIME, + PROP_UPDATEDTIME }; struct _GFBGraphNodePrivate { GList *connections; gchar *id; + gchar *link; + gchar *created_time; + gchar *updated_time; }; typedef struct { @@ -102,6 +108,42 @@ gfbgraph_node_class_init (GFBGraphNodeClass *klass) "The Facebook node ID", "Every node in the Facebook Graph is identified by his ID", "", G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GFBGraphNode:link: + * + * The node link. An URL to the node on Facebook. + **/ + g_object_class_install_property (gobject_class, + PROP_LINK, + g_param_spec_string ("link", + "The link to the node", "A link (url) to the node on Facebook", + "", + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GFBGraphNode:created_time: + * + * The time the node was initially published. Is an ISO 8601 encoded date. + **/ + g_object_class_install_property (gobject_class, + PROP_CREATEDTIME, + g_param_spec_string ("created_time", + "The node creation time", "An ISO 8601 encoded date when the node was initially published", + "", + G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GFBGraphNode:updated_time: + * + * The last time the node was updated. Is an ISO 8601 encoded date. + **/ + g_object_class_install_property (gobject_class, + PROP_UPDATEDTIME, + g_param_spec_string ("updated_time", + "The node updated time", "An ISO 8601 encoded date when the node was updated", + "", + G_PARAM_READABLE | G_PARAM_WRITABLE)); } static void @@ -119,6 +161,10 @@ gfbgraph_node_finalize (GObject *object) if (priv->id) g_free (priv->id); + if (priv->link) + g_free (priv->link); + if (priv->created_time) + g_free (priv->created_time); G_OBJECT_CLASS(parent_class)->finalize (object); } @@ -136,6 +182,21 @@ gfbgraph_node_set_property (GObject *object, guint prop_id, const GValue *value, g_free (priv->id); priv->id = g_strdup (g_value_get_string (value)); break; + case PROP_LINK: + if (priv->link) + g_free (priv->link); + priv->link = g_strdup (g_value_get_string (value)); + break; + case PROP_CREATEDTIME: + if (priv->created_time) + g_free (priv->created_time); + priv->created_time = g_strdup (g_value_get_string (value)); + break; + case PROP_UPDATEDTIME: + if (priv->updated_time) + g_free (priv->updated_time); + priv->updated_time = g_strdup (g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -153,6 +214,15 @@ gfbgraph_node_get_property (GObject *object, guint prop_id, GValue *value, GPara case PROP_ID: g_value_set_string (value, priv->id); break; + case PROP_LINK: + g_value_set_string (value, priv->link); + break; + case PROP_CREATEDTIME: + g_value_set_string (value, priv->created_time); + break; + case PROP_UPDATEDTIME: + g_value_set_string (value, priv->updated_time); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -203,7 +273,7 @@ gfbgraph_node_new (void) * @error: (allow-none): a #GError or %NULL. * * Retrieve a node object as a #GFBgraphNode of #node_type type, with the given @id from the Facebook Graph. - * + * * Returns: (transfer full): a #GFBGraphNode or %NULL. **/ GFBGraphNode* @@ -236,7 +306,90 @@ gfbgraph_node_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GTyp g_object_unref (jparser); } - return node; + return node; +} + +/** + * gfbgraph_node_get_id: + * @node: a #GFBGraphNode. + * + * Gets the Facebook Graph unique node ID. + * + * Returns: (transfer none): the node ID. + **/ +const gchar* +gfbgraph_node_get_id (GFBGraphNode *node) +{ + g_return_val_if_fail (GFBGRAPH_IS_NODE (node), NULL); + + return node->priv->id; +} + +/** + * gfbgraph_node_get_url: + * @node: a #GFBGraphNode. + * + * Gets the node link to the Facebook web page. + * + * Returns: (transfer none): the URL. + **/ +const gchar* +gfbgraph_node_get_link (GFBGraphNode *node) +{ + g_return_val_if_fail (GFBGRAPH_IS_NODE (node), NULL); + + return node->priv->link; +} + +/** + * gfbgraph_node_get_created_time: + * @node: a #GFBGraphNode. + * + * Gets a node created time. + * + * Returns: (transfer none): an ISO 8601 encoded date when the node was initially published. + **/ +const gchar* +gfbgraph_node_get_created_time (GFBGraphNode *node) +{ + g_return_val_if_fail (GFBGRAPH_IS_NODE (node), NULL); + + return node->priv->created_time; +} + +/** + * gfbgraph_node_get_updated_time: + * @node: a #GFBGraphNode. + * + * Gets a node updated time. + * + * Returns: (transfer none): an ISO 8601 encoded date when the node was updated. + **/ +const gchar* +gfbgraph_node_get_updated_time (GFBGraphNode *node) +{ + g_return_val_if_fail (GFBGRAPH_IS_NODE (node), NULL); + + return node->priv->updated_time; +} + +/** + * gfbgraph_node_set_id: + * @node: a #GFBGraphNode. + * @id: a const pointer to a #gchar. + * + * Sets the ID for a node. Just useful when a new node is created + * and the Graph API returns the ID of the new created node. + **/ +void +gfbgraph_node_set_id (GFBGraphNode *node, const gchar *id) +{ + g_return_if_fail (GFBGRAPH_IS_NODE (node)); + g_return_if_fail (id != NULL); + + g_object_set (G_OBJECT (node), + "id", id, + NULL); } /** @@ -245,12 +398,12 @@ gfbgraph_node_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GTyp * @node_type: a #GFBGraphNode type #GType that determines the kind of nodes to retrieve. * @authorizer: a #GFBGraphAuthorizer. * @error: (allow-none): a #GError or %NULL. - * + * * Retrieve the nodes of type @node_type connected to the @node object. The @node_type object must * implement the #GFBGraphConnectionable interface and be connectable to @node type object. * See gfbgraph_node_get_connection_nodes_async() for the asynchronous version of this call. * - * Returns: (transfer full): a #GList of type @node_type objects with the found nodes. + * Returns: (element-type GFBGraphNode) (transfer full): a newly-allocated #GList of type @node_type objects with the found nodes. **/ GList* gfbgraph_node_get_connection_nodes (GFBGraphNode *node, GType node_type, GFBGraphAuthorizer *authorizer, GError **error) @@ -272,7 +425,7 @@ gfbgraph_node_get_connection_nodes (GFBGraphNode *node, GType node_type, GFBGrap if (GFBGRAPH_IS_CONNECTABLE (connected_node) == FALSE) { g_set_error (error, GFBGRAPH_NODE_ERROR, GFBGRAPH_NODE_ERROR_NO_CONNECTABLE, - "The given node type (%s) don't implement connetionable interface", g_type_name (node_type)); + "The given node type (%s) doesn't implement connectable interface", g_type_name (node_type)); return NULL; } @@ -316,7 +469,7 @@ gfbgraph_node_get_connection_nodes (GFBGraphNode *node, GType node_type, GFBGrap * @cancellable: (allow-none): An optional #GCancellable object, or %NULL. * @callback: (scope async): A #GAsyncReadyCallback to call when the request is completed. * @user_data: (closure): The data to pass to @callback. - * + * * Asynchronously retrieve the list of nodes of type @node_type connected to the @node object. See * gfbgraph_node_get_connection_nodes() for the synchronous version of this call. * @@ -331,7 +484,7 @@ gfbgraph_node_get_connection_nodes_async (GFBGraphNode *node, GType node_type, G g_return_if_fail (GFBGRAPH_IS_NODE (node)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); - g_return_if_fail (callback != NULL); + g_return_if_fail (callback != NULL); result = g_simple_async_result_new (G_OBJECT (node), callback, user_data, gfbgraph_node_get_connection_nodes_async); g_simple_async_result_set_check_cancellable (result, cancellable); @@ -354,10 +507,10 @@ gfbgraph_node_get_connection_nodes_async (GFBGraphNode *node, GType node_type, G * @result: A #GAsyncResult. * @error: (allow-none): An optional #GError, or %NULL. * - * Finishes an asynchronous operation started with + * Finishes an asynchronous operation started with * gfbgraph_node_get_connection_nodes_async(). * - * Returns: (transfer full): a #GList of type #node_type objects with the found nodes. + * Returns: (element-type GFBGraphNode) (transfer full): a newly-allocated #GList of type #node_type objects with the found nodes. **/ GList* gfbgraph_node_get_connection_nodes_async_finish (GFBGraphNode *node, GAsyncResult *result, GError **error) @@ -386,6 +539,8 @@ gfbgraph_node_get_connection_nodes_async_finish (GFBGraphNode *node, GAsyncResul * * Appends @connect_node to @node. @connect_node must implement the #GFBGraphConnectable interface * and be connectable to @node GType. + * + * Returns: TRUE on sucess, FALSE if an error ocurred. **/ gboolean gfbgraph_node_append_connection (GFBGraphNode *node, GFBGraphNode *connect_node, GFBGraphAuthorizer *authorizer, GError **error) @@ -398,7 +553,20 @@ gfbgraph_node_append_connection (GFBGraphNode *node, GFBGraphNode *connect_node, g_return_val_if_fail (GFBGRAPH_IS_NODE (node), FALSE); g_return_val_if_fail (GFBGRAPH_IS_NODE (connect_node), FALSE); g_return_val_if_fail (GFBGRAPH_IS_AUTHORIZER (authorizer), FALSE); - /* TODO: Check if connect_node is connectable to node */ + + if (GFBGRAPH_IS_CONNECTABLE (connect_node) == FALSE) { + g_set_error (error, GFBGRAPH_NODE_ERROR, + GFBGRAPH_NODE_ERROR_NO_CONNECTABLE, + "The given node type (%s) doesn't implement connectable interface", G_OBJECT_TYPE_NAME (connect_node)); + return FALSE; + } + + if (gfbgraph_connectable_is_connectable_to (GFBGRAPH_CONNECTABLE (connect_node), G_OBJECT_TYPE (node)) == FALSE) { + g_set_error (error, GFBGRAPH_NODE_ERROR, + GFBGRAPH_NODE_ERROR_NO_CONNECTABLE, + "The given node type (%s) can't append a %s connection", G_OBJECT_TYPE_NAME (node), G_OBJECT_TYPE_NAME (connect_node)); + return FALSE; + } priv = GFBGRAPH_NODE_GET_PRIVATE (node); @@ -424,9 +592,24 @@ gfbgraph_node_append_connection (GFBGraphNode *node, GFBGraphNode *connect_node, if (rest_proxy_call_sync (rest_call, error)) { const gchar *payload; + JsonParser *jparser; + JsonNode *jnode; + JsonReader *jreader; payload = rest_proxy_call_get_payload (rest_call); - /* TODO: Parse result (the ID) and put to the connect_node */ + /* Parssing the new ID */ + jparser = json_parser_new (); + json_parser_load_from_data (jparser, payload, -1, error); + jnode = json_parser_get_root (jparser); + jreader = json_reader_new (jnode); + + json_reader_read_element (jreader, 0); + gfbgraph_node_set_id (connect_node, + json_reader_get_string_value (jreader)); + json_reader_end_element (jreader); + + g_object_unref (jreader); + g_object_unref (jparser); } else { return FALSE; } diff --git a/gfbgraph/gfbgraph-node.h b/gfbgraph/gfbgraph-node.h index f8fc879..95da121 100644 --- a/gfbgraph/gfbgraph-node.h +++ b/gfbgraph/gfbgraph-node.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_NODE_H__ @@ -46,7 +46,7 @@ struct _GFBGraphNode { }; struct _GFBGraphNodeClass { - GObjectClass parent_class; + GObjectClass parent_class; }; typedef enum { @@ -60,7 +60,14 @@ GFBGraphNode* gfbgraph_node_new (void); GFBGraphNode* gfbgraph_node_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GType node_type, GError **error); -GList* gfbgraph_node_get_connection_nodes (GFBGraphNode *node, +const gchar* gfbgraph_node_get_id (GFBGraphNode *node); +const gchar* gfbgraph_node_get_link (GFBGraphNode *node); +const gchar* gfbgraph_node_get_created_time (GFBGraphNode *node); +const gchar* gfbgraph_node_get_updated_time (GFBGraphNode *node); + +void gfbgraph_node_set_id (GFBGraphNode *node, const gchar *id); + +GList* gfbgraph_node_get_connection_nodes (GFBGraphNode *node, GType node_type, GFBGraphAuthorizer *authorizer, GError **error); diff --git a/gfbgraph/gfbgraph-photo.c b/gfbgraph/gfbgraph-photo.c index 12b091a..1e8955c 100644 --- a/gfbgraph/gfbgraph-photo.c +++ b/gfbgraph/gfbgraph-photo.c @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -30,6 +30,7 @@ #include "gfbgraph-connectable.h" #include "gfbgraph-album.h" +#include <json-glib/json-glib.h> #include <libsoup/soup.h> #include <libsoup/soup-request.h> #include <libsoup/soup-request-http.h> @@ -41,14 +42,17 @@ enum { PROP_NAME, PROP_SOURCE, PROP_HEIGHT, - PROP_WIDTH + PROP_WIDTH, + PROP_IMAGES }; struct _GFBGraphPhotoPrivate { - gchar *name; - gchar *source; - guint width; - guint height; + gchar *name; + gchar *source; + guint width; + guint height; + GList *images; + GFBGraphPhotoImage *hires_image; }; static void gfbgraph_photo_init (GFBGraphPhoto *obj); @@ -60,17 +64,28 @@ static void gfbgraph_photo_get_property (GObject *object, guint prop_id, GValue static void gfbgraph_photo_connectable_iface_init (GFBGraphConnectableInterface *iface); GHashTable* gfbgraph_photo_get_connection_post_params (GFBGraphConnectable *self, GType node_type); +static void gfbgraph_photo_serializable_iface_init (JsonSerializableIface *iface); +JsonNode *gfbgraph_photo_serializable_serialize_property (JsonSerializable *serializable, const gchar *property_name, const GValue *value, GParamSpec *pspec); +gboolean gfbgraph_photo_serializable_deserialize_property (JsonSerializable *serializable, const gchar *property_name, GValue *value, GParamSpec *pspec, JsonNode *property_node); +GParamSpec *gfbgraph_photo_serializable_find_property (JsonSerializable *serializable, const char *name); +GParamSpec **gfbgraph_photo_serializable_list_properties (JsonSerializable *serializable, guint *n_pspecs); +void gfbgraph_photo_serializable_set_property (JsonSerializable *serializable, GParamSpec *pspec, const GValue *value); +void gfbgraph_photo_serializable_get_property (JsonSerializable *serializable, GParamSpec *pspec, GValue *value); + #define GFBGRAPH_PHOTO_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), GFBGRAPH_TYPE_PHOTO, GFBGraphPhotoPrivate)) static GFBGraphNodeClass *parent_class = NULL; G_DEFINE_TYPE_WITH_CODE (GFBGraphPhoto, gfbgraph_photo, GFBGRAPH_TYPE_NODE, - G_IMPLEMENT_INTERFACE (GFBGRAPH_TYPE_CONNECTABLE, gfbgraph_photo_connectable_iface_init)); + G_IMPLEMENT_INTERFACE (GFBGRAPH_TYPE_CONNECTABLE, gfbgraph_photo_connectable_iface_init); + G_IMPLEMENT_INTERFACE (JSON_TYPE_SERIALIZABLE, gfbgraph_photo_serializable_iface_init);); static void gfbgraph_photo_init (GFBGraphPhoto *obj) { obj->priv = GFBGRAPH_PHOTO_GET_PRIVATE(obj); + + obj->priv->images = NULL; } static void @@ -132,11 +147,42 @@ gfbgraph_photo_class_init (GFBGraphPhotoClass *klass) "Photo height", "The photo height", 0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GFBGraphPhoto:images: + * + * A list with the available representations of the photo, in differents sizes + **/ + g_object_class_install_property (gobject_class, + PROP_IMAGES, + g_param_spec_pointer ("images", + "Sizes of the photo", "The diffents sizes available of the photo", + G_PARAM_READABLE | G_PARAM_WRITABLE)); } static void gfbgraph_photo_finalize (GObject *obj) { + GFBGraphPhotoPrivate *priv; + GList *images; + GFBGraphPhotoImage *photo_image; + + priv = GFBGRAPH_PHOTO_GET_PRIVATE (obj); + + images = priv->images; + while (images) { + photo_image = (GFBGraphPhotoImage *) images->data; + + g_free (photo_image->source); + g_free (photo_image); + + images = g_list_next (images); + } + + g_free (priv->name); + g_free (priv->source); + g_list_free (priv->images); + G_OBJECT_CLASS(parent_class)->finalize (obj); } @@ -164,6 +210,10 @@ gfbgraph_photo_set_property (GObject *object, guint prop_id, const GValue *value case PROP_HEIGHT: priv->height = g_value_get_uint (value); break; + case PROP_IMAGES: + /* TODO: Free GList memory with g_list_free_full */ + priv->images = g_value_get_pointer (value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -190,6 +240,8 @@ gfbgraph_photo_get_property (GObject *object, guint prop_id, GValue *value, GPar case PROP_HEIGHT: g_value_set_uint (value, priv->height); break; + case PROP_IMAGES: + g_value_set_pointer (value, priv->images); default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -224,6 +276,96 @@ gfbgraph_photo_get_connection_post_params (GFBGraphConnectable *self, GType node return params; } +static void +gfbgraph_photo_serializable_iface_init (JsonSerializableIface *iface) +{ + iface->serialize_property = gfbgraph_photo_serializable_serialize_property; + iface->deserialize_property = gfbgraph_photo_serializable_deserialize_property; + iface->find_property = gfbgraph_photo_serializable_find_property; + iface->list_properties = gfbgraph_photo_serializable_list_properties; + iface->set_property = gfbgraph_photo_serializable_set_property; + iface->get_property = gfbgraph_photo_serializable_get_property; +} + +JsonNode * +gfbgraph_photo_serializable_serialize_property (JsonSerializable *serializable, const gchar *property_name, const GValue *value, GParamSpec *pspec) +{ + JsonNode *node = NULL; + + g_print ("Serializing %s\n", property_name); + + if (g_strcmp0 ("images", property_name) == 0) { + } else { + node = json_serializable_default_serialize_property (serializable, property_name, value, pspec); + } + + return node; +} + +gboolean +gfbgraph_photo_serializable_deserialize_property (JsonSerializable *serializable, const gchar *property_name, GValue *value, GParamSpec *pspec, JsonNode *property_node) +{ + gboolean res; + + if (g_strcmp0 ("images", property_name) == 0) { + if (JSON_NODE_HOLDS_ARRAY (property_node)) { + guint i, num_images; + JsonArray *jarray; + GList *images; + + images = NULL; + jarray = json_node_get_array (property_node); + num_images = json_array_get_length (jarray); + for (i = 0; i < num_images; i++) { + JsonObject *image_object; + GFBGraphPhotoImage *photo_image; + + image_object = json_array_get_object_element (jarray, i); + photo_image = g_new0 (GFBGraphPhotoImage, 1); + photo_image->width = json_object_get_int_member (image_object, "width"); + photo_image->height = json_object_get_int_member (image_object, "height"); + photo_image->source = g_strdup (json_object_get_string_member (image_object, "source")); + + images = g_list_append (images, photo_image); + } + + g_value_set_pointer (value, (gpointer *) images); + res = TRUE; + } else { + g_warning ("The 'images' node retrieved from the Facebook Graph API isn't an array, it's holding a %s\n", json_node_type_name (property_node)); + res = FALSE; + } + } else { + res = json_serializable_default_deserialize_property (serializable, property_name, value, pspec, property_node); + } + + return res; +} + +GParamSpec* +gfbgraph_photo_serializable_find_property (JsonSerializable *serializable, const char *name) +{ + return g_object_class_find_property (G_OBJECT_GET_CLASS (GFBGRAPH_PHOTO (serializable)), name); +} + +GParamSpec** +gfbgraph_photo_serializable_list_properties (JsonSerializable *serializable, guint *n_pspecs) +{ + return g_object_class_list_properties (G_OBJECT_GET_CLASS (GFBGRAPH_PHOTO (serializable)), n_pspecs); +} + +void +gfbgraph_photo_serializable_set_property (JsonSerializable *serializable, GParamSpec *pspec, const GValue *value) +{ + g_object_set_property (G_OBJECT (serializable), g_param_spec_get_name (pspec), value); +} + +void +gfbgraph_photo_serializable_get_property (JsonSerializable *serializable, GParamSpec *pspec, GValue *value) +{ + g_object_get_property (G_OBJECT (serializable), g_param_spec_get_name (pspec), value); +} + /** * gfbgraph_photo_new: * @@ -258,7 +400,7 @@ gfbgraph_photo_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GEr * gfbgraph_photo_download_default_size: * @photo: a #GFBGraphPhoto. * @authorizer: a #GFBGraphAuthorizer. - * @error: (allow-none) a #GError or %NULL. + * @error: (allow-none): a #GError or %NULL. * * Download the default sized photo pointed by @photo, with a maximum width or height of 720px. * The photo always is a JPEG. @@ -287,7 +429,6 @@ gfbgraph_photo_download_default_size (GFBGraphPhoto *photo, GFBGraphAuthorizer * request = soup_requester_request (requester, priv->source, error); if (request != NULL) { message = soup_request_http_get_message (SOUP_REQUEST_HTTP (request)); - gfbgraph_authorizer_process_message (authorizer, message); stream = soup_request_send (request, NULL, error); if (stream != NULL) { @@ -302,3 +443,163 @@ gfbgraph_photo_download_default_size (GFBGraphPhoto *photo, GFBGraphAuthorizer * return stream; } + +/** + * gfbgraph_photo_get_name: + * @photo: a #GFBGraphPhoto. + * + * Returns: (transfer none): the @photo name, which is the comment given by the user so it would by larger, or %NULL. + **/ +const gchar* +gfbgraph_photo_get_name (GFBGraphPhoto *photo) +{ + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), NULL); + + return photo->priv->name; +} + +/** + * gfbgraph_photo_get_source_uri: + * @photo: a #GFBGraphPhoto. + * + * Returns: (transfer none): the image link with a maximun widht or height of 720px + **/ +const gchar* +gfbgraph_photo_get_default_source_uri (GFBGraphPhoto *photo) +{ + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), NULL); + + return photo->priv->source; +} + +/** + * gfbgraph_pohto_get_default_width: + * @photo: a #GFBGraphPhoto. + * + * Returns: (transfer none): the default photo width, up to 720px. + **/ +guint +gfbgraph_photo_get_default_width (GFBGraphPhoto *photo) +{ + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), 0); + + return photo->priv->width; +} + +/** + * gfbgraph_pohto_get_default_height: + * @photo: a #GFBGraphPhoto. + * + * Returns: (transfer none): the default photo height, up to 720px. + **/ +guint +gfbgraph_photo_get_default_height (GFBGraphPhoto *photo) +{ + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), 0); + + return photo->priv->height; +} + +/** + * gfbgraph_photo_get_images: + * @photo: a #GFBGraphPhoto. + * + * Returns: (element-type GFBGraphPhotoImage) (transfer none): a #GList of #GFBGraphPhotoImage with the available photo sizes + **/ +GList* +gfbgraph_photo_get_images (GFBGraphPhoto *photo) +{ + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), NULL); + + return photo->priv->images; +} + +/** + * gfbgraph_photo_get_image_hires: + * @photo: a #GFBGraphPhoto. + * + * Returns: (transfer none): a #GFBGraphPhotoImage with the higher resolution available of the photo + **/ +const GFBGraphPhotoImage* +gfbgraph_photo_get_image_hires (GFBGraphPhoto *photo) +{ + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), NULL); + + if (photo->priv->hires_image == NULL) { + GList *images_list; + guint bigger_width; + GFBGraphPhotoImage *photo_image; + + bigger_width = 0; + images_list = photo->priv->images; + while (images_list) { + photo_image = (GFBGraphPhotoImage *) images_list->data; + if (photo_image->width > bigger_width) { + photo->priv->hires_image = photo_image; + bigger_width = photo_image->width; + } + + images_list = g_list_next (images_list); + } + } + + return photo->priv->hires_image; +} + +const GFBGraphPhotoImage* +gfbgraph_photo_get_image_near_width (GFBGraphPhoto *photo, guint width) +{ + GList *images_list; + GFBGraphPhotoImage *tmp_photo_image; + GFBGraphPhotoImage *photo_image; + gint tmp_w_dif, w_dif; + + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), NULL); + + photo_image = NULL; + images_list = photo->priv->images; + while (images_list) { + tmp_photo_image = (GFBGraphPhotoImage *) images_list->data; + tmp_w_dif = tmp_photo_image->width - width; + tmp_w_dif = (tmp_w_dif > 0) ? tmp_w_dif : (tmp_w_dif * -1); + + if (photo_image == NULL + || tmp_w_dif < w_dif) { + w_dif = tmp_w_dif; + photo_image = tmp_photo_image; + } else { + } + + images_list = g_list_next (images_list); + } + + return photo_image; +} + +const GFBGraphPhotoImage* +gfbgraph_photo_get_image_near_height (GFBGraphPhoto *photo, guint height) +{ + GList *images_list; + GFBGraphPhotoImage *tmp_photo_image; + GFBGraphPhotoImage *photo_image; + gint tmp_h_dif, h_dif; + + g_return_val_if_fail (GFBGRAPH_IS_PHOTO (photo), NULL); + + photo_image = NULL; + images_list = photo->priv->images; + while (images_list) { + tmp_photo_image = (GFBGraphPhotoImage *) images_list->data; + tmp_h_dif = ABS(tmp_photo_image->height - height); + + if (photo_image == NULL + || tmp_h_dif < h_dif) { + h_dif = tmp_h_dif; + photo_image = tmp_photo_image; + } + + images_list = g_list_next (images_list); + } + + return photo_image; +} diff --git a/gfbgraph/gfbgraph-photo.h b/gfbgraph/gfbgraph-photo.h index 55ff3d9..c0d7549 100644 --- a/gfbgraph/gfbgraph-photo.h +++ b/gfbgraph/gfbgraph-photo.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libginstapaper 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_PHOTO_H__ @@ -47,11 +47,33 @@ struct _GFBGraphPhotoClass { GFBGraphNodeClass parent_class; }; +typedef struct _GFBGraphPhotoImage GFBGraphPhotoImage; + +/** + * GFBGraphPhotoImage: + * + * An struct with the information of a image. + */ +struct _GFBGraphPhotoImage { + guint width; + guint height; + gchar *source; +}; + GType gfbgraph_photo_get_type (void) G_GNUC_CONST; GFBGraphPhoto* gfbgraph_photo_new (void); GFBGraphPhoto* gfbgraph_photo_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GError **error); GInputStream* gfbgraph_photo_download_default_size (GFBGraphPhoto *photo, GFBGraphAuthorizer *authorizer, GError **error); +const gchar* gfbgraph_photo_get_name (GFBGraphPhoto *photo); +const gchar* gfbgraph_photo_get_default_source_uri (GFBGraphPhoto *photo); +guint gfbgraph_photo_get_default_width (GFBGraphPhoto *photo); +guint gfbgraph_photo_get_default_height (GFBGraphPhoto *photo); +GList* gfbgraph_photo_get_images (GFBGraphPhoto *photo); +const GFBGraphPhotoImage* gfbgraph_photo_get_image_hires (GFBGraphPhoto *photo); +const GFBGraphPhotoImage* gfbgraph_photo_get_image_near_width (GFBGraphPhoto *photo, guint width); +const GFBGraphPhotoImage* gfbgraph_photo_get_image_near_height (GFBGraphPhoto *photo, guint height); + G_END_DECLS #endif /* __GFBGRAPH_PHOTO_H__ */ diff --git a/gfbgraph/gfbgraph-simple-authorizer.c b/gfbgraph/gfbgraph-simple-authorizer.c index 0709d24..ab1041f 100644 --- a/gfbgraph/gfbgraph-simple-authorizer.c +++ b/gfbgraph/gfbgraph-simple-authorizer.c @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -118,7 +118,7 @@ gfbgraph_simple_authorizer_set_property (GObject *object, guint prop_id, const G default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; - } + } } static void diff --git a/gfbgraph/gfbgraph-simple-authorizer.h b/gfbgraph/gfbgraph-simple-authorizer.h index 74263e0..e2ceac3 100644 --- a/gfbgraph/gfbgraph-simple-authorizer.h +++ b/gfbgraph/gfbgraph-simple-authorizer.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_SIMPLE_AUTHORIZER_H__ diff --git a/gfbgraph/gfbgraph-user.c b/gfbgraph/gfbgraph-user.c index af21b7f..7af2fc1 100644 --- a/gfbgraph/gfbgraph-user.c +++ b/gfbgraph/gfbgraph-user.c @@ -1,20 +1,20 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */ /* * libgfbgraph - GObject library for Facebook Graph API - * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> + * Copyright (C) 2013-2014 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ /** @@ -38,11 +38,13 @@ enum { PROP_0, - PROP_NAME + PROP_NAME, + PROP_EMAIL }; struct _GFBGraphUserPrivate { gchar *name; + gchar *email; }; typedef struct { @@ -75,20 +77,20 @@ G_DEFINE_TYPE (GFBGraphUser, gfbgraph_user, GFBGRAPH_TYPE_NODE); static void gfbgraph_user_init (GFBGraphUser *obj) { - obj->priv = GFBGRAPH_USER_GET_PRIVATE(obj); + obj->priv = GFBGRAPH_USER_GET_PRIVATE(obj); } static void gfbgraph_user_class_init (GFBGraphUserClass *klass) { - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - parent_class = g_type_class_peek_parent (klass); - gobject_class->finalize = gfbgraph_user_finalize; + parent_class = g_type_class_peek_parent (klass); + gobject_class->finalize = gfbgraph_user_finalize; gobject_class->set_property = gfbgraph_user_set_property; gobject_class->get_property = gfbgraph_user_get_property; - g_type_class_add_private (gobject_class, sizeof(GFBGraphUserPrivate)); + g_type_class_add_private (gobject_class, sizeof(GFBGraphUserPrivate)); /** * GFBGraphUser:name: @@ -101,12 +103,24 @@ gfbgraph_user_class_init (GFBGraphUserClass *klass) "User's full name", "The full name of the user", "", G_PARAM_READABLE | G_PARAM_WRITABLE)); + + /** + * GFBGraphUser:email: + * + * The email of the user if available + **/ + g_object_class_install_property (gobject_class, + PROP_EMAIL, + g_param_spec_string ("email", + "User's email", "The user primary email if available", + NULL, + G_PARAM_READABLE | G_PARAM_WRITABLE)); } static void gfbgraph_user_finalize (GObject *obj) { - G_OBJECT_CLASS(parent_class)->finalize (obj); + G_OBJECT_CLASS(parent_class)->finalize (obj); } static void @@ -122,6 +136,11 @@ gfbgraph_user_set_property (GObject *object, guint prop_id, const GValue *value, g_free (priv->name); priv->name = g_strdup (g_value_get_string (value)); break; + case PROP_EMAIL: + if (priv->email) + g_free (priv->email); + priv->email = g_strdup (g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -139,6 +158,9 @@ gfbgraph_user_get_property (GObject *object, guint prop_id, GValue *value, GPara case PROP_NAME: g_value_set_string (value, priv->name); break; + case PROP_EMAIL: + g_value_set_string (value, priv->email); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -148,17 +170,17 @@ gfbgraph_user_get_property (GObject *object, guint prop_id, GValue *value, GPara static void gfbgraph_user_async_data_free (GFBGraphUserAsyncData *data) { - g_object_unref (data->user); + g_object_unref (data->user); - g_slice_free (GFBGraphUserAsyncData, data); + g_slice_free (GFBGraphUserAsyncData, data); } static void gfbgraph_user_connection_async_data_free (GFBGraphUserConnectionAsyncData *data) { - g_object_unref (data->authorizer); + g_object_unref (data->authorizer); - g_slice_free (GFBGraphUserConnectionAsyncData, data); + g_slice_free (GFBGraphUserConnectionAsyncData, data); } static void @@ -199,7 +221,7 @@ gfbgraph_user_get_albums_async_thread (GSimpleAsyncResult *simple_async, GFBGrap GFBGraphUser* gfbgraph_user_new (void) { - return GFBGRAPH_USER (g_object_new (GFBGRAPH_TYPE_USER, NULL)); + return GFBGRAPH_USER (g_object_new (GFBGRAPH_TYPE_USER, NULL)); } /** @@ -221,7 +243,7 @@ gfbgraph_user_new_from_id (GFBGraphAuthorizer *authorizer, const gchar *id, GErr /** * gfbgraph_user_get_me: * @authorizer: a #GFBGraphAuthorizer. - * @error: (allow-none) a #GError or %NULL. + * @error: (allow-none): a #GError or %NULL. * * Retrieve the current user logged using the https://graph.facebook.com/me Graph API function. * See gfbgraph_user_get_my_async() for the asynchronous version of this call. @@ -267,8 +289,8 @@ gfbgraph_user_get_me (GFBGraphAuthorizer *authorizer, GError **error) * @authorizer: a #GFBGraphAuthorizer. * @cancellable: (allow-none): An optional #GCancellable object, or %NULL. * @callback: (scope async): A #GAsyncReadyCallback to call when the request is completed. - * @user_data: (closure); The data to pass to @callback. - * + * @user_data: (closure): The data to pass to @callback. + * * Asynchronously retrieve the current user logged. See gfbgraph_user_get_me() for the * synchronous version of this call. * @@ -283,7 +305,7 @@ gfbgraph_user_get_me_async (GFBGraphAuthorizer *authorizer, GCancellable *cancel g_return_if_fail (GFBGRAPH_IS_AUTHORIZER (authorizer)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); - g_return_if_fail (callback != NULL); + g_return_if_fail (callback != NULL); simple_async = g_simple_async_result_new (G_OBJECT (authorizer), callback, user_data, gfbgraph_user_get_me_async); g_simple_async_result_set_check_cancellable (simple_async, cancellable); @@ -303,7 +325,7 @@ gfbgraph_user_get_me_async (GFBGraphAuthorizer *authorizer, GCancellable *cancel * @result: A #GAsyncResult. * @error: (allow-none): An optional #GError, or %NULL. * - * Finishes an asynchronous operation started with + * Finishes an asynchronous operation started with * gfbgraph_user_get_me_async(). * * Returns: (transfer full): a #GFBGraphUser for to the current user logged. @@ -334,7 +356,7 @@ gfbgraph_user_get_me_async_finish (GFBGraphAuthorizer *authorizer, GAsyncResult * * Retrieve the albums nodes owned by the @user. This functions call the function ID/albums. * - * Returns: (transfer full): a #GList with the albums nodes (#GFBGraphAlbums) owned by the given user. + * Returns: (element-type GFBGraphAlbum) (transfer full): a newly-allocated #GList with the albums nodes owned by the given user. **/ GList* gfbgraph_user_get_albums (GFBGraphUser *user, GFBGraphAuthorizer *authorizer, GError **error) @@ -351,13 +373,13 @@ gfbgraph_user_get_albums (GFBGraphUser *user, GFBGraphAuthorizer *authorizer, GE * @authorizer: a #GFBGraphAuthorizer. * @cancellable: (allow-none): An optional #GCancellable object, or %NULL. * @callback: (scope async): A #GAsyncReadyCallback to call when the request is completed. - * @user_data: (closure); The data to pass to @callback. + * @user_data: (closure): The data to pass to @callback. * * Asynchronously retrieve the albums nodes owned by the @user. See gfbgraph_user_get_albums() for the * synchronous version of this call. * * When the operation is finished, @callback will be called. You can then call gfbgraph_user_get_albums_async_finish() - * to get the #GList of #GFBGraphAlbums owned by the @user. + * to get the #GList of #GFBGraphAlbum owned by the @user. **/ void gfbgraph_user_get_albums_async (GFBGraphUser *user, GFBGraphAuthorizer *authorizer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) @@ -368,7 +390,7 @@ gfbgraph_user_get_albums_async (GFBGraphUser *user, GFBGraphAuthorizer *authoriz g_return_if_fail (GFBGRAPH_IS_USER (user)); g_return_if_fail (GFBGRAPH_IS_AUTHORIZER (authorizer)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); - g_return_if_fail (callback != NULL); + g_return_if_fail (callback != NULL); simple_async = g_simple_async_result_new (G_OBJECT (user), callback, user_data, gfbgraph_user_get_albums_async); g_simple_async_result_set_check_cancellable (simple_async, cancellable); @@ -390,10 +412,10 @@ gfbgraph_user_get_albums_async (GFBGraphUser *user, GFBGraphAuthorizer *authoriz * @result: A #GAsyncResult. * @error: (allow-none): An optional #GError, or %NULL. * - * Finishes an asynchronous operation started with + * Finishes an asynchronous operation started with * gfbgraph_user_get_albums_async(). * - * Returns: (transfer full): a #GList of #GFBGraphAlbums owned by the @user. + * Returns: (element-type GFBGraphAlbum) (transfer full): a newly-allocated #GList of albums owned by the @user. **/ GList* gfbgraph_user_get_albums_async_finish (GFBGraphUser *user, GAsyncResult *result, GError **error) @@ -413,3 +435,36 @@ gfbgraph_user_get_albums_async_finish (GFBGraphUser *user, GAsyncResult *result, data = (GFBGraphUserConnectionAsyncData *) g_simple_async_result_get_op_res_gpointer (simple_async); return data->nodes; } + +/** + * gfbgraph_user_get_name: + * @user: a #GFBGraphUser. + * + * Get the user full name. + * + * Returns: (transfer none): a const #gchar with the user full name, or %NULL. + **/ +const gchar* +gfbgraph_user_get_name (GFBGraphUser *user) +{ + g_return_val_if_fail (GFBGRAPH_IS_USER (user), NULL); + + return user->priv->name; +} + +/** + * gfbgraph_user_get_email: + * @user: a #GFBGraphUser. + * + * Get the user email. To retrieve this propertie, you need 'email' extended + * permission. + * + * Returns: (transfer none): a const #gchar with the user email, or %NULL. + **/ +const gchar* +gfbgraph_user_get_email (GFBGraphUser *user) +{ + g_return_val_if_fail (GFBGRAPH_IS_USER (user), NULL); + + return user->priv->email; +} diff --git a/gfbgraph/gfbgraph-user.h b/gfbgraph/gfbgraph-user.h index f17a4dd..722d366 100644 --- a/gfbgraph/gfbgraph-user.h +++ b/gfbgraph/gfbgraph-user.h @@ -1,20 +1,20 @@ /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */ /* * libgfbgraph - GObject library for Facebook Graph API - * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> + * Copyright (C) 2013-2014 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_USER_H__ @@ -42,11 +42,11 @@ struct _GFBGraphUser { GFBGraphNode parent; /*< private >*/ - GFBGraphUserPrivate *priv; + GFBGraphUserPrivate *priv; }; struct _GFBGraphUserClass { - GFBGraphNodeClass parent_class; + GFBGraphNodeClass parent_class; }; GType gfbgraph_user_get_type (void) G_GNUC_CONST; @@ -61,6 +61,9 @@ GList* gfbgraph_user_get_albums (GFBGraphUser *user, GFBGrap void gfbgraph_user_get_albums_async (GFBGraphUser *user, GFBGraphAuthorizer *authorizer, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); GList* gfbgraph_user_get_albums_async_finish (GFBGraphUser *user, GAsyncResult *result, GError **error); +const gchar* gfbgraph_user_get_name (GFBGraphUser *user); +const gchar* gfbgraph_user_get_email (GFBGraphUser *user); + G_END_DECLS #endif /* __GFBGRAPH_USER_H__ */ diff --git a/gfbgraph/gfbgraph.h b/gfbgraph/gfbgraph.h index 68cc9b9..a9f0034 100644 --- a/gfbgraph/gfbgraph.h +++ b/gfbgraph/gfbgraph.h @@ -3,18 +3,18 @@ * libgfbgraph - GObject library for Facebook Graph API * Copyright (C) 2013 Álvaro Peña <alvaropg@gmail.com> * - * This library 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. + * GFBGraph 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. * - * libgfbgraph 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. + * GFBGraph 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 General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. + * You should have received a copy of the GNU Lesser General Public + * License along with GFBGraph. If not, see <http://www.gnu.org/licenses/>. */ #ifndef __GFBGRAPH_H__ diff --git a/libgfbgraph.pc.in b/libgfbgraph.pc.in index 3609c7c..f87073e 100644 --- a/libgfbgraph.pc.in +++ b/libgfbgraph.pc.in @@ -6,9 +6,9 @@ datadir=@datadir@ includedir=@includedir@ apiversion=@API_VERSION@ -Name: libginstapaper -Description: GObject Instapaper library +Name: libgfbgraph +Description: GObject library for Facebook Graph API Version: @VERSION@ -Requires: rest-0.7 glib-2.0 -Libs: -L${libdir} -llibginstapaper-${apiversion} -Cflags: -I${includedir} +Requires: gio-2.0 glib-2.0 goa-1.0 json-glib-1.0 libsoup-2.4 rest-0.7 +Libs: -L${libdir} -lgfbgraph-${apiversion} +Cflags: -I${includedir}/gfbgraph-@API_VERSION@ diff --git a/tests/Makefile.am b/tests/Makefile.am index b67ad00..efe441e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,19 +1,10 @@ -TESTS = gtestutils test test-async - -COMMON_SRC = credentials.h +TESTS = gtestutils AM_CPPFLAGS = -I$(top_srcdir) $(LIBGFBGRAPH_CFLAGS) -AM_LDFLAGS = $(top_srcdir)/gfbgraph/libgfbgraph-@API_VERSION@.la $(LIBGFBGRAPH_LIBS) +AM_LDFLAGS = $(top_builddir)/gfbgraph/libgfbgraph-@API_VERSION@.la $(LIBGFBGRAPH_LIBS) noinst_PROGRAMS = $(TESTS) -gtestutils_SOURCES = $(COMMON_SRC) \ - gtestutils.c - -test_SOURCES = $(COMMON_SRC) \ - test.c - -test_async_SOURCES = $(COMMON_SRC) \ - test-async.c +gtestutils_SOURCES = gtestutils.c -include $(top_srcdir)/git.mk diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..45db00d --- /dev/null +++ b/tests/README @@ -0,0 +1,8 @@ +To run the tests it's required a file called "credentials.ini" placed in this +folder. In that file you need to put your cliend id and your client secret +codes. You can get both from the Facebook Developer Page. + +This is an example content of credentials.ini: +[Client] +ClientId=000000000000000 +ClientSecret=00000000000000000000000000000000 diff --git a/tests/credentials.h b/tests/credentials.h deleted file mode 100644 index ca153dd..0000000 --- a/tests/credentials.h +++ /dev/null @@ -1,2 +0,0 @@ -#define GFBGRAPH_TEST_CLIENT_ID "" -#define GFBGRAPH_TEST_ACCESS_TOKEN "" diff --git a/tests/gtestutils.c b/tests/gtestutils.c index 0970b3d..438b239 100644 --- a/tests/gtestutils.c +++ b/tests/gtestutils.c @@ -1,21 +1,282 @@ -#include "config.h" -#include "credentials.h" +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * libgfbgraph - GObject library for Facebook Graph API + * Copyright (C) 2013-2015 Álvaro Peña <alvaropg@gmail.com> + * + * GFBGraph 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. + * + * GFBGraph 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 GFBGraph. If not, see <http://www.gnu.org/licenses/>. + */ #include <glib.h> +#include <json-glib/json-glib.h> +#include <rest/rest-proxy.h> +#include <string.h> + #include <gfbgraph/gfbgraph.h> #include <gfbgraph/gfbgraph-simple-authorizer.h> +/* #include "config.h" */ + +typedef struct _GFBGraphTestFixture GFBGraphTestFixture; +typedef struct _GFBGraphTestApp GFBGraphTestApp; + +struct _GFBGraphTestFixture +{ + gchar *user_id; + gchar *user_email; + + GFBGraphSimpleAuthorizer *authorizer; +}; + +struct _GFBGraphTestApp +{ + gchar *client_id; + gchar *client_secret; + gchar *access_token; +}; + +#define FACEBOOK_ENDPOINT "https://graph.facebook.com/v2.3" + +#define FACEBOOK_TEST_USER_PERMISSIONS "user_about_me,user_photos,email" + +GFBGraphTestApp* +gfbgraph_test_app_setup (void) +{ + GFBGraphTestApp *app; + RestProxy *proxy; + RestProxyCall *rest_call; + gchar *function_path; + GKeyFile *app_key_file; + gchar *app_key_filename; + GError *error = NULL; + const char *payload; + JsonNode *jnode; + JsonParser *jparser; + JsonReader *jreader; + + app_key_filename = g_test_build_filename (G_TEST_BUILT, + "credentials.ini", + NULL); + app_key_file = g_key_file_new (); + g_key_file_load_from_file (app_key_file, + app_key_filename, + G_KEY_FILE_NONE, + &error); + g_assert_no_error(error); + + app = g_new0(GFBGraphTestApp, 1); + + app->client_id = g_key_file_get_string (app_key_file, + "Client", + "ClientId", + &error); + g_assert_no_error(error); + app->client_secret = g_key_file_get_string (app_key_file, + "Client", + "ClientSecret", + &error); + g_assert_no_error(error); + + proxy = rest_proxy_new (FACEBOOK_ENDPOINT, FALSE); + rest_call = rest_proxy_new_call (proxy); + + rest_proxy_call_add_param (rest_call, "client_id", app->client_id); + rest_proxy_call_add_param (rest_call, "client_secret", app->client_secret); + rest_proxy_call_add_param (rest_call, "grant_type", "client_credentials"); + + rest_proxy_call_set_method (rest_call, "GET"); + function_path = g_strdup ("/oauth/access_token"); + rest_proxy_call_set_function (rest_call, function_path); + + rest_proxy_call_sync (rest_call, &error); + g_assert_no_error (error); + + payload = rest_proxy_call_get_payload (rest_call); + jparser = json_parser_new (); + json_parser_load_from_data (jparser, payload, -1, &error); + g_assert_no_error (error); + jnode = json_parser_get_root (jparser); + jreader = json_reader_new (jnode); + json_reader_read_element (jreader, 0); + app->access_token = g_strdup(json_reader_get_string_value (jreader)); + json_reader_end_element (jreader); + g_object_unref(jparser); + + g_clear_object(&rest_call); + g_clear_object(&proxy); + + return app; +} + +void +gfbgraph_test_fixture_setup (GFBGraphTestFixture *fixture, gconstpointer user_data) +{ + RestProxy *proxy; + RestProxyCall *rest_call; + gchar *function_path; + const gchar *payload; + GError *error = NULL; + const GFBGraphTestApp *app = user_data; + JsonNode *jnode; + JsonParser *jparser; + JsonReader *jreader; + const gchar *access_token; + + /* Create a new user */ + + proxy = rest_proxy_new (FACEBOOK_ENDPOINT, FALSE); + rest_call = rest_proxy_new_call (proxy); + + /* Params as documented here: https://developers.facebook.com/docs/graph-api/reference/app/accounts/test-users#publish */ + rest_proxy_call_add_param (rest_call, "installed", "true"); + rest_proxy_call_add_param (rest_call, "permissions", FACEBOOK_TEST_USER_PERMISSIONS); + rest_proxy_call_add_param (rest_call, "access_token", app->access_token); + + rest_proxy_call_set_method (rest_call, "POST"); + function_path = g_strdup_printf ("%s/accounts/test-users", app->client_id); + rest_proxy_call_set_function (rest_call, function_path); + + rest_proxy_call_sync (rest_call, &error); + g_assert_no_error (error); + + payload = rest_proxy_call_get_payload (rest_call); + jparser = json_parser_new (); + json_parser_load_from_data (jparser, payload, -1, &error); + g_assert_no_error (error); + jnode = json_parser_get_root (jparser); + jreader = json_reader_new (jnode); + + json_reader_read_element (jreader, 0); + fixture->user_id = g_strdup (json_reader_get_string_value (jreader)); + json_reader_end_element (jreader); + json_reader_read_element (jreader, 1); + access_token = g_strdup (json_reader_get_string_value (jreader)); + json_reader_end_element (jreader); + json_reader_read_element (jreader, 3); + fixture->user_email = g_strdup (json_reader_get_string_value (jreader)); + json_reader_end_element (jreader); + + fixture->authorizer = gfbgraph_simple_authorizer_new (access_token); + + if (function_path) + g_free (function_path); + g_clear_object (&rest_call); + g_clear_object (&proxy); +} + +static void +gfbgraph_test_fixture_teardown (GFBGraphTestFixture *fixture, gconstpointer user_data) +{ + SoupSession *ssession; + SoupMessage *smessage; + gchar *function_path; + gchar *auth_value; + guint status; + const GFBGraphTestApp *app = user_data; + SoupURI *uri; + + /* Delete the test user and clean up memory */ + + ssession = soup_session_new (); + + function_path = g_strdup_printf ("%s/%s", FACEBOOK_ENDPOINT, fixture->user_id); + smessage = soup_message_new ("DELETE", function_path); + gfbgraph_authorizer_process_message (GFBGRAPH_AUTHORIZER (fixture->authorizer), smessage); + + status = soup_session_send_message (ssession, smessage); + g_assert_cmpint(status, ==, 200); + + g_free (function_path); + g_free (auth_value); + g_free (fixture->user_id); + g_free (fixture->user_email); + g_object_unref (fixture->authorizer); +} + +static void +gfbgraph_test_me (GFBGraphTestFixture *fixture, gconstpointer user_data) +{ + GFBGraphUser *me; + GError *error = NULL; + + me = gfbgraph_user_get_me (GFBGRAPH_AUTHORIZER (fixture->authorizer), &error); + g_assert_no_error (error); + g_assert (GFBGRAPH_IS_USER (me)); + + g_assert_cmpstr (fixture->user_id, ==, gfbgraph_node_get_id (GFBGRAPH_NODE (me))); + + g_assert_cmpstr (fixture->user_email, ==, gfbgraph_user_get_email (me)); + + g_object_unref (me); +} + +static void +gfbgraph_test_album (GFBGraphTestFixture *fixture, gconstpointer user_data) +{ + GFBGraphUser *me; + GFBGraphAlbum *album; + GError *error = NULL; + + me = gfbgraph_user_get_me (GFBGRAPH_AUTHORIZER (fixture->authorizer), &error); + g_assert_no_error (error); + g_assert (GFBGRAPH_IS_USER (me)); + + /* Create a photo album */ + album = gfbgraph_album_new (); + gfbgraph_album_set_name (album, "Vanilla Sky"); + gfbgraph_album_set_description (album, "Great sunset photos in Mars!"); + g_assert (gfbgraph_node_append_connection (GFBGRAPH_NODE (me), + GFBGRAPH_NODE (album), + GFBGRAPH_AUTHORIZER (fixture->authorizer), + &error)); + g_assert_no_error (error); +} int main (int argc, char **argv) { - GFBGraphSimpleAuthorizer *authorizer; + GFBGraphTestApp *app = NULL; + int test_result; - g_type_init (); g_test_init (&argc, &argv, NULL); - authorizer = gfbgraph_simple_authorizer_new (GFBGRAPH_TEST_ACCESS_TOKEN); + g_log_set_always_fatal (G_LOG_LEVEL_ERROR | G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL | G_LOG_LEVEL_CRITICAL); + + app = gfbgraph_test_app_setup (); + + g_test_add ("/GFBGraph/Me", + GFBGraphTestFixture, + app, + gfbgraph_test_fixture_setup, + gfbgraph_test_me, + gfbgraph_test_fixture_teardown); + + g_test_add ("/GFBGraph/Album", + GFBGraphTestFixture, + app, + gfbgraph_test_fixture_setup, + gfbgraph_test_album, + gfbgraph_test_fixture_teardown); + + test_result = g_test_run (); - //g_test_add_data_func ("/GInstapaper/Bookmarks/List", proxy, (GTestDataFunc) ginstapaper_test_bookmarks_list); + if (app) { + if (app->client_id) + g_free (app->client_id); + if (app->client_secret) + g_free (app->client_secret); + if (app->access_token) + g_free (app->access_token); + } - return g_test_run (); + return test_result; } diff --git a/tests/test-async.c b/tests/test-async.c deleted file mode 100644 index bf43f20..0000000 --- a/tests/test-async.c +++ /dev/null @@ -1,119 +0,0 @@ -#include <gfbgraph/gfbgraph.h> -#include <gfbgraph/gfbgraph-simple-authorizer.h> -#include "credentials.h" - -static GMainLoop *main_loop; - -void -photo_async_cb (GFBGraphNode *album_node, GAsyncResult *res, GFBGraphAuthorizer *authorizer) -{ - GList *photos; - GError *error = NULL; - - photos = gfbgraph_node_get_connection_nodes_async_finish (GFBGRAPH_NODE (album_node), res, &error); - - if (error != NULL) { - g_print ("Error: %s\n", error->message); - g_main_loop_quit (main_loop); - } - - while (photos) { - GFBGraphPhoto *photo; - gchar *name, *source; - guint width, height; - - photo = GFBGRAPH_PHOTO (photos->data); - g_object_get (photo, "name", &name, "width", &width, "height", &height, "source", &source, NULL); - g_print ("\t\t%s (%dx%d): %s\n", name, width, height, source); - g_free (name); - - photos = g_list_next (photos); - } - - g_object_unref (album_node); - g_list_free (photos); - g_main_loop_quit (main_loop); -} - -void -albums_async_cb (GFBGraphNode *me_node, GAsyncResult *res, GFBGraphAuthorizer *authorizer) -{ - GList *albums; - GFBGraphAlbum *one_album = NULL; - GError *error = NULL; - - albums = gfbgraph_node_get_connection_nodes_async_finish (GFBGRAPH_NODE (me_node), res, &error); - - if (error != NULL) { - g_print ("Error: %s\n", error->message); - g_main_loop_quit (main_loop); - } - - /* Print all albums names and count */ - while (albums) { - GFBGraphAlbum *album; - gchar *album_name; - guint album_count; - - album = GFBGRAPH_ALBUM (albums->data); - if (one_album == NULL) { - one_album = album; - g_object_ref (one_album); - } - g_object_get (album, "name", &album_name, "count", &album_count, NULL); - g_print ("\tAlbum: %s - Photos: %d\n", album_name, album_count); - g_free (album_name); - - albums = g_list_next (albums); - } - - - /* For one album, get the photos */ - if (one_album != NULL) { - gfbgraph_node_get_connection_nodes_async (GFBGRAPH_NODE (one_album), GFBGRAPH_TYPE_PHOTO, authorizer, - NULL, (GAsyncReadyCallback) photo_async_cb, authorizer); - } - - g_list_free (albums); -} - -void -me_async_cb (GFBGraphAuthorizer *authorizer, GAsyncResult *res, gpointer user_data) -{ - GFBGraphUser *me; - GError *error = NULL; - - me = gfbgraph_user_get_me_async_finish (authorizer, res, &error); - if (error != NULL) { - g_print ("Error: %s\n", error->message); - g_main_loop_quit (main_loop); - } else { - gchar *me_name; - - g_object_get (G_OBJECT (me), "name", &me_name, NULL); - g_print ("User: %s\n", me_name); - gfbgraph_node_get_connection_nodes_async (GFBGRAPH_NODE (me), GFBGRAPH_TYPE_ALBUM, authorizer, - NULL, (GAsyncReadyCallback) albums_async_cb, authorizer); - } -} - -int -main (int argc, char **argv) -{ - GFBGraphSimpleAuthorizer *authorizer; - - g_type_init (); - main_loop = g_main_loop_new (NULL, TRUE); - - authorizer = gfbgraph_simple_authorizer_new (GFBGRAPH_TEST_ACCESS_TOKEN); - - /* Get "me" user */ - gfbgraph_user_get_me_async (GFBGRAPH_AUTHORIZER (authorizer), NULL, (GAsyncReadyCallback) me_async_cb, NULL); - - g_main_loop_run (main_loop); - - g_main_loop_unref (main_loop); - g_clear_object (&authorizer); - - return 0; -} diff --git a/tests/test.c b/tests/test.c deleted file mode 100644 index 53146ae..0000000 --- a/tests/test.c +++ /dev/null @@ -1,52 +0,0 @@ -#include <gfbgraph/gfbgraph.h> -#include <gfbgraph/gfbgraph-simple-authorizer.h> -#include "credentials.h" - -int -main (int argc, char **argv) -{ - GFBGraphSimpleAuthorizer *authorizer; - GFBGraphUser *me; - gchar *me_name; - GError *error = NULL; - GList *albums; - - g_type_init (); - - authorizer = gfbgraph_simple_authorizer_new (GFBGRAPH_TEST_ACCESS_TOKEN); - - /* Get "me" user */ - me = gfbgraph_user_get_me (GFBGRAPH_AUTHORIZER (authorizer), &error); - if (error != NULL) { - g_print ("Error getting \"me\" user: %s\n", error->message); - return -1; - } - g_object_get (G_OBJECT (me), "name", &me_name, NULL); - g_print ("User: %s\n", me_name); - - /* Get my albums */ - albums = gfbgraph_node_get_connection_nodes (GFBGRAPH_NODE (me), GFBGRAPH_TYPE_ALBUM, GFBGRAPH_AUTHORIZER (authorizer), &error); - if (error != NULL) { - g_print ("Error get connected nodes\n"); - return -1; - } - if (albums == NULL) { - g_print ("Es nulo\n"); - } - while (albums) { - GFBGraphAlbum *album; - gchar *album_name; - guint album_count; - - album = GFBGRAPH_ALBUM (albums->data); - g_object_get (album, "name", &album_name, "count", &album_count, NULL); - g_print ("\tAlbum: %s - Photos: %d\n", album_name, album_count); - g_free (album_name); - - albums = g_list_next (albums); - } - - g_clear_object (&authorizer); - - return 0; -} |