./0000755000004100000410000000000013115304145011240 5ustar www-datawww-data./NEWS0000644000004100000410000000237713115304145011750 0ustar www-datawww-data2010-10-06: unity-place-files 0.6.12 * Update category icons * Make sure we don't update the model too soon, otherwise Dash flickers 2010-09-29: unity-place-files 0.6.10 * Open bookmarks in default file browser * Search in Downloads folder * Fix problems with DBUS_STARTER* enviroment variables 2010-08-02: unity-place-files 0.5.12 * Folder browsing mode * Downloads group on front page * Favorite Folders group on front page (gtk bookmarks) 2010-06-24: unity-place-files-0.5.2 * (temporarily) Disabled monitoring of Zeitgeist events since it leads to annoying duplicates in the Today group. This will be properly fixed later 2010-06-23: unity-place-files-0.5.1 * More correct time grouping * Add a Top Results group in search results containing relevancy ranked results 2010-06-18: unity-place-files-0.5.0 * Enable sections, groups, and full text searching. Everything still at a prototype level. especially the time based grouping. Requires at least Unity r337 and libzeitgeist >= 0.2.1, and Zeitgeist running with the FTS extension for full text searching to work 2010-06-09: unity-place-files-0.3.1 * Second release... This time distcheck actually passes. Great stuff :-) 2010-06-09: unity-place-files-0.3.0 * First release ./acinclude.m40000644000004100000410000000170713115304145013436 0ustar www-datawww-datadnl AS_AC_EXPAND(VAR, CONFIGURE_VAR) dnl dnl example dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir) dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local AC_DEFUN([AS_AC_EXPAND], [ EXP_VAR=[$1] FROM_VAR=[$2] dnl first expand prefix and exec_prefix if necessary prefix_save=$prefix exec_prefix_save=$exec_prefix dnl if no prefix given, then use /usr/local, the default prefix if test "x$prefix" = "xNONE"; then prefix=$ac_default_prefix fi dnl if no exec_prefix given, then use prefix if test "x$exec_prefix" = "xNONE"; then exec_prefix=$prefix fi full_var="$FROM_VAR" dnl loop until it doesn't change anymore while true; do new_full_var="`eval echo $full_var`" if test "x$new_full_var"="x$full_var"; then break; fi full_var=$new_full_var done dnl clean up full_var=$new_full_var AC_SUBST([$1], "$full_var") dnl restore prefix and exec_prefix prefix=$prefix_save exec_prefix=$exec_prefix_save ]) ./configure.ac0000644000004100000410000001125213115304145013527 0ustar www-datawww-dataAC_INIT(unity-lens-files, 7.1, https://launchpad.net/unity-lens-files) AC_COPYRIGHT([Copyright 2010-2012 Canonical]) AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION) ##################################################### # Silent build rules ##################################################### m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) AC_PREREQ(2.59) AC_CONFIG_HEADERS([config.h]) ##################################################### # Init the other things we depend on ##################################################### AM_MAINTAINER_MODE AM_PROG_VALAC([0.16.0]) AS_IF([test -z "$VALAC"], [AC_MSG_ERROR(["No valac compiler found."])]) AC_PROG_CC AM_PROG_CC_C_O AC_HEADER_STDC LT_INIT AC_CONFIG_MACRO_DIR([m4]) ############################################# # Gettext ############################################# GETTEXT_PACKAGE="$PACKAGE" AC_SUBST(GETTEXT_PACKAGE) AC_SUBST([CONFIG_STATUS_DEPENDENCIES],['$(top_srcdir)/po/LINGUAS']) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [gettext domain]) AM_GLIB_GNU_GETTEXT # AM_GNOME_GETTEXT above substs $DATADIRNAME # this is the directory where the *.{mo,gmo} files are installed localedir='${prefix}/${DATADIRNAME}/locale' AC_SUBST(localedir) IT_PROG_INTLTOOL([0.40.0]) AC_DEFINE_UNQUOTED(LOCALE_DIR, "${PREFIX}/${DATADIRNAME}/locale",[Locale directory]) AC_DEFINE_UNQUOTED(DATADIR, "${PREFIX}/${DATADIRNAME}",[Data directory]) AC_DEFINE_UNQUOTED(PREFIXDIR, "${PREFIX}",[Prefix directory]) ###################################################### # intltool rule for generating translated .scope file ###################################################### INTLTOOL_SCOPE_RULE='%.scope: %.scope.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@' AC_SUBST(INTLTOOL_SCOPE_RULE) ##################################################### # Check for module and library dependancies ##################################################### GLIB_REQUIRED=2.27 PKG_CHECK_MODULES(SCOPE_DAEMON, glib-2.0 >= $GLIB_REQUIRED gobject-2.0 >= $GLIB_REQUIRED gio-2.0 >= $GLIB_REQUIRED gio-unix-2.0 >= $GLIB_REQUIRED gee-0.8 dee-1.0 >= 0.5.16 zeitgeist-2.0 >= 0.9.12 unity >= 7.0.0) AC_SUBST(SCOPE_DAEMON_CFLAGS) AC_SUBST(SCOPE_DAEMON_LIBS) ##################################################### # local install for distcheck and stand-alone running ##################################################### with_localinstall="no" AC_ARG_ENABLE(localinstall, AS_HELP_STRING([--enable-localinstall], [Install all of the files locally instead of in system directories (for distcheck)]), with_localinstall=$enableval, with_localinstall=no) AM_CONDITIONAL([HAVE_LOCALINSTALL], [test "x$with_localinstall" = "xyes"]) ##################################################### # Expand variables needed for config.vala ##################################################### AS_AC_EXPAND(PREFIX, $prefix) AC_SUBST(PREFIX) AS_AC_EXPAND(DATADIR, $datarootdir) AC_SUBST(DATADIR) ##################################################### # Look for dbus service dir ##################################################### if test "x$with_localinstall" = "xyes"; then DBUSSERVICEDIR="${datadir}/dbus-1/services/" else DBUSSERVICEDIR=`$PKG_CONFIG --variable=session_bus_services_dir dbus-1` fi AC_SUBST(DBUSSERVICEDIR) ############################################# # GSettings macros ############################################# GLIB_GSETTINGS ##################################################### # Look for correct Scopes dir ##################################################### if test "x$with_localinstall" = "xyes"; then SCOPESDIR="${datadir}/unity/scopes" else SCOPESDIR=`$PKG_CONFIG --variable=scopesdir unity` fi AC_SUBST(SCOPESDIR) ##################################################### # Create the Makefiles ##################################################### AC_CONFIG_FILES([ Makefile local.scope.in data/Makefile data/com.canonical.Unity.FilesLens.gschema.xml.in src/Makefile src/config.vala po/Makefile.in tests/Makefile ]) AC_OUTPUT ##################################################### # Output the results ##################################################### AC_MSG_NOTICE([ Unity Files Lens Daemon $VERSION ------------------------------- Prefix : ${prefix} Local install : ${with_localinstall} Extra CFlags : ${CPPFLAGS} $MAINTAINER_CFLAGS Extra ValaFlags : ${CPPFLAGS} $MAINTAINER_VALAFLAGS Scopes Directory: ${SCOPESDIR} ]) ./README0000644000004100000410000000000013115304145012106 0ustar www-datawww-data./TESTS-TODO.txt0000644000004100000410000000074013115304145013447 0ustar www-datawww-dataSince testing lenses is dependant on multiple components in the system, we will implement a `unity-tool` to help which will be able to talk to the lenses and examine their results. Here are some of the use-cases it will be used for: 1) Start a domain-specific search which should return non-zero number of results. 2) Start a search with non-sensical string and check that it returns 0 results and that the "no-results-hint" is set in the method reply. More to come... ./COPYING0000644000004100000410000010437413115304145012304 0ustar www-datawww-data GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . ./src/0000755000004100000410000000000013115304145012027 5ustar www-datawww-data./src/folder.vala0000644000004100000410000002717113115304145014157 0ustar www-datawww-data/* * Copyright (C) 2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Mikkel Kamstrup Erlandsen * */ namespace Unity.FilesLens { public class Bookmarks : Object { private List bookmarks; private string bookmarks_file; private FileMonitor monitor; public signal void changed (); public Bookmarks () { bookmarks_file = @"$(Environment.get_home_dir())/.config/gtk-3.0/bookmarks"; update(); /* Update the bookmarks list whener the bookmarks file changes */ try { monitor = File.new_for_path (bookmarks_file).monitor (FileMonitorFlags.NONE); monitor.set_rate_limit (2000); // max 1 update every 2s monitor.changed.connect ((mon, file, other_file, event_type) => { debug ("Bookmarks changed. Updating."); update (); changed (); }); } catch (Error e) { warning ("Failed to install file monitor on %s. Bookmarks monitoring disabled: %s", bookmarks_file, e.message); } } private void update () { bookmarks = new List (); string contents; string desktop_uri; bool has_desktop_in_favourites = false; File desktop_file = File.new_for_path (Environment.get_user_special_dir (UserDirectory.DESKTOP)); desktop_uri = desktop_file.get_uri (); try { FileUtils.get_contents (bookmarks_file, out contents); } catch (FileError e) { warning ("Failed to read favorites: %s", e.message); return; } string[] favorites = contents.split ("\n"); string mimetype = "inode/directory"; foreach (var uri in favorites) { if (uri == "") continue; // Filter out useless bookmark that is created by Nautilus. // https://bugs.launchpad.net/unity-lens-files/+bug/1044309 if (uri.has_prefix("x-nautilus-desktop:")) continue; if (uri == desktop_uri) has_desktop_in_favourites = true; string[] parts = uri.split (" ", 2); string display_name; if (parts.length == 1) { display_name = Uri.unescape_string (uri); display_name = Filename.display_basename (display_name); } else if (parts.length == 2) { uri = parts[0]; display_name = parts[1]; } else { warning ("Internal error computing display name for favorite '%s'", uri); display_name = uri; } var bookmark = new Bookmark (uri, mimetype, display_name); bookmarks.append (bookmark); } /* Add desktop statically */ if (!has_desktop_in_favourites) { var desktop_display_name = Path.get_basename (desktop_file.get_parse_name ()); var desktop_bookmark = new Bookmark (desktop_uri, mimetype, desktop_display_name); bookmarks.append (desktop_bookmark); } } /* makes sure the uris exist on the filesystem (checks only native uris) */ private GLib.List filter_bookmarks (List bm_list) { var result = new GLib.List (); foreach (var bookmark in bm_list) { File f = File.new_for_uri (bookmark.uri); if (f.is_native () && !f.query_exists ()) continue; result.prepend (bookmark); } result.reverse (); return result; } #if 0 private async GLib.List filter_bookmarks_async (owned GLib.List bm_list) { var result = new GLib.List (); foreach (var bookmark in bm_list) { File f = File.new_for_uri (bookmark.uri); if (f.is_native ()) { bool exists; try { var info = yield f.query_info_async (FileAttribute.STANDARD_TYPE, 0, Priority.DEFAULT, null); exists = info.get_file_type () != FileType.UNKNOWN; } catch (Error err) { exists = false; } if (!exists) continue; } result.prepend (bookmark); } result.reverse (); return result; } #endif public List list () { return filter_bookmarks (bookmarks); } public List prefix_search (string search) { var prefix = Utils.normalize_string (search); var matches = new List (); foreach (var bookmark in bookmarks) { foreach (var term in bookmark.get_index_terms ()) { if (term.has_prefix (prefix)) { /* Register a hit for this bookmark */ matches.append (bookmark); break; } } } return filter_bookmarks (matches); } public bool launch_if_bookmark (string uri) throws Error { if (!uri.has_prefix ("bookmark:")) return false; var launcher = AppInfo.get_default_for_type ("inode/directory", true); uri = uri.offset (9); // Remove "bookmark:" prefix from uri if (launcher == null) { warning ("No default handler for inode/directory. Unable to open bookmark '%s'", uri); throw new IOError.FAILED ("No default handler for inode/directory. Unable to open bookmark '%s'", uri); } var uris = new List (); uris.append (uri); launcher.launch_uris (uris, null); return true; } } public class Bookmark : Object { public string uri { get; set construct; } public string icon { get; set construct; } public string mimetype { get; set construct; } public string display_name { get; set construct; } public string dnd_uri { get; set construct; } private List index_terms; public Bookmark (string uri, string mimetype, string display_name) { Object (uri:"bookmark:"+uri, icon:Utils.get_icon_for_uri (uri, mimetype), mimetype:mimetype, display_name:display_name, dnd_uri:uri); index_terms = new List (); index_terms.append (Utils.normalize_string (Path.get_basename (uri))); index_terms.append (Utils.normalize_string (display_name)); } public unowned List get_index_terms () { return index_terms; } public static bool is_bookmark_uri (string uri) { return uri.has_prefix ("bookmark:"); } public static string uri_from_bookmark (string uri) { return uri.substring (9); } } public class Devices : Object { private List devices; private VolumeMonitor volume_monitor; public signal void changed (); public Devices () { volume_monitor = VolumeMonitor.get (); update(); volume_monitor.volume_added.connect ((mon, volume) => { update (); changed (); }); volume_monitor.volume_removed.connect ((mon, volume) => { update (); changed (); }); volume_monitor.volume_changed.connect ((mon, volume) => { update (); changed (); }); } private void update () { devices = new List (); foreach ( Volume volume in volume_monitor.get_volumes ()) { var label = volume.get_identifier (VolumeIdentifier.LABEL); var uuid = volume.get_identifier (VolumeIdentifier.UUID); if ((label == null || label.length == 0) && (uuid == null || uuid.length == 0)) continue; var device = new Device (volume); devices.append (device); } } public List list () { var result = new GLib.List (); foreach (var device in devices) { result.append (device); } return result; } public List search (string search) { var normalized_search = Utils.normalize_string (search); var matches = new List (); foreach (var device in devices) { foreach (var term in device.get_index_terms ()) { if (term.contains (normalized_search)) { matches.append (device); break; } } } return matches; } public bool launch_if_device (string uri) throws Error { if (!Device.is_device_uri (uri)) return false; foreach (var device in devices) { if (device.uri == uri) { device.mount_and_open (); return true; } } return false; } public Device? get_device_from_uri (string uri) { if (!Device.is_device_uri (uri)) return null; foreach (var device in devices) { if (device.uri == uri) return device; } return null; } } public class Device : Object { public Volume volume { get; set construct; } public string name { get; set construct; } public string uri { get; set construct; } public Icon icon { get; set construct; } public string icon_name { get; set construct; } public string display_name { get; set construct; } public string dnd_uri { get; set construct; } private List index_terms_; public Device (Volume volume) { var name = volume.get_name (); var icon = volume.get_icon (); var icon_name = icon.to_string (); var label = volume.get_identifier (VolumeIdentifier.LABEL) ?? ""; var uuid = volume.get_identifier (VolumeIdentifier.UUID) ?? ""; var id = "device://" + uuid + "-" + label; Object (volume:volume, name:name, uri:id, icon:icon,icon_name:icon_name, display_name:name, dnd_uri:id); index_terms_ = new List (); index_terms_.append (Utils.normalize_string (name)); } public unowned List get_index_terms () { return index_terms_; } public static bool is_device_uri (string uri) { return uri.has_prefix ("device://"); } public void mount_and_open () throws Error { if (is_mounted ()) { open_in_file_manager (); } else { volume.mount.begin (MountMountFlags.NONE, null, null, (obj, res) => { try { if (volume.mount.end (res)) open_in_file_manager (); } catch (Error e) { warning ("Failed to mount %s: %s", display_name, e.message); } }); } } private bool is_mounted () { var mount = volume.get_mount (); return mount != null; } private void open_in_file_manager () throws Error { if (!is_mounted ()) return; AppInfo.launch_default_for_uri (get_volume_uri (), null); } private string? get_volume_uri () { var root = get_root_file (); if (root == null) return null; return root.get_uri (); } public File? get_root_file () { if (is_mounted()) { var mount = volume.get_mount (); if (mount == null) return null; return mount.get_root (); } else { return volume.get_activation_root (); } } } } /* end: namespace */ ./src/url-checker.vala0000644000004100000410000000732613115304145015110 0ustar www-datawww-data/* * Copyright (C) 2011 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Mikkel Kamstrup Erlandsen * Modified by Angelo Compagnucci * */ namespace Unity.FilesLens { public enum UrlType { UNKNOWN, WEB, MOUNTABLE; } public class UrlChecker : Object { /* A string serialized GIcon */ public string web_icon { get; private set; } public string mountable_icon { get; private set; } /* Regexes URLs must match */ private Regex web_regex; private Regex mountable_regex; private const string TLD_REGEX = "(ac|ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|" + "as|asia|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|" + "by|bz|ca|cat|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cu|cv|cw|cx|cy|cz|de|" + "dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|" + "gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|info|" + "int|io|iq|ir|is|it|je|jm|jo|jobs|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|" + "li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mobi|mp|mq|mr|ms|mt|" + "mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|" + "pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|" + "sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sx|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|" + "to|tp|tr|travel|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn|xxx|" + "ye|yt|za|zm|zw|local|[0-9]{1,3})"; public UrlChecker () { web_icon = new ThemedIcon ("web-browser").to_string (); mountable_icon = new ThemedIcon ("folder-remote").to_string (); try { web_regex = new Regex ("(http[s]?://.+)|" + "([a-zA-Z0-9\\-\\.]+\\." +TLD_REGEX+ "\\b.*)", RegexCompileFlags.OPTIMIZE); mountable_regex = new Regex ("(\\\\|(ftp|ssh|sftp|smb|dav)://).+"); } catch (RegexError e) { warning ("Error compiling regular expressions for URL matching. URL launching will not work: %s", e.message); } } /* Returns a valid URL if the input looks like it or null otherwise, * returns also url type which can after be used * to retrive corresponding icon */ public string? check_url (string sample, out UrlType url_type) { url_type = UrlType.UNKNOWN; if (sample.strip () == "") return null; if (mountable_regex.match (sample)) { url_type = UrlType.MOUNTABLE; return sample.replace("\\\\","smb://"); } else if (web_regex.match (sample)) { url_type = UrlType.WEB; return sample.has_prefix ("http") ? sample : ("http://" + sample); } return null; } public string get_icon_for_type (UrlType url_type) { switch (url_type) { case UrlType.WEB: return web_icon; case UrlType.MOUNTABLE: return mountable_icon; } return web_icon; } } /* end: class UrlChecker */ } /* end: namespace */ ./src/daemon.vala0000644000004100000410000013730613115304145014151 0ustar www-datawww-data/* * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Mikkel Kamstrup Erlandsen * Michal Hruby * Angelo Compagnucci * */ using Zeitgeist; using Zeitgeist.Timestamp; using Config; using Gee; namespace Unity.FilesLens { const string ICON_PATH = Config.DATADIR + "/icons/unity-icon-theme/places/svg/"; public class Daemon : GLib.Object { private Zeitgeist.Log log; private Zeitgeist.Index index; private Zeitgeist.Monitor monitor; private Bookmarks bookmarks; private Devices devices; private UrlChecker urls; private Unity.DeprecatedScope scope; /* For each section we have a set of Zeitgeist.Event templates that * we use to query Zeitgeist */ private HashTable type_templates; private HashTable download_dir_type_templates; private const string SCHEMA_NAME = "com.canonical.Unity.FilesLens"; private const string USE_LOCATE_KEY = "use-locate"; public bool use_locate { get; set; default = true; } private Settings scope_settings; private Variant empty_asv; construct { empty_asv = new Variant.array (VariantType.VARDICT.element (), {}); prepare_type_templates (); if (SCHEMA_NAME in Settings.list_schemas ()) { scope_settings = new Settings (SCHEMA_NAME); scope_settings.bind (USE_LOCATE_KEY, this, USE_LOCATE_KEY, SettingsBindFlags.GET); } scope = new Unity.DeprecatedScope ("/com/canonical/unity/scope/files", "files-local.scope"); scope.search_in_global = true; scope.search_hint = _("Search Files & Folders"); scope.activate_uri.connect (activate); scope.preview_uri.connect (preview); populate_categories (); populate_filters (); /* Bring up Zeitgeist interfaces */ log = new Zeitgeist.Log (); index = new Zeitgeist.Index (); /* Listen for all file:// related events from Zeitgeist */ var templates = new GenericArray(); var event = new Zeitgeist.Event (); var subject = new Zeitgeist.Subject (); subject.uri = "file://*"; event.add_subject (subject); templates.add (event); monitor = new Zeitgeist.Monitor (new Zeitgeist.TimeRange.from_now (), templates); monitor.events_inserted.connect (on_zeitgeist_changed); monitor.events_deleted.connect (on_zeitgeist_changed); log.install_monitor (monitor); bookmarks = new Bookmarks (); urls = new UrlChecker (); devices = new Devices (); devices.changed.connect (() => { /* make sure our results are fresh */ scope.queue_search_changed (SearchType.DEFAULT); scope.queue_search_changed (SearchType.GLOBAL); }); scope.generate_search_key.connect ((search) => { return search.search_string.strip (); }); /* Listen for changes to the search */ scope.search_changed.connect ((search, search_type, cancellable) => { dispatch_search.begin (search, search_type, cancellable); }); scope.export (); } private async void dispatch_search (DeprecatedScopeSearch scope_search, SearchType search_type, GLib.Cancellable cancellable) { if (search_type == SearchType.GLOBAL) { yield update_global_search_async (scope_search, cancellable); } else { yield update_search_async (scope_search, cancellable); } // make sure we don't forget to emit finished (if we didn't get cancelled) if (!cancellable.is_cancelled ()) { if (scope_search.results_model.get_n_rows () == 0) { scope_search.set_reply_hint ("no-results-hint", _("Sorry, there are no files or folders that match your search.")); } } scope_search.finished (); } private void populate_filters () { var filters = new Unity.FilterSet (); /* Last modified */ { var filter = new RadioOptionFilter ("modified", _("Last modified")); filter.add_option ("last-7-days", _("Last 7 days")); filter.add_option ("last-30-days", _("Last 30 days")); filter.add_option ("last-year", _("Last year")); filters.add (filter); } /* Type filter */ { var filter = new CheckOptionFilter ("type", _("Type")); filter.sort_type = OptionsFilter.SortType.DISPLAY_NAME; filter.add_option ("documents", _("Documents")); filter.add_option ("folders", _("Folders")); filter.add_option ("images", _("Images")); filter.add_option ("audio", _("Audio")); filter.add_option ("videos", _("Videos")); filter.add_option ("presentations", _("Presentations")); filter.add_option ("other", _("Other")); filters.add (filter); } /* Size filter */ { var filter = new MultiRangeFilter ("size", _("Size")); filter.add_option ("1kB", _("1kB")); filter.add_option ("100kB", _("100kB")); filter.add_option ("1MB", _("1MB")); filter.add_option ("10MB", _("10MB")); filter.add_option ("100MB", _("100MB")); filter.add_option ("1GB", _("1GB")); filter.add_option (">1GB", _(">1GB")); filters.add (filter); } scope.filters = filters; } private void populate_categories () { var categories = new Unity.CategorySet (); var icon_dir = File.new_for_path (ICON_PATH); var cat = new Unity.Category ("global", _("Files & Folders"), new FileIcon (icon_dir.get_child ("group-folders.svg"))); categories.add (cat); cat = new Unity.Category ("recent", _("Recent"), new FileIcon (icon_dir.get_child ("group-recent.svg"))); categories.add (cat); cat = new Unity.Category ("downloads", _("Downloads"), new FileIcon (icon_dir.get_child ("group-downloads.svg"))); categories.add (cat); cat = new Unity.Category ("folders", _("Folders"), new FileIcon (icon_dir.get_child ("group-folders.svg"))); categories.add (cat); scope.categories = categories; } private void init_templates (HashTable templates, string manifestation, string uri_prefix) { Event event; Subject sub; /* Section.ALL_FILES */ event = new Event.full("", manifestation, "", ""); sub = new Subject.full(uri_prefix, "", "", "", "", "", ""); event.add_subject(sub); templates["all"] = event; /* Section.DOCUMENTS */ event = new Event.full("", manifestation, "", ""); sub = new Subject.full (uri_prefix, NFO.DOCUMENT, "", "", "", "", ""); event.add_subject(sub); sub = new Subject.full ("", "!"+NFO.PRESENTATION, "", "", "", "", ""); event.add_subject(sub); templates["documents"] = event; /* Section.FOLDERS * - we're using special ORIGIN queries here */ event = new Event.full("", manifestation, "", ""); sub = new Subject.full (uri_prefix, "", "", "", "", "", ""); event.add_subject(sub); templates["folders"] = event; /* Section.IMAGES */ event = new Event.full("", manifestation, "", ""); sub = new Subject.full (uri_prefix, NFO.IMAGE, "", "", "", "", ""); event.add_subject(sub); templates["images"] = event; /* Section.AUDIO */ event = new Event.full("", manifestation, "", ""); sub = new Subject.full (uri_prefix, NFO.AUDIO, "", "", "", "", ""); event.add_subject(sub); templates["audio"] = event; /* Section.VIDEOS */ event = new Event.full("", manifestation, "", "" ); sub = new Subject.full (uri_prefix, NFO.VIDEO, "", "", "", "", ""); event.add_subject(sub); templates["videos"] = event; /* Section.PRESENTATIONS * FIXME: Zeitgeist logger needs to user finer granularity * on classification as I am not sure it uses * NFO.PRESENTATION yet */ event = new Event.full("", manifestation, "", ""); sub = new Subject.full (uri_prefix, NFO.PRESENTATION, "", "", "", "", ""); event.add_subject(sub); templates["presentations"] = event; /* Section.OTHER * Note that subject templates are joined with logical AND */ event = new Event.full("", manifestation, ""); event.add_subject (new Subject.full (uri_prefix, "!"+NFO.DOCUMENT, "", "", "", "", "")); event.add_subject (new Subject.full ("", "!"+NFO.IMAGE, "", "", "", "", "")); event.add_subject (new Subject.full ("", "!"+NFO.AUDIO, "", "", "", "", "")); event.add_subject (new Subject.full ("", "!"+NFO.VIDEO, "", "", "", "", "")); event.add_subject (new Subject.full ("", "!"+NFO.PRESENTATION, "", "", "", "", "")); templates["other"] = event; } private void prepare_type_templates () { type_templates = new HashTable (str_hash, str_equal); init_templates (type_templates, ZG.USER_ACTIVITY, "file:*"); unowned string download_path; download_path = Environment.get_user_special_dir (UserDirectory.DOWNLOAD); if (download_path != null) { download_dir_type_templates = new HashTable (str_hash, str_equal); string download_uri = File.new_for_path (download_path).get_uri (); init_templates (download_dir_type_templates, "", download_uri + "/*"); } } private const string[] ALL_TYPES = { "documents", "folders", "images", "audio", "videos", "presentations", "other" }; private GenericArray? create_template (OptionsFilter? filter, bool downloads_templates) { var templates = new GenericArray (); HashTable? prepared_templates = downloads_templates ? download_dir_type_templates : type_templates; if (prepared_templates == null) return null; if (filter == null || !filter.filtering) { /* Section.ALL_FILES */ templates.add (prepared_templates["all"]); return templates; } string[] types = {}; foreach (unowned string type_id in ALL_TYPES) { var option = filter.get_option (type_id); if (option == null || !option.active) continue; types += type_id; } if (types.length == ALL_TYPES.length) { /* Section.ALL_FILES */ templates.add (prepared_templates["all"]); return templates; } foreach (unowned string type_id in types) { // we need to handle folders separately if (type_id == "folders") continue; templates.add (prepared_templates[type_id]); } return templates; } private bool is_search_empty (DeprecatedScopeSearch search) { if (search.search_string == null) return true; return search.search_string.strip () == ""; } private string prepare_search_string (DeprecatedScopeSearch search) { var s = search.search_string; if (s.has_suffix (" ")) s = s.strip (); if (!s.has_suffix ("*")) s = s + "*"; /* The Xapian query parser (used by the Zeitgeist FTS Extension) seems to * handle hyphens in a special way, namely that it forces the joined * tokens into a phrase query no matter if it appears as the last word * in a query and we have the PARTIAL flag set on the query parser. * This makes 'unity-p' not match 'unity-package-search.cc' etc. */ s = s.delimit ("-", ' '); return s; } private async void update_global_search_async (DeprecatedScopeSearch search, GLib.Cancellable cancellable) { var has_search = !is_search_empty (search); var results_model = search.results_model; /* * For global searches we collate all results under one category heading * called Files & Folders */ try { /* Get results ranked by recency */ var results = yield run_zg_query (search, new Zeitgeist.TimeRange.anytime (), Zeitgeist.ResultType.MOST_RECENT_CURRENT_URI, null, 20, cancellable); results_model.clear (); /* check if the thing typed isn't a url (like facebook.com) * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/ var url_type = UrlType.UNKNOWN; var checked_url = urls.check_url (search.search_string, out url_type); if (checked_url != null) { results_model.append (checked_url, urls.get_icon_for_type(url_type), Categories.FILES_AND_FOLDERS, ResultType.PERSONAL, "text/html", search.search_string, checked_url, checked_url, empty_asv); } var category_id = Categories.FILES_AND_FOLDERS; Set? bookmark_uris = null; if (has_search) { /* add bookmarks first */ GLib.List matching_bookmarks; matching_bookmarks = bookmarks.prefix_search (search.search_string); append_bookmarks (matching_bookmarks, results_model, category_id); /* make sure we don't duplicate the bookmark uris */ bookmark_uris = new Gee.HashSet (); foreach (var bookmark_obj in matching_bookmarks) { /* uri has bookmark: scheme */ bookmark_uris.add (bookmark_obj.dnd_uri); } } var result_flags = has_search ? ResultFlags.EXTRACT_ORIGINS : 0; append_events_sorted (search.search_string, results, results_model, 0, int64.MAX, result_flags, bookmark_uris, category_id); if (has_search) { GLib.List matching_devices; if (has_search) matching_devices = devices.search (search.search_string); else matching_devices = devices.list (); append_devices (matching_devices, results_model, Categories.FILES_AND_FOLDERS); } /* Add downloads catagory if we don't have a search */ if (has_search == false) { results = yield run_zg_query (search, new Zeitgeist.TimeRange.anytime (), Zeitgeist.ResultType.MOST_RECENT_CURRENT_URI, null, 40, cancellable, true); append_events_sorted (search.search_string, results, results_model, 0, int64.MAX, ResultFlags.NONE, null, Categories.DOWNLOADS); } if (has_search && use_locate) { yield perform_locate (search, 500, search.search_string, search.results_model, cancellable, Categories.FILES_AND_FOLDERS, Categories.FILES_AND_FOLDERS); } } catch (IOError.CANCELLED ioe) { return; } catch (GLib.Error e) { warning ("Error performing global search '%s': %s", search.search_string, e.message); } } private async void update_search_async (DeprecatedScopeSearch search, GLib.Cancellable cancellable) { var results_model = search.results_model; var txn = new Dee.Transaction (results_model); var has_search = !is_search_empty (search); var filter = search.get_filter ("type") as OptionsFilter; var active_filters = get_current_types (search); bool only_folders = active_filters != null && active_filters.length == 1 && active_filters[0] == "folders"; uint timer_id = 0; try { /* Get results ranked by recency */ Zeitgeist.ResultSet? results = null; if (!only_folders) { results = yield run_zg_query (search, get_current_timerange (search), Zeitgeist.ResultType.MOST_RECENT_CURRENT_URI, filter, 50, cancellable); } txn.clear (); /* check if the thing typed isn't a url (like facebook.com) * or isn't a remote mountable url (like ftp://ftp.ubuntu.com)*/ var url_type = UrlType.UNKNOWN; var checked_url = urls.check_url (search.search_string, out url_type); if (checked_url != null) { txn.append (checked_url, urls.get_icon_for_type(url_type), Categories.RECENT, ResultType.PERSONAL, "text/html", search.search_string, checked_url, checked_url, empty_asv); } /* apply filters to results found by zeitgeist */ int64 min_size, max_size; get_current_size_limits (search, out min_size, out max_size); if (results != null) { append_events_sorted (search.search_string, results, txn, min_size, max_size, ResultFlags.SKIP_FOLDERS); } /* get recently downloaded files */ results = yield run_zg_query (search, get_current_timerange (search), Zeitgeist.ResultType.MOST_RECENT_CURRENT_URI, filter, 50, cancellable, true); append_events_sorted (search.search_string, results, txn, min_size, max_size, ResultFlags.NONE, null, Categories.DOWNLOADS); /* commit if the origin query is taking too long, if we committed right * away, we'd cause flicker */ if (txn.get_n_rows () > 0) { /* here be something magical */ timer_id = Timeout.add (200, () => { if (!cancellable.is_cancelled () && !txn.is_committed ()) { txn.commit (); } timer_id = 0; return false; }); } /* folders are last category we need, update the model directly */ if (filter == null || !filter.filtering || filter.get_option ("folders").active) { results = yield run_zg_query (search, get_current_timerange (search), Zeitgeist.ResultType.MOST_RECENT_ORIGIN, null, 50, cancellable); if (!txn.is_committed ()) txn.commit (); /* add bookmarks first */ GLib.List matching_bookmarks; if (has_search) matching_bookmarks = bookmarks.prefix_search (search.search_string); else matching_bookmarks = bookmarks.list (); append_bookmarks (matching_bookmarks, results_model, Categories.FOLDERS); /* make sure we don't duplicate the bookmark uris */ var bookmark_uris = new Gee.HashSet (); foreach (var bookmark_obj in matching_bookmarks) { /* uri has bookmark: scheme */ bookmark_uris.add (bookmark_obj.dnd_uri); } append_events_sorted (search.search_string, results, results_model, min_size, max_size, ResultFlags.USE_ORIGIN, bookmark_uris); GLib.List matching_devices; if (has_search) matching_devices = devices.search (search.search_string); else matching_devices = devices.list (); append_devices (matching_devices, results_model, Categories.FOLDERS); } else { /* just commit */ if (!txn.is_committed ()) txn.commit (); } if (has_search && use_locate) { yield perform_locate (search, 500, search.search_string, search.results_model, cancellable); } } catch (IOError.CANCELLED ioe) { return; } catch (GLib.Error e) { /* if we weren't cancelled, commit the transaction */ warning ("Error performing global search '%s': %s", search.search_string, e.message); if (!txn.is_committed ()) txn.commit (); } finally { if (timer_id != 0) Source.remove (timer_id); } } private string[]? get_current_types (DeprecatedScopeSearch search) { /* returns null if the filter is disabled / all options selected */ var filter = search.get_filter ("type") as CheckOptionFilter; if (filter == null || !filter.filtering) return null; string[] types = {}; foreach (unowned string type_id in ALL_TYPES) { var option = filter.get_option (type_id); if (option == null || !option.active) continue; types += type_id; } if (types.length == ALL_TYPES.length) return null; return types; } private TimeRange get_current_timerange (DeprecatedScopeSearch search) { var filter = search.get_filter ("modified") as RadioOptionFilter; Unity.FilterOption? option = filter.get_active_option (); string date = option == null ? "all" : option.id; if (date == "last-7-days") return new TimeRange (Timestamp.from_now() - Timestamp.WEEK, Timestamp.from_now ()); else if (date == "last-30-days") return new TimeRange (Timestamp.from_now() - (Timestamp.WEEK * 4), Timestamp.from_now()); else if (date == "last-year") return new TimeRange (Timestamp.from_now() - Timestamp.YEAR, Timestamp.from_now ()); else return new TimeRange.anytime (); } private void get_current_size_limits (DeprecatedScopeSearch search, out int64 min_size, out int64 max_size) { var filter = search.get_filter ("size") as MultiRangeFilter; Unity.FilterOption? min_opt = filter.get_first_active (); Unity.FilterOption? max_opt = filter.get_last_active (); if (min_opt == null || max_opt == null) { min_size = 0; max_size = int64.MAX; return; } int64[] sizes = { 0, 1000, 100000, 1000000, 10000000, 100000000, 1000000000, int64.MAX }; switch (min_opt.id) { case "1kB": min_size = sizes[0]; break; case "100kB": min_size = sizes[1]; break; case "1MB": min_size = sizes[2]; break; case "10MB": min_size = sizes[3]; break; case "100MB": min_size = sizes[4]; break; case "1GB": min_size = sizes[5]; break; case ">1GB": min_size = sizes[6]; break; default: warn_if_reached (); min_size = 0; break; } switch (max_opt.id) { case "1kB": max_size = sizes[1]; break; case "100kB": max_size = sizes[2]; break; case "1MB": max_size = sizes[3]; break; case "10MB": max_size = sizes[4]; break; case "100MB": max_size = sizes[5]; break; case "1GB": max_size = sizes[6]; break; case ">1GB": max_size = sizes[7]; break; default: warn_if_reached (); max_size = int64.MAX; break; } } private async Zeitgeist.ResultSet? run_zg_query ( DeprecatedScopeSearch search, TimeRange time_range, Zeitgeist.ResultType result_type, OptionsFilter? filters, uint num_results, GLib.Cancellable cancellable, bool downloads_only = false) throws Error { Zeitgeist.ResultSet results; var timer = new Timer (); var templates = create_template (filters, downloads_only); if (templates == null) return null; /* Copy the templates to a PtrArray which libzg expects */ var ptr_arr = new GenericArray(); for (int i = 0; i < templates.length; i++) { ptr_arr.add (templates[i]); } /* Get results ranked by recency */ if (is_search_empty (search)) { results = yield log.find_events (time_range, ptr_arr, Zeitgeist.StorageState.ANY, num_results, result_type, cancellable); } else { var search_string = prepare_search_string (search); results = yield index.search (search_string, time_range, ptr_arr, 0, // offset num_results, result_type, cancellable); } debug ("Found %u/%u no search results in %fms", results.size (), results.estimated_matches (), timer.elapsed()*1000); return results; } private void append_bookmarks (GLib.List bookmarks, Dee.Model results_model, Categories category) { foreach (var bookmark in bookmarks) { results_model.append (bookmark.uri, bookmark.icon, category, ResultType.PERSONAL, bookmark.mimetype, bookmark.display_name, "", bookmark.dnd_uri, empty_asv); } } private void append_devices (GLib.List devices, Dee.Model results_model, Categories category) { foreach (var device in devices) { results_model.append (device.uri, device.icon_name, category, ResultType.PERSONAL, "", device.display_name, "", device.dnd_uri, empty_asv); } } private async void perform_locate (DeprecatedScopeSearch search, uint timeout, string query, Dee.Model results_model, GLib.Cancellable cancellable, int files_category = Categories.RECENT, int dirs_category = Categories.FOLDERS) throws Error { cancellable.set_error_if_cancelled (); // throws IOError /* Wait a while before starting the locate search */ uint timer_src_id = Timeout.add_full (Priority.LOW, timeout, perform_locate.callback); var canc_id = cancellable.connect (() => { if (timer_src_id != 0) Source.remove (timer_src_id); timer_src_id = 0; // can't invoke directly, the disconnect call would deadlock Idle.add_full (Priority.DEFAULT, perform_locate.callback); }); yield; cancellable.disconnect (canc_id); if (timer_src_id != 0) Source.remove (timer_src_id); cancellable.set_error_if_cancelled (); // throws IOError var results = yield Locate.locate (query, cancellable); results.sort (Utils.cmp_file_info_by_mtime); /* make a list of uris we already have */ var present_uris = new Gee.HashSet (); var model_iter = results_model.get_first_iter (); var model_end_iter = results_model.get_last_iter (); while (model_iter != model_end_iter) { present_uris.add (results_model.get_string (model_iter, 0)); model_iter = results_model.next (model_iter); } var timerange = get_current_timerange (search); int64 min_size, max_size; get_current_size_limits (search, out min_size, out max_size); var types = get_current_types (search); foreach (var info in results) { var uri = info.get_data ("associated-gfile").get_uri (); warn_if_fail (uri != null); if (uri == null || uri in present_uris) continue; var mimetype = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE); var icon_hint = Utils.check_icon_string (uri, mimetype, info); // check if we match the timerange uint64 mtime = info.get_attribute_uint64 (FileAttribute.TIME_MODIFIED) * 1000; if (mtime < timerange.start || mtime > timerange.end) continue; // check if type matches if (types != null && !Utils.file_info_matches_any (info, types)) continue; // check if size is within bounds int64 size = info.get_size (); if (size < min_size || size > max_size) continue; uint category_id = mimetype == "inode/directory" ? dirs_category : files_category; results_model.append (uri, icon_hint, category_id, ResultType.PERSONAL, mimetype, info.get_display_name (), "", uri, empty_asv); } } private void count_directory_items (string top_path, ref int count, ref uint64 total_size, bool recurse=false) throws GLib.Error { var dir = GLib.File.new_for_path (top_path); var file_iter = dir.enumerate_children (GLib.FileAttribute.STANDARD_SIZE, GLib.FileQueryInfoFlags.NONE); //follow symlinks GLib.FileInfo? info = null; GLib.Queue? dirs = null; do { info = file_iter.next_file (); if (info != null) { count++; if (info.get_file_type () == GLib.FileType.REGULAR) { total_size += info.get_size (); } else { if (info.get_file_type () == GLib.FileType.DIRECTORY && recurse) { if (dirs == null) { dirs = new GLib.Queue (); } dirs.push_tail (info.get_name()); } } } } while (info != null); file_iter.close(); if (dirs != null) { while (!dirs.is_empty()) { string path = top_path + "/" + dirs.pop_head (); count_directory_items (path, ref count, ref total_size, recurse); } } } public Unity.Preview preview (string uri) { debug ("Previewing: %s", uri); Unity.GenericPreview preview = null; string real_uri; if (Bookmark.is_bookmark_uri (uri)) { real_uri = Bookmark.uri_from_bookmark (uri); } else if (Device.is_device_uri (uri)) { preview = create_device_preview (uri); return preview; } else { real_uri = uri; } var file = GLib.File.new_for_uri (real_uri); if (file != null) { GLib.FileInfo finfo = null; try { finfo = file.query_info ("*", GLib.FileQueryInfoFlags.NONE); } catch (GLib.Error e) { warning ("Error getting file info for '%s': %s", uri, e.message); } if (finfo != null) { preview = new Unity.GenericPreview (finfo.get_name (), "", null); if (Bookmark.is_bookmark_uri (uri)) { preview.image_source_uri = Bookmark.uri_from_bookmark (uri); } else { preview.image_source_uri = uri; } GLib.TimeVal mtime = finfo.get_modification_time (); var date_time = new GLib.DateTime.from_timeval_local (mtime); if (date_time != null) { preview.subtitle = date_time.format ("%x, %X"); } var email_app_info = GLib.AppInfo.get_default_for_uri_scheme ("mailto"); string mime_type = finfo.get_content_type (); preview.add_info (new InfoHint ("format", _("Format"), null, GLib.ContentType.get_description (mime_type))); var open_action = new Unity.PreviewAction ("open", _("Open"), null); open_action.activated.connect (on_preview_open); preview.add_action (open_action); uint64 total_size = 0; if (finfo.get_file_type () == GLib.FileType.DIRECTORY) { if (file.get_path () != null) { int count = 0; try { count_directory_items (file.get_path (), ref count, ref total_size); } catch (GLib.Error e) { warning ("Error encounted when counting directory items for path '%s': %s", file.get_path(), e.message); } preview.add_info (new InfoHint ("size", _("Size"), null, _("%s, %u items").printf (GLib.format_size (total_size), count))); } else { warning ("No such uri '%s'\n", uri); } } else // single file preview { total_size = finfo.get_size (); preview.add_info (new InfoHint ("size", _("Size"), null, GLib.format_size (total_size))); var open_folder_action = new Unity.PreviewAction ("open-dir", _("Show in Folder"), null); open_folder_action.activated.connect (on_preview_open_folder); preview.add_action (open_folder_action); if (email_app_info != null) { var email_action = new Unity.PreviewAction ("email", _("Email"), null); email_action.activated.connect (on_email_file); preview.add_action (email_action); } } try { var path = Path.get_dirname (Filename.from_uri (real_uri)); var home = Environment.get_home_dir (); if (path.has_prefix (home)) { var relative_path = path.substring (home.length); if (relative_path[0] == '\0') { path = _("Home"); } else { path = "~" + relative_path; } } preview.add_info (new InfoHint ("path", _("Path"), null, path)); } catch (Error e) { warning ("Failed to get path for '%s': %s", real_uri, e.message); } } else { warning ("Couldn't stat file: '%s'", real_uri); } } else { warning ("Couldn't access file: '%s'", real_uri); } return preview; } private Unity.GenericPreview? create_device_preview (string uri) { var device = devices.get_device_from_uri (uri); if (device == null) return null; Unity.GenericPreview preview = new Unity.GenericPreview (device.display_name, "", device.icon); int contents_count = 0; uint64 contents_size = 0; string filesystem_type = ""; uint64 total_capacity = 0; uint64 free_capacity = 0; try { var file = device.get_root_file (); var file_info = file.query_filesystem_info (GLib.FileAttribute.FILESYSTEM_SIZE + "," + GLib.FileAttribute.FILESYSTEM_TYPE + "," + GLib.FileAttribute.FILESYSTEM_FREE, null); count_directory_items (file.get_path (), ref contents_count, ref contents_size, false); filesystem_type = file_info.get_attribute_as_string (GLib.FileAttribute.FILESYSTEM_TYPE); total_capacity = file_info.get_attribute_uint64 (GLib.FileAttribute.FILESYSTEM_SIZE); free_capacity = file_info.get_attribute_uint64 (GLib.FileAttribute.FILESYSTEM_FREE); contents_size = total_capacity - free_capacity; } catch (Error e) { warning ("Failed to query filesystem info: %s", e.message); } preview.subtitle = _("Total capacity %s").printf (GLib.format_size(total_capacity)); preview.add_info (new InfoHint ("filesytem_type", _("Filesystem type"), null, filesystem_type)); preview.add_info (new InfoHint ("contents", _("Contents"), null, _("%s, %u items").printf (GLib.format_size (contents_size), contents_count))); var open_action = new Unity.PreviewAction ("open", _("Open"), null); open_action.activated.connect (on_preview_open); preview.add_action (open_action); return preview; } public Unity.ActivationResponse on_email_file (string uri) { debug (@"Emailing file: $uri"); var email_app_info = GLib.AppInfo.get_default_for_uri_scheme ("mailto"); if (email_app_info != null) { try { var files = new GLib.List (); files.append (GLib.File.new_for_uri (uri)); email_app_info.launch (files, null); } catch (Error e) { warning ("Couldn't launch email application '%s': '%s'", email_app_info.get_executable (), e.message); } } return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH); } public Unity.ActivationResponse on_preview_open (string uri) { try { if (bookmarks.launch_if_bookmark (uri) || devices.launch_if_device (uri) || GLib.AppInfo.launch_default_for_uri (uri, null)) { return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH); } } catch (GLib.Error e) { warning ("Failed to launch default application for uri '%s': %s", uri, e.message); } return new Unity.ActivationResponse(Unity.HandledType.NOT_HANDLED); } public Unity.ActivationResponse on_preview_open_folder (string uri) { var file_manager = AppInfo.get_default_for_type("inode/directory", true); var uris = new GLib.List (); uris.append (uri); try { if (file_manager.launch_uris (uris, null)) return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH); } catch (GLib.Error e) { warning ("Failed to launch default application for uri '%s': %s", uri, e.message); } return new Unity.ActivationResponse(Unity.HandledType.NOT_HANDLED); } public Unity.ActivationResponse activate (string uri) { debug (@"Activating: $uri"); try { if (bookmarks.launch_if_bookmark (uri) || devices.launch_if_device (uri)) return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH); /* this code ensures that a file manager will be used * * if uri it's a remote location that should be mounted */ var url_type = UrlType.UNKNOWN; var checked_url = urls.check_url (uri, out url_type); if (checked_url != null && url_type == UrlType.MOUNTABLE) { var muris = new GLib.List(); muris.prepend (uri); var file_manager = AppInfo.get_default_for_type("inode/directory", true); file_manager.launch_uris(muris,null); return new Unity.ActivationResponse(Unity.HandledType.HIDE_DASH); } } catch (GLib.Error error) { warning ("Failed to launch URI %s", uri); } return new Unity.ActivationResponse (Unity.HandledType.NOT_HANDLED); } private void on_zeitgeist_changed () { /* make sure our results are fresh */ scope.queue_search_changed (SearchType.DEFAULT); scope.queue_search_changed (SearchType.GLOBAL); } private const string ATTRS_TYPE_HIDDEN = FileAttribute.STANDARD_TYPE + "," + FileAttribute.STANDARD_IS_HIDDEN; private const string ATTRS_TYPE_SIZE_HIDDEN = FileAttribute.STANDARD_TYPE + "," + FileAttribute.STANDARD_SIZE + "," + FileAttribute.STANDARD_IS_HIDDEN; [Flags] public enum ResultFlags { NONE = 0, USE_ORIGIN, EXTRACT_ORIGINS, SKIP_FOLDERS, } /* Appends a set of Zeitgeist.Events to our Dee.Model assuming that * these events are already sorted with descending timestamps */ public void append_events_sorted (string search_string, Zeitgeist.ResultSet? events, Dee.Model results, int64 min_size, int64 max_size, ResultFlags flags, Gee.Set? excluded_uris = null, int category_override = -1) { if (events == null) return; uint category_id; Set? extracted_directories = null; if (ResultFlags.EXTRACT_ORIGINS in flags) { var folded_search = search_string.casefold (); var origins = new HashSet (); // loop through all found events, take a look at origin field, add it // to result set if it matches our search // NOTE: using separate zg query with MOST_RECENT_ORIGINS grouping // is more likely to find relevant directories, but is much slower // than this kind of "approximation" foreach (var ev in events) { if (ev.num_subjects () > 0) { string origin = ev.get_subject (0).origin; if (origin == null || origin == "") continue; var f = File.new_for_uri (origin); origin = f.get_uri (); if (excluded_uris != null && origin in excluded_uris) continue; if (!(origin in origins) && f.is_native () && f.query_exists ()) { string? path = f.get_path (); if (path != null && path.contains ("/.")) continue; var display_name = Path.get_basename (f.get_parse_name ()); if (display_name.casefold ().has_prefix (folded_search)) { string mimetype = "inode/directory"; string icon = Utils.get_icon_for_uri (origin, mimetype); if (category_override >= 0) category_id = category_override; else category_id = Categories.FOLDERS; results.append (origin, icon, category_id, ResultType.PERSONAL, mimetype, display_name, "", origin, empty_asv); } else { if (extracted_directories == null) { extracted_directories = new HashSet (); } extracted_directories.add (origin); } origins.add (origin); } } } // we need this because of way ResultSet works with foreach if (events.size () > 0) events.reset (); } foreach (var ev in events) { if (ev.num_subjects () > 0) { // FIXME: We only use the first subject... Zeitgeist.Subject su = ev.get_subject (0); string uri; string display_name; string mimetype; if (ResultFlags.USE_ORIGIN in flags) { uri = su.origin; display_name = ""; mimetype = "inode/directory"; } else { uri = su.current_uri; display_name = su.text; mimetype = su.mimetype; mimetype = su.mimetype != null ? su.mimetype : "application/octet-stream"; } if (uri == null) continue; File file = File.new_for_uri (uri); if (excluded_uris != null && file.get_uri () in excluded_uris) continue; if (display_name == null || display_name == "") { display_name = Path.get_basename (file.get_parse_name ()); } bool check_size = min_size > 0 || max_size < int64.MAX; /* Don't check existence on non-native files as http:// and * friends are *very* expensive to query */ FileType file_type = FileType.UNKNOWN; if (file.is_native ()) { // hidden files should be ignored try { FileInfo info = file.query_info (check_size ? ATTRS_TYPE_SIZE_HIDDEN : ATTRS_TYPE_HIDDEN, 0, null); string? path = file.get_path (); if (path != null && path.contains ("/.")) continue; if (check_size && (info.get_size () < min_size || info.get_size () > max_size)) { continue; } file_type = info.get_file_type (); } catch (GLib.Error e) { // as error occurred file must be missing therefore ignoring it continue; } } string icon = Utils.get_icon_for_uri (uri, mimetype); string comment = file.get_parse_name (); var is_dir = file_type == FileType.DIRECTORY; if (is_dir && ResultFlags.SKIP_FOLDERS in flags) continue; if (category_override >= 0) category_id = category_override; else category_id = is_dir ? Categories.FOLDERS : Categories.RECENT; results.append (uri, icon, category_id, ResultType.PERSONAL, mimetype, display_name, comment, uri, empty_asv); } } if (extracted_directories != null) { foreach (var dir_uri in extracted_directories) { var f = File.new_for_uri (dir_uri); var display_name = Path.get_basename (f.get_parse_name ()); string mimetype = "inode/directory"; string icon = Utils.get_icon_for_uri (dir_uri, mimetype); if (category_override >= 0) category_id = category_override; else category_id = Categories.FOLDERS; results.append (dir_uri, icon, category_id, ResultType.PERSONAL, mimetype, display_name, "", dir_uri, empty_asv); } } } } } /* namespace */ ./src/blacklist-tracker.vala0000644000004100000410000000731313115304145016301 0ustar www-datawww-data/* * Copyright (C) 2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Michal Hruby * */ using Zeitgeist; using Config; using Gee; namespace Unity.FilesLens { /* Libzeitgeist currently doesn't expose any blacklist API, so we need to * use direct dbus calls */ [DBus (name = "org.gnome.zeitgeist.Blacklist")] public interface Blacklist : Object { [DBus (signature = "a{s(asaasay)}")] public abstract async Variant get_templates () throws Error; public signal void template_added (string template_id, [DBus (signature = "(asassay)")] Variant template); public signal void template_removed (string template_id, [DBus (signature = "(asassay)")] Variant template); } public class BlacklistTracker : Object { private HashTable event_templates; private Blacklist blacklist_proxy; private Set blacklisted_uris; private bool cached_uris_dirty; construct { event_templates = new HashTable (str_hash, str_equal); blacklisted_uris = new HashSet (); Bus.get_proxy (BusType.SESSION, "org.gnome.zeitgeist.Engine", "/org/gnome/zeitgeist/blacklist", 0, null, (src, res) => { try { blacklist_proxy = (src as DBusConnection).get_proxy.end (res); fetch_blacklists (); } catch (GLib.Error err) { warning ("%s", err.message); } }); } private async void fetch_blacklists () { blacklist_proxy.template_added.connect (this.template_added); blacklist_proxy.template_removed.connect (this.template_removed); Variant all_templates = yield blacklist_proxy.get_templates (); VariantIter iter = new VariantIter (all_templates); string template_id; Variant event_variant; while (iter.next ("{s@(asaasay)}", out template_id, out event_variant)) { Event e = new Event.from_variant (event_variant); event_templates[template_id] = e; } cached_uris_dirty = true; } private void template_added (string id, Variant template) { Event e = new Event.from_variant (template); event_templates[id] = e; cached_uris_dirty = true; } private void template_removed (string id, Variant template) { event_templates.remove (id); cached_uris_dirty = true; } private void update_uris () { var iter = HashTableIter (event_templates); unowned Event e; while (iter.next (null, out e)) { if (e.num_subjects () > 0) { Subject s = e.get_subject (0); string uri = s.uri; if (uri == null || uri == "") continue; if (uri.has_suffix ("*")) { blacklisted_uris.add (uri.substring (0, uri.length - 1)); } } } } public unowned Set get_blacklisted_uris () { if (cached_uris_dirty) { blacklisted_uris.clear (); update_uris (); cached_uris_dirty = false; } return blacklisted_uris; } } } /* namespace */ ./src/config.vala.in0000644000004100000410000000050413115304145014545 0ustar www-datawww-datanamespace Config { const string PREFIX = "@prefix@"; const string DATADIR = "@DATADIR@"; const string PKGDATADIR = "@DATADIR@/unity"; const string BINDIR = "@prefix@/bin"; const string LOCALEDIR = "@DATADIR@/locale"; const string PACKAGE = "@PACKAGE@"; const string VERSION = "@VERSION@"; } ./src/schemas.vala0000644000004100000410000000147613115304145014327 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Mikkel Kamstrup Erlandsen * */ namespace Unity.FilesLens { public enum Categories { FILES_AND_FOLDERS, RECENT, DOWNLOADS, FOLDERS, } } ./src/locate.vala0000644000004100000410000000654413115304145014154 0ustar www-datawww-data/* * Copyright (C) 2010-2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Michal Hruby * */ using Zeitgeist; using Config; using Gee; namespace Unity.FilesLens.Locate { const uint MAX_RESULTS = 128; /* Careful about usage of FileAttribute.STANDARD_ICON, this is the same as * requesting FileAttribute.STANDARD_CONTENT_TYPE and causes reading * of the target file, we just want to stat it */ const string ATTRIBS = FileAttribute.STANDARD_IS_HIDDEN + "," + FileAttribute.STANDARD_IS_BACKUP + "," + FileAttribute.STANDARD_DISPLAY_NAME + "," + FileAttribute.STANDARD_SIZE + "," + FileAttribute.TIME_MODIFIED + "," + FileAttribute.THUMBNAIL_PATH + "," + FileAttribute.ACCESS_CAN_WRITE + "," + FileAttribute.STANDARD_FAST_CONTENT_TYPE; private BlacklistTracker blacklist_tracker; public async GLib.SList locate (string input_query, GLib.Cancellable cancellable) throws Error { if (blacklist_tracker == null) blacklist_tracker = new BlacklistTracker (); var result = new GLib.SList (); var query = Regex.escape_string (input_query.strip ()); // FIXME: we could limit the search to specific directories, but using regex // matching slows down the search considerably string[] argv = { "locate", "-i", "-e", "-l", "%u".printf (MAX_RESULTS), "*%s*".printf (query.replace (" ", "*")) }; Pid pid; int read_fd; string? line = null; Process.spawn_async_with_pipes (null, argv, null, SpawnFlags.SEARCH_PATH, null, out pid, null, out read_fd); UnixInputStream read_stream = new UnixInputStream (read_fd, true); DataInputStream locate_output = new DataInputStream (read_stream); do { line = yield locate_output.read_line_async (Priority.DEFAULT_IDLE, cancellable); if (line == null) break; if ("/." in line) continue; // we don't want no hidden files var file = File.new_for_path (line); var uri = file.get_uri (); bool skip = false; foreach (var blacklisted_uri in blacklist_tracker.get_blacklisted_uris ()) { if (uri.has_prefix (blacklisted_uri)) { skip = true; break; } } if (skip) continue; var fi = yield file.query_info_async (ATTRIBS, 0, Priority.DEFAULT_IDLE, cancellable); if (fi.get_is_hidden () || fi.get_is_backup () || !fi.get_attribute_boolean (FileAttribute.ACCESS_CAN_WRITE)) continue; fi.set_data ("associated-gfile", file); result.prepend (fi); } while (line != null); result.reverse (); return result; } } /* namespace */ ./src/utils.vala0000644000004100000410000003341013115304145014035 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Mikkel Kamstrup Erlandsen * */ using GLib; using Zeitgeist; using Gee; using Dee; namespace Unity.FilesLens.Utils { const string icon_attribs = FileAttribute.PREVIEW_ICON + "," + FileAttribute.STANDARD_ICON + "," + FileAttribute.THUMBNAIL_PATH; const string file_attribs = FileAttribute.STANDARD_NAME + "," + FileAttribute.STANDARD_DISPLAY_NAME + "," + FileAttribute.STANDARD_CONTENT_TYPE + "," + FileAttribute.STANDARD_IS_HIDDEN + "," + FileAttribute.STANDARD_IS_BACKUP + "," + FileAttribute.STANDARD_SIZE + "," + FileAttribute.TIME_MODIFIED + "," + FileAttribute.TIME_ACCESS; const string hide_attribs = FileAttribute.STANDARD_IS_BACKUP + "," + FileAttribute.STANDARD_IS_HIDDEN; const string all_attribs = icon_attribs + "," + file_attribs + "," + hide_attribs; /* Synchronous method to query GIO for a good icon for a uri/mimetype */ public string get_icon_for_uri (string uri, string mimetype) { try { File f = File.new_for_uri (uri); /* Don't query icons or thumbnails for non-local files, * http:// and friends are *very* expensive */ if (!f.is_native()) return ContentType.get_icon(mimetype).to_string(); FileInfo info = f.query_info (icon_attribs, FileQueryInfoFlags.NONE, null); return check_icon_string (uri, mimetype, info); } catch (GLib.Error e) { /* We failed to probe the icon. Try looking up by mimetype instead */ Icon icon2 = ContentType.get_icon (mimetype); return icon2.to_string (); } } /* Async method to query GIO for a good icon for a uri/mimetype */ public async string get_icon_for_uri_async (string uri, string mimetype) { try { File f = File.new_for_uri (uri); FileInfo info = yield f.query_info_async (icon_attribs, FileQueryInfoFlags.NONE, Priority.LOW, null); return check_icon_string (uri, mimetype, info); } catch (GLib.Error e) { /* We failed to probe the icon. Try looking up by mimetype instead */ Icon icon2 = ContentType.get_icon (mimetype); return icon2.to_string (); } } public string check_icon_string (string uri, string mimetype, FileInfo info) { Icon icon = info.get_icon (); string thumbnail_path = info.get_attribute_byte_string (FileAttribute.THUMBNAIL_PATH); if (thumbnail_path == null && icon != null) return icon.to_string (); else if (icon == null) return ContentType.get_icon (mimetype).to_string (); else return new FileIcon (File.new_for_path (thumbnail_path)).to_string (); } public int cmp_file_info_by_mtime (FileInfo info1, FileInfo info2) { TimeVal tv1, tv2; tv1 = info1.get_modification_time (); tv2 = info2.get_modification_time (); long cmp = tv1.tv_sec - tv2.tv_sec; return cmp < 0 ? 1 : ( cmp > 0 ? -1 : 0); } public string get_month_name (DateMonth month) { switch (month) { case DateMonth.BAD_MONTH: return _("Invalid Month"); case DateMonth.JANUARY: return _("January"); case DateMonth.FEBRUARY: return _("February"); case DateMonth.MARCH: return _("March"); case DateMonth.APRIL: return _("April"); case DateMonth.MAY: return _("May"); case DateMonth.JUNE: return _("June"); case DateMonth.JULY: return _("July"); case DateMonth.AUGUST: return _("August"); case DateMonth.SEPTEMBER: return _("September"); case DateMonth.OCTOBER: return _("October"); case DateMonth.NOVEMBER: return _("November"); case DateMonth.DECEMBER: return _("December"); } return "Internal Error"; } public string get_day_name (DateWeekday weekday) { switch (weekday) { case GLib.DateWeekday.MONDAY: return _("Monday"); case GLib.DateWeekday.TUESDAY: return _("Tuesday"); case GLib.DateWeekday.WEDNESDAY: return _("Wednesday"); case GLib.DateWeekday.THURSDAY: return _("Thursday"); case GLib.DateWeekday.FRIDAY: return _("Friday"); case GLib.DateWeekday.SATURDAY: return _("Saturday"); case GLib.DateWeekday.SUNDAY: return _("Sunday"); default: return "Internal Error"; } } #if 0 /* Calculate the time group of the event returning the group id * of the group @event belongs to. It may be necessary for this method * to add a row to @groups_model if the group is one of the variadic * types such as */ public uint get_time_group (Zeitgeist.Event event, Dee.Model groups_model, out string comment=null) { // FIXME: We need to calculate bounds of previous midnight, week, month etc // This impl is just a quick hack to have something to show var t = event.get_timestamp (); var now = Timestamp.now (); var delta = now - t; /* Set limit to the previous midnight */ var limit = Timestamp.prev_midnight (now); if (t > limit) { /* Fuzzy hour match */ var hour = Timestamp.HOUR; if (delta > hour * 7) comment = _("Earlier today"); else if (delta > hour * 6) comment = _("Five hours ago"); else if (delta > hour * 5) comment = _("Four hours ago"); else if (delta > hour * 4) comment = _("Three hours ago"); else if (delta > hour * 3) comment = _("Two hours ago"); else if (delta > hour * 2) comment = _("1 hour ago"); else comment = _("Past hour"); return Group.TODAY; } else if (t > limit - Zeitgeist.Timestamp.DAY) { comment = _("Yesterday"); return Group.YESTERDAY; } /* Set limit to start of calendar week (monday) */ var date = Date(); Timestamp.to_date (now, out date); limit = limit - (date.get_weekday() - 1)*Timestamp.DAY; /* Try and give the name of the day */ var datethen = Date (); Timestamp.to_date (t, out datethen); comment = get_day_name (datethen.get_weekday ()); if (t > limit) return Group.THIS_WEEK; else if (t > limit - Zeitgeist.Timestamp.WEEK) return Group.LAST_WEEK; /* Set limit to start of current calendar month */ date.set_day (1); limit = Timestamp.from_date (date); if (t > limit) { var days = datethen.days_between (date); /* Try and give a fuzzy weeks time */ if (days < 7 * 3) comment = _("Three weeks ago"); else if (days < 7 * 4) comment = _("A month ago"); return Group.THIS_MONTH; } /* At this point let's just fall back to month name */ comment = get_month_name (datethen.get_month ()); /* Set limit to start of previous calendar month */ date.subtract_months (1); limit = Timestamp.from_date (date); if (t > now - 6*30*Zeitgeist.Timestamp.DAY) { return Group.PAST_SIX_MONTHS; } /* Set limit to 1st pf January in the current year. We need to * reset 'date' because date.subtract_months(1) above might have * turned a year */ Timestamp.to_date (now, out date); date.set_month (DateMonth.JANUARY); date.set_day (1); limit = Timestamp.from_date (date); if (t > limit) { return Group.THIS_YEAR; } else return Group.LAST_YEAR; } #endif private async SList list_dir_internal (File folder, string? name_filter) throws Error { string? filter = null; if (name_filter != null) filter = name_filter.strip ().casefold (); var result = new SList (); var e = yield folder.enumerate_children_async (Utils.all_attribs, 0, Priority.DEFAULT, null); while (true) { var file_infos = yield e.next_files_async (10, Priority.DEFAULT, null); if (file_infos == null) break; foreach (var info in file_infos) { if (info.get_is_hidden() || info.get_is_backup ()) continue; if (filter != null && info.get_display_name ().casefold ().index_of (filter) < 0) continue; var colkey = info.get_display_name().collate_key_for_filename (); info.set_attribute_string ("unity::collation-key", colkey); result.prepend (info); } } /* No need to reverse the result list even though we prepend to it, * we are going to re-sort it now anyway */ CompareFunc cmpfunc = (info1, info2) => { return GLib.strcmp ((info1 as FileInfo).get_attribute_string("unity::collation-key"), (info2 as FileInfo).get_attribute_string("unity::collation-key")); }; result.sort (cmpfunc); return result; } /** * Asynchronously list the contents of a directory given by a path, * and return a list of FileInfos filled with the attributes specified * by Utils.all_attribs */ public async SList list_dir (File folder) throws Error { return yield list_dir_internal (folder, null); } /** * Similar to list_dir, but only return list of FileInfos matching * name_filter name. */ public async SList list_dir_filtered (File folder, string name_filter) throws Error { return yield list_dir_internal (folder, name_filter); } public bool file_info_matches_any (FileInfo info, string[] types) { foreach (unowned string type_id in types) { if (file_info_matches_type (info, type_id)) return true; } return false; } public bool file_info_matches_type (FileInfo info, string type_id) { unowned string interpretation; unowned string content_type = info.get_content_type (); if (content_type == null) content_type = info.get_attribute_string (FileAttribute.STANDARD_FAST_CONTENT_TYPE); if (content_type == null) content_type = "application/octet-stream"; interpretation = Zeitgeist.interpretation_for_mimetype (content_type); if (interpretation == null) return type_id == "other" || type_id == "all"; /* type_id is one of: documents, folders, images, audio, videos, * presentations, other */ switch (type_id) { case "documents": return Zeitgeist.Symbol.is_a (interpretation, Zeitgeist.NFO.DOCUMENT) && !Zeitgeist.Symbol.is_a (interpretation, Zeitgeist.NFO.PRESENTATION); case "folders": return content_type == "inode/directory"; case "images": return Zeitgeist.Symbol.is_a (interpretation, Zeitgeist.NFO.IMAGE); case "audio": return Zeitgeist.Symbol.is_a (interpretation, Zeitgeist.NFO.AUDIO); case "videos": return Zeitgeist.Symbol.is_a (interpretation, Zeitgeist.NFO.VIDEO); case "presentations": return Zeitgeist.Symbol.is_a (interpretation, Zeitgeist.NFO.PRESENTATION); case "other": bool is_recognized = false; is_recognized |= content_type == "inode/directory"; // DOCUMENT includes PRESENTATION is_recognized |= Zeitgeist.Symbol.is_a (interpretation, Zeitgeist.NFO.DOCUMENT); // MEDIA includes AUDIO, VIDEO, IMAGE is_recognized |= Zeitgeist.Symbol.is_a (interpretation, Zeitgeist.NFO.MEDIA); return !is_recognized; case "all": return true; default: warning ("Unrecognized type: \"%s\"", type_id); return false; } } /* Extract a hash set of all subject uris in a Zeitgeist.ResultSet */ public Set get_uri_set (Zeitgeist.ResultSet results) { Set uris = new HashSet (); foreach (var ev in results) { for (int i = 0; i < ev.num_subjects(); i++) uris.add (ev.get_subject (i).uri); } return uris; } public string normalize_string (string input) { return input.normalize (-1, NormalizeMode.ALL_COMPOSE).casefold (); } } /* namespace */ ./src/Makefile.am0000644000004100000410000000271113115304145014064 0ustar www-datawww-dataNULL = BUILT_SOURCES = CLEANFILES = EXTRA_DIST = DATADIR = $(datadir) pkglibexec_PROGRAMS = \ unity-files-daemon AM_CFLAGS = -w unity_files_daemon_CPPFLAGS = \ -DDATADIR=\"$(DATADIR)\" \ -DPKGDATADIR=\"$(PKGDATADIR)\" \ -DGETTEXT_PACKAGE=\"$(GETTEXT_PACKAGE)\" \ -DG_LOG_DOMAIN=\"unity-files-daemon\" \ $(SCOPE_DAEMON_CFLAGS) \ $(MAINTAINER_CFLAGS) \ -I$(srcdir) \ -g unity_files_daemon_VALAFLAGS = \ -C \ --pkg dee-1.0 \ --pkg zeitgeist-2.0 \ --pkg unity \ --pkg gee-0.8 \ --pkg gio-2.0 \ --pkg gio-unix-2.0 \ --target-glib=2.26 \ $(MAINTAINER_VALAFLAGS) unity_files_daemon_LDADD = \ $(SCOPE_DAEMON_LIBS) \ $(NULL) unity_files_daemon_VALASOURCES = \ blacklist-tracker.vala \ config.vala \ daemon.vala \ folder.vala \ locate.vala \ main.vala \ schemas.vala \ url-checker.vala \ utils.vala \ $(NULL) unity_files_daemon_SOURCES = \ $(unity_files_daemon_VALASOURCES:.vala=.c) \ $(NULL) BUILT_SOURCES += unity_files_daemon.vala.stamp EXTRA_DIST += \ unity_files_daemon.vala.stamp \ $(unity_files_daemon_VALASOURCES) \ $(NULL) # Major hack alert: https://bugzilla.gnome.org/show_bug.cgi?id=621292 # Introduced because of our requirements for the GLIB_2_22 define. See above. unity_files_daemon.vala.stamp: $(unity_files_daemon_VALASOURCES) $(AM_V_GEN) $(VALAC) $(unity_files_daemon_VALAFLAGS) $^ @touch $@ CLEANFILES += \ *.stamp \ *.vapi \ $(unity_files_daemon_VALASOURCES:.vala=.c) \ $(NULL) ./src/main.vala0000644000004100000410000000761313115304145013627 0ustar www-datawww-data/* * Copyright (C) 2010 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Mikkel Kamstrup Erlandsen * */ using GLib; using Config; namespace Unity.FilesLens { static const string DBUS_NAME = "com.canonical.Unity.Scope.LocalFiles"; static Application? app = null; static Daemon? daemon = null; /* Check if a given well known DBus is owned. * WARNING: This does sync IO! */ public static bool dbus_name_has_owner (string name) { try { bool has_owner; DBusConnection bus = Bus.get_sync (BusType.SESSION); Variant result = bus.call_sync ("org.freedesktop.DBus", "/org/freedesktop/dbus", "org.freedesktop.DBus", "NameHasOwner", new Variant ("(s)", name), new VariantType ("(b)"), DBusCallFlags.NO_AUTO_START, -1); result.get ("(b)", out has_owner); return has_owner; } catch (IOError e) { warning ("Unable to decide whether '%s' is running: %s", name, e.message); } return false; } public static int main (string[] args) { /* Sort up locale to get translations but also sorting and * punctuation right */ GLib.Intl.textdomain (Config.PACKAGE); GLib.Intl.bindtextdomain (Config.PACKAGE, Config.LOCALEDIR); GLib.Intl.bind_textdomain_codeset (Config.PACKAGE, "UTF-8"); GLib.Intl.setlocale(GLib.LocaleCategory.ALL, ""); /* Make sure the desktop appinfos are picked up correctly */ DesktopAppInfo.set_desktop_env ("GNOME"); /* Sub processes inheriting our environment may be confused if they * see a starter bus set */ Environment.unset_variable ("DBUS_STARTER_ADDRESS"); Environment.unset_variable ("DBUS_STARTER_BUS_TYPE"); /* Workaround for https://bugzilla.gnome.org/show_bug.cgi?id=640714 * GApplication.register() call owns our DBus name in a sync manner * making it race against GDBus' worker thread to export our * objects on the bus before/after owning our name and receiving * method calls on our objects (which may not yet be up!)*/ if (dbus_name_has_owner (DBUS_NAME)) { print ("Another instance of the Unity Files Daemon " + "already appears to be running.\nBailing out.\n"); return 2; } /* Now register our DBus objects *before* acquiring the name! * See above for reasons */ daemon = new Daemon (); /* Use GApplication directly for single instance app functionality */ app = new Application (DBUS_NAME, ApplicationFlags.IS_SERVICE); try { app.register (); } catch (Error e) { /* FIXME: We get this error if another daemon is already running, * but it uses a generic error so we can't detect this reliably... */ print ("Failed to start files daemon: %s\n", e.message); return 1; } if (app.get_is_remote ()) { print ("Another instance of the Unity Files Daemon " + "already appears to be running.\nBailing out.\n"); return 2; } /* Hold()ing the app makes sure the GApplication doesn't exit */ app.hold(); return app.run (); } } /* namespace */ ./local.scope.in.in0000644000004100000410000000101013115304145014367 0ustar www-datawww-data[Scope] DBusName=com.canonical.Unity.Scope.LocalFiles DBusPath=/com/canonical/unity/scope/files Icon=@prefix@/share/unity/icons/lens-nav-file.svg _Name=Files & Folders Type=files _Description=This is an Ubuntu search plugin that enables local files to be searched and displayed in the Dash underneath the Files & Folders header. If you do not wish to search this content source, you can disable this search plugin. _SearchHint=Search Files & Folders Shortcut=f [Desktop Entry] X-Ubuntu-Gettext-Domain=unity-lens-files ./autogen.sh0000755000004100000410000000027313115304145013243 0ustar www-datawww-data#!/bin/sh srcdir=`dirname $0` PKG_NAME="unity-place-files" which gnome-autogen.sh || { echo "You need gnome-common from GNOME SVN" exit 1 } USE_GNOME2_MACROS=1 \ . gnome-autogen.sh ./files.png0000644000004100000410000000341213115304145013050 0ustar www-datawww-dataPNG  IHDR00 1 bKGD) oFFsuG pHYsHHFk> vpAg441 EIDATXåϋdW?s߫,43Qu?1 ,Ew Yĭnd!nDbd"3 !z|][^UWn}Op#o PD tX{K(ov"ߟ@; T$` %lk+ ԝib8/I@O$8/G\{!2zb8jD*$[)N8b`mB N$]% ),(l @DPTT@'Jzkðk[?P40~4,JOT'I -_Nv(z hhjHWUML)n_}TRA*3J#FF E_L(2^nҫ$BVZҊQAQ+teҚpcl gr°̀JAaԨV3jgu ~=.$ue'RZ,4B#cu=6+_C`;vR/",AaР+Zy[Eryk|eRUdS+I{|/N!>מ99HBa_5~Ư ^"W5“4xR]cL@@7xB"ou ET]"͏FQQyxӅ,[Ut,`G.ڏ w2 ~qEd -vb{]&z|qx1|? ٦Kx$wC^.w7?mwėAm}7W*S_r n_TI62Sm[ yWOtY?i8kȉI-hA*?yw@ERQP6_ŧG8_Gyx] * configure.ac: Bump libzeitgeist dep to 0.2.1 as 0.2.0 had a bad integer overflow bug causing time range queries to go askew 2010-06-18 Mikkel Kamstrup Erlandsen * configure.ac: * src/daemon.vala: * src/schemas.vala: * src/utils.vala: Merge bzr merge lp:~anjali-team/anjali/unity-place-files.groups. Bumps libzeitgeist dep to 0.2.0 and enables a *prototype** implementation of the time based grouping of files. The grouping is not accurate nor to the spec, but is good enough for the gui to have something to play around with for now 2010-06-17 Mikkel Kamstrup Erlandsen * configure.ac: Bump libzeitgeist dep to 0.2.0 2010-06-17 Mikkel Kamstrup Erlandsen * src/daemon.vala: * src/schemas.vala: * src/utils.vala: First prototype of time grouping complete. The grouping is *not* complete or to the spec, but is there for Neil to have something to play with 2010-06-17 Mikkel Kamstrup Erlandsen * src/daemon.vala: Populate the groups model with all months ahead of time because we are going to need them anyway 2010-06-17 Mikkel Kamstrup Erlandsen * src/daemon.vala: * src/utils.vala: Start adding the right time based grouping 2010-06-18 Mikkel Kamstrup Erlandsen * src/utils.vala: * configure.ac: * src/Makefile.am: * src/daemon.vala: Merge bzr merge lp:~anjali-team/anjali/unity-place-files.search. Enabling the SetSearch() and SetGlobalSearch() methods in the DBus API. Note that you need Zeitgeist 0.4.0 or later running with the FTS extension in order for this to work 2010-06-16 Mikkel Kamstrup Erlandsen * src/utils.vala: * src/Makefile.am: * src/daemon.vala: Moce unused, but useful, code ti utils.vala 2010-06-16 Mikkel Kamstrup Erlandsen * src/daemon.vala: Search results for SetSearch() and SetGlobalSearch() are now added to their respective Dee.SharedModels (thus shared on the bus) 2010-06-16 Mikkel Kamstrup Erlandsen * configure.ac: * src/daemon.vala: DBus calls to SetSearch() and SetGlobalSearch() getting through and result in an actual call against ZG FTS. The Dee models are still not populated, but we are getting there... 2010-06-16 Mikkel Kamstrup Erlandsen * src/Makefile.am: * src/daemon.vala: * src/schemas.vala: Merge lp:~anjali-team/anjali/unity-place-files.sections enabling the sections- and groups- models. You can also update the results model by setting the section of the files place entry 2010-06-14 Mikkel Kamstrup Erlandsen * src/daemon.vala: Restrict to subjects of URI file:*. We can't solely rely on NFO_FILE_DATA_OBJECT as NFO_REMOTE_FILE_DATA_OBJECT is also a child of this type 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: w00t! sections actually work (not exactly as specced, but somewhere close to that) 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: Fix memory corruption due to the fact that GPtrArray doesn't ref objects when you add them. Vala doesn't like that... 2010-06-11 Mikkel Kamstrup Erlandsen * src/Makefile.am: * src/daemon.vala: * src/schemas.vala: Hook up infrastructure for section shuffling 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: Add link to ZG bug reporthttps://bugs.launchpad.net/zeitgeist/+bug/592599 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: Build a list of event templates to use in the query indexed by section id 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: Grab a Zeitgeist.Index() so we can do full text search on ZG 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: Export the Unity.Place.Controller as the last thing in the Daemon constructor to ensure that all the Dee.SharedModels are up when the place is "ready" 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: * src/schemas.vala: Fill out the sections model and entry goups model on construction of the Daemon 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: * src/main.vala: Upgrade to work against libzeitgeist 0.1.1 2010-06-11 Mikkel Kamstrup Erlandsen * src/daemon.vala: * src/Makefile.am: * src/main.vala: * src/model-schemas.vala: * src/schemas.vala: Refactor: pull Daemon class out into its own .vala file so that main.vala only contains... well... main() :-) Rename model-schemas.vala to just schemas.vala 2010-06-10 Neil Jagdish Patel * files.place.in: * src/main.vala: - Update files.place.in with new key names - Update main.vala to export with correct name (.Unity. instead of .unity.) 2010-06-09 Mikkel Kamstrup Erlandsen * src/common: * src/files: * src/test: * src/test/main.vala: * NEWS: * configure.ac: * src/Makefile.am: * src/common/config.vala.in: * src/config.vala.in: * src/common/model-schemas.vala: * src/model-schemas.vala: * src/files/main.vala: * src/main.vala: Flatten src/ dir and ensure distcheck passes. Clean up unused files. Bump version to 0.3.1 2010-06-09 Mikkel Kamstrup Erlandsen * NEWS: Post 0.3.0 tag 2010-06-08 Mikkel Kamstrup Erlandsen * src/files/main.vala: No more g_criticals() or g_warnings() on stderr... Vala *really* doesn't like anonymous variables... The following diff makes all the difference: - templates.add (new Zeitgeist.Event ()); + var event = new Zeitgeist.Event (); + templates.add (event); 2010-06-08 Mikkel Kamstrup Erlandsen * src/files/main.vala: Almost working again now, modulo Vala oddness 2010-06-08 Mikkel Kamstrup Erlandsen * src/common/daemon.vala: * src/Makefile.am: Remove the old helper class Unity.Place.Daemon from the build as it's not all handled inside libunity 2010-06-07 Mikkel Kamstrup Erlandsen * configure.ac: * files.place.in: * src/Makefile.am: * src/common/model-schemas.vala: * src/files/main.vala: Refactor to new libunity place daemon impl. Works module the fact that libunity doesn't ship a .pc file yet, meaning that automagic fails to detect libunity 2010-06-07 Mikkel Kamstrup Erlandsen * src/common/config.vala.in: * configure.ac: * src/Makefile.am: Auto-magic to generate a config.vala and include that in the build 2010-06-01 Mikkel Kamstrup Erlandsen * src/test: * src/test/main.vala: Initial import of (working!!) Vala/DBus prototype of the Place API 2010-05-27 Mikkel Kamstrup Erlandsen * src/common/daemon.vala: * src/files/main.vala: Silence some cast-warnings from valac (requires yet to be released Dee 0.2.1) 2010-05-27 Mikkel Kamstrup Erlandsen * configure.ac: * src/Makefile.am: * src/common/daemon.vala: * src/files/main.vala: Port from DbusModel to Dee 2010-04-29 Mikkel Kamstrup Erlandsen * AUTHORS: * COPYING: * ChangeLog: * MAINTAINERS: * Makefile.am: * NEWS: * README: * autogen.sh: * configure.ac: * files.place.in: * src: * src/Makefile.am: * src/common: * src/common/daemon.vala: * src/common/model-schemas.vala: * src/files: * src/files/main.vala: Initial project setup of a Unity Place Daemon providing recently used files. At the time of writing we require dbusmodel trunk and libzeitgeist trunk in order to work. ./tests/0000755000004100000410000000000013115304145012402 5ustar www-datawww-data./tests/test-url-checker.vala0000644000004100000410000001050313115304145016427 0ustar www-datawww-data/* * Copyright (C) 2012 Canonical Ltd * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * Authored by Michal Hruby * */ using Unity.FilesLens; using Assertions; public class Main { public static int main (string[] args) { Test.init (ref args); Test.add_data_func ("/Unit/UrlChecker/WebUris", test_web_uris); Test.add_data_func ("/Unit/UrlChecker/MountableUris", test_mountable_uris); Test.run (); return 0; } private static void test_web_uris () { string result; var checker = new UrlChecker (); UrlType url_type; result = checker.check_url ("facebook.com", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.WEB); assert_cmpstr (result, OperatorType.EQUAL, "http://facebook.com"); result = checker.check_url ("google.co.uk", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.WEB); assert_cmpstr (result, OperatorType.EQUAL, "http://google.co.uk"); result = checker.check_url ("http://www.bbc.co.uk", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.WEB); assert_cmpstr (result, OperatorType.EQUAL, "http://www.bbc.co.uk"); result = checker.check_url ("https://launchpad.net", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.WEB); assert_cmpstr (result, OperatorType.EQUAL, "https://launchpad.net"); result = checker.check_url ("https://code.launchpad.net/unity-lens-files", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.WEB); assert_cmpstr (result, OperatorType.EQUAL, "https://code.launchpad.net/unity-lens-files"); result = checker.check_url ("google.com/?q=unity-lens-files", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.WEB); assert_cmpstr (result, OperatorType.EQUAL, "http://google.com/?q=unity-lens-files"); result = checker.check_url ("192.168.0.1", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.WEB); assert_cmpstr (result, OperatorType.EQUAL, "http://192.168.0.1"); result = checker.check_url ("daemon.vala", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.UNKNOWN); assert_cmpstr (result, OperatorType.EQUAL, null); result = checker.check_url ("non-existing-tld.qv", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.UNKNOWN); assert_cmpstr (result, OperatorType.EQUAL, null); } private static void test_mountable_uris () { string result; var checker = new UrlChecker (); UrlType url_type; result = checker.check_url ("\\\\smb_share", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.MOUNTABLE); assert_cmpstr (result, OperatorType.EQUAL, "smb://smb_share"); result = checker.check_url ("smb://another_share", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.MOUNTABLE); assert_cmpstr (result, OperatorType.EQUAL, "smb://another_share"); result = checker.check_url ("ftp://mozilla.org", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.MOUNTABLE); assert_cmpstr (result, OperatorType.EQUAL, "ftp://mozilla.org"); result = checker.check_url ("ssh://a.server.somewhere", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.MOUNTABLE); assert_cmpstr (result, OperatorType.EQUAL, "ssh://a.server.somewhere"); result = checker.check_url ("sftp://secure.mozilla.org", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.MOUNTABLE); assert_cmpstr (result, OperatorType.EQUAL, "sftp://secure.mozilla.org"); result = checker.check_url ("dav://dav.share.co.uk", out url_type); assert_cmpint (url_type, OperatorType.EQUAL, UrlType.MOUNTABLE); assert_cmpstr (result, OperatorType.EQUAL, "dav://dav.share.co.uk"); } } ./tests/assertions.vapi0000644000004100000410000000133413115304145015456 0ustar www-datawww-data[CCode (cprefix = "G", lower_case_cprefix = "g_", cheader_filename = "glib.h")] namespace Assertions { public enum OperatorType { [CCode (cname = "==")] EQUAL, [CCode (cname = "!=")] NOT_EQUAL, [CCode (cname = "<")] LESS_THAN, [CCode (cname = ">")] GREATER_THAN, [CCode (cname = "<=")] LESS_OR_EQUAL, [CCode (cname = ">=")] GREATER_OR_EQUAL } public void assert_cmpstr (string? s1, OperatorType op, string? s2); public void assert_cmpint (int n1, OperatorType op, int n2); public void assert_cmpuint (uint n1, OperatorType op, uint n2); public void assert_cmphex (uint n1, OperatorType op, uint n2); public void assert_cmpfloat (float n1, OperatorType op, float n2); } ./tests/manual/0000755000004100000410000000000013115304145013657 5ustar www-datawww-data./tests/manual/downloads.txt0000644000004100000410000000052213115304145016411 0ustar www-datawww-dataDownloads ========= Tests that the downloads category shows files from your ~/Downloads directory. #. Create a file in the ~/Downloads category (or equivalent for your locale). #. Search for this file with files lens. Outcome The file you created in the first step should show up as a result in the Downloads category of files lens. ./tests/manual/misc.txt0000644000004100000410000000126113115304145015353 0ustar www-datawww-dataHidden files / dirs are not displayed ------------------------------------- Test that hidden files, hidden folders, or normal files in hidden folders are not displayed in search results. Setup: Create a few combinations of hidden files/folders using nautilus (CTRL+H in nautilus to view hidden files), e.g. ~/.Foo/bar.txt, ~/.foo.txt, ~/.Foo/bar/baz.txt. Update locatedb (e.g. sudo /etc/cron.daily/mlocate). Actions: Type search queries such as "Foo", "bar", "baz" in the dash search query. Expected Result: Verify none of the newly created hidden files are displayed in the Dash home view with empty search. Verify none of the hidden files are displayed after entering a search query. ./tests/manual/locate.txt0000644000004100000410000000132413115304145015667 0ustar www-datawww-dataLocate scope ============ Tests that the built-in locate scope works. Search ------ #. Create a file named "report.txt" in your home directory (`touch report.txt`). #. Run updatedb (`sudo updatedb`). #. Search for this file with files lens. Outcome The "report.txt" should show up as a result in the Recent category of files lens. Privacy ------- #. Open the "Privacy" application and add your home directory to the list of folders that shouldn't be monitored. #. Create a file named "report.txt" in your home directory (`touch report.txt`). #. Run updatedb (`sudo updatedb`). #. Search for this file with files lens. Outcome The "report.txt" should NOT show up as a result in any of the categories of files lens. ./tests/manual/moving.txt0000644000004100000410000000070413115304145015720 0ustar www-datawww-dataMove events =========== Tests that moving files using Nautilus get picked up by Zeitgeist and therefore by files lens. #. Create a file named "report.txt" in your home directory (`touch report.txt`). #. Open nautilus and move the file to a different directory. #. Search for this file with files lens. Outcome The "report.txt" should show up as a result in the Recent category of files lens and clicking on it should open it from the new location. ./tests/manual/folders.txt0000644000004100000410000000267113115304145016064 0ustar www-datawww-dataFolders ======= Tests that global searches find folders as well as files. #. Open the Dash. #. Perform a generic search in the home view. (for example 'd') Outcome You should see "Files and Folders" category with both folders starting with 'd' (including "Desktop"), followed by files containing 'd' or residing in a folder with 'd' in name. File system icons - Plug ---------------------------------------------------- Tests that file system icons are shown in the "Folder" category. Actions: #. Plug a USB flash drive. #. Open files lens. #. Expand "Folder" category. Expected Result: You should see the icon of the USB flash drive in the "Folders" category. File system icons - Click ---------------------------------------------------- Test that file system icons can be mounted and are opened in the file manager. Actions: #. Plug a USB flash drive. #. Open files lens. #. Expand "Folder" category. #. Click on the icon of the USB flash drive. Expected Result: The file manager should be opened showing the content of the USB flash drive. File system icons - Unplug ---------------------------------------------------- Test that file system icons are removed from the "Folder" category. Actions: #. Plug a USB flash drive. #. Open files lens. #. Expand "Folder" category. #. Make sure you see the icon of the USB flash drive. #. Unplug the USB flash drive. Expected Result: Make sure the icon is correctly removed from the "Folder" category. ./tests/Makefile.am0000644000004100000410000000063713115304145014444 0ustar www-datawww-datacheck_PROGRAMS = test-url-checker TESTS = $(check_PROGRAMS) AM_CPPFLAGS = \ -w \ $(SCOPE_DAEMON_CFLAGS) \ $(NULL) AM_VALAFLAGS = \ --pkg gio-2.0 \ $(srcdir)/assertions.vapi \ $(NULL) test_libs = \ $(SCOPE_DAEMON_LIBS) \ $(NULL) test_url_checker_LDADD = $(test_libs) test_url_checker_SOURCES = \ test-url-checker.vala \ $(top_srcdir)/src/url-checker.vala \ $(NULL) CLEANFILES = *.stamp ./po/0000755000004100000410000000000013115304145011656 5ustar www-datawww-data./po/POTFILES.skip0000644000004100000410000000004513115304145013772 0ustar www-datawww-datasrc/main.c src/daemon.c src/utils.c ./po/POTFILES.in0000644000004100000410000000014513115304145013433 0ustar www-datawww-data[encoding: UTF-8] src/daemon.vala src/utils.vala src/main.vala [type: gettext/ini]local.scope.in.in ./po/LINGUAS0000644000004100000410000000000413115304145012675 0ustar www-datawww-datada ./po/da.po0000644000004100000410000001024513115304145012604 0ustar www-datawww-data# Danish translation for unity-place-files # Copyright (c) 2010 Rosetta Contributors and Canonical Ltd 2010 # This file is distributed under the same license as the unity-place-files package. # FIRST AUTHOR , 2010. # msgid "" msgstr "" "Project-Id-Version: unity-place-files\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2010-08-23 21:08+0200\n" "PO-Revision-Date: 2010-08-23 19:54+0000\n" "Last-Translator: Mikkel Kamstrup Erlandsen \n" "Language-Team: Danish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Launchpad-Export-Date: 2010-08-25 07:12+0000\n" "X-Generator: Launchpad (build Unknown)\n" #: ../src/daemon.vala:276 msgid "All Files" msgstr "Alle filer" #: ../src/daemon.vala:278 msgid "Documents" msgstr "Dokumenter" #: ../src/daemon.vala:280 msgid "Folders" msgstr "Mapper" #: ../src/daemon.vala:282 msgid "Images" msgstr "Billeder" #: ../src/daemon.vala:284 msgid "Audio" msgstr "Lyd" #: ../src/daemon.vala:286 msgid "Videos" msgstr "Video" #: ../src/daemon.vala:288 msgid "Presentations" msgstr "Præsentationer" #: ../src/daemon.vala:290 msgid "Other" msgstr "Andet" #: ../src/daemon.vala:309 msgid "Top Results" msgstr "Topresultater" #: ../src/daemon.vala:312 msgid "Recent" msgstr "Seneste" #: ../src/daemon.vala:315 msgid "Downloads" msgstr "Downloads" #: ../src/daemon.vala:318 msgid "Favorite Folders" msgstr "Favoritmapper" #: ../src/daemon.vala:321 msgid "Files" msgstr "Filer" #: ../src/daemon.vala:330 msgid "Today" msgstr "I dag" #: ../src/daemon.vala:333 msgid "Yesterday" msgstr "I går" #: ../src/daemon.vala:336 msgid "This week" msgstr "Denne uge" #: ../src/daemon.vala:339 msgid "Last Week" msgstr "Sidste uge" #: ../src/daemon.vala:342 msgid "This Month" msgstr "Denne måned" #: ../src/daemon.vala:345 msgid "Past Six Months" msgstr "Sidste seks måneder" #: ../src/daemon.vala:348 msgid "This Year" msgstr "I år" #: ../src/daemon.vala:351 msgid "Last Year" msgstr "Sidste år" #: ../src/daemon.vala:983 msgid "You search did not match any files" msgstr "Din søgning matchede ingen filer" #: ../src/daemon.vala:993 msgid "Search the web" msgstr "Søg på nettet" #: ../src/daemon.vala:1009 ../src/daemon.vala:1034 msgid "files" msgstr "filer" #: ../src/daemon.vala:1012 msgid "documents" msgstr "dokumenter" #: ../src/daemon.vala:1015 msgid "folders" msgstr "mapper" #: ../src/daemon.vala:1018 msgid "images" msgstr "billeder" #: ../src/daemon.vala:1021 msgid "audio files" msgstr "lydfiler" #: ../src/daemon.vala:1024 msgid "videos" msgstr "videofiler" #: ../src/daemon.vala:1027 msgid "presentations" msgstr "præsentationer" #: ../src/daemon.vala:1030 msgid "other files" msgstr "andre filer" #: ../src/daemon.vala:1042 msgid "There are no $section_name in your Home folder" msgstr "Der er ingen $section_name i din hjemmemappe" #: ../src/utils.vala:101 msgid "Invalid Month" msgstr "Ugyldig måned" #: ../src/utils.vala:103 msgid "January" msgstr "Januar" #: ../src/utils.vala:105 msgid "February" msgstr "Februar" #: ../src/utils.vala:107 msgid "March" msgstr "Marts" #: ../src/utils.vala:109 msgid "April" msgstr "April" #: ../src/utils.vala:111 msgid "May" msgstr "Maj" #: ../src/utils.vala:113 msgid "June" msgstr "Juni" #: ../src/utils.vala:115 msgid "July" msgstr "Juli" #: ../src/utils.vala:117 msgid "August" msgstr "August" #: ../src/utils.vala:119 msgid "September" msgstr "September" #: ../src/utils.vala:121 msgid "October" msgstr "Oktober" #: ../src/utils.vala:123 msgid "November" msgstr "November" #: ../src/utils.vala:125 msgid "December" msgstr "December" #: ../src/main.vala:51 msgid "" "Another Files Place daemon appears to be running.\n" "Bailing out." msgstr "" "Der kører allerede en anden fildæmon.\n" "Afslutter." #: ../src/main.vala:55 #, c-format msgid "" "Error connecting to session bus: %s.\n" "Bailing out." msgstr "" "Fejl ved opkobling til sessionsbus: %s.\n" "Afslutter." #. namespace #: ../files.place.in.in.h:1 msgid "Files & Folders" msgstr "Filer og mapper" #: ../files.place.in.in.h:2 msgid "Find documents, downloads, and other files" msgstr "Find dokumenter, downloads og andre filer" ./MAINTAINERS0000644000004100000410000000014413115304145012734 0ustar www-datawww-dataMikkel Kamstrup Erlandsen Michal Hruby ./Makefile.am0000644000004100000410000000171313115304145013276 0ustar www-datawww-dataSUBDIRS = src data po tests # # Install the local.scope file # scope_in_files = local.scope.in scopedir = $(SCOPESDIR)/files scope_DATA = $(scope_in_files:.scope.in=.scope) icondir = $(datadir)/unity/themes icon_DATA = files.png @INTLTOOL_SCOPE_RULE@ DISTCHECK_CONFIGURE_FLAGS = --enable-localinstall # ChangeLog file created at distcheck time dist-hook: @if test -d "$(srcdir)/.bzr"; \ then \ echo Creating ChangeLog && \ ( cd "$(top_srcdir)" && \ echo '# Generated by Makefile. Do not edit.'; echo; \ $(top_srcdir)/missing --run bzr log --gnu-changelog ) > ChangeLog.tmp \ && mv -f ChangeLog.tmp $(top_distdir)/ChangeLog \ || (rm -f ChangeLog.tmp; \ echo Failed to generate ChangeLog >&2 ); \ else \ echo Failed to generate ChangeLog: not a branch >&2; \ fi EXTRA_DIST = \ autogen.sh \ files.png \ $(scope_in_files) \ AUTHORS \ COPYING \ MAINTAINERS \ README CLEANFILES = \ $(scope_DATA) ./AUTHORS0000644000004100000410000000014513115304145012310 0ustar www-datawww-dataMikkel Kamstrup Erlandsen Michal Hruby ./data/0000755000004100000410000000000013115304145012151 5ustar www-datawww-data./data/unity-scope-files-local.service.in0000644000004100000410000000014213115304145020604 0ustar www-datawww-data[D-BUS Service] Name=com.canonical.Unity.Scope.LocalFiles Exec=@pkglibexecdir@/unity-files-daemon ./data/com.canonical.Unity.FilesLens.gschema.xml.in.in0000644000004100000410000000067513115304145023021 0ustar www-datawww-data true Use locate during searches. Use locate during searches to make sure the lens is able to find most of their files even it they're not logged by Zeitgeist. ./data/Makefile.am0000644000004100000410000000122013115304145014200 0ustar www-datawww-datadbus_servicesdir = $(DBUSSERVICEDIR) service_in_files = unity-scope-files-local.service.in dbus_services_DATA = $(service_in_files:.service.in=.service) %.service: %.service.in sed -e "s|\@pkglibexecdir\@|$(pkglibexecdir)|" $< > $@ ############################################################# # GSettings schemas ############################################################# gsettings_SCHEMAS = com.canonical.Unity.FilesLens.gschema.xml @INTLTOOL_XML_NOMERGE_RULE@ @GSETTINGS_RULES@ EXTRA_DIST = \ com.canonical.Unity.FilesLens.gschema.xml.in.in \ $(service_in_files) CLEANFILES = \ unity-scope-files-local.service \ $(gsettings_SCHEMAS)