Showing posts with label nautilus-sendto. Show all posts
Showing posts with label nautilus-sendto. Show all posts

01 February, 2012

PackageKit in Cheese

As I already mentioned in one of my last posts, the sharing functionality in Cheese uses nautilus-sendto, which is a runtime dependency, and we wanted to do it our best to let the user/developer/maintainer know about it:


  2. By writing a comment in the README file.

  3. By using PackageKit to install the package at runtime. If the package is not installed, and the user tries to use the sharing functionality, PackageKit will be used to install it at runtime. 

The adventure
The PackageKit bit has been quite challenging for me, and I have to admit that it took me much longer than expected :(! I have learned a lot of new things though!

The first problem I had, was that I spent a few days working on dbus-glib, which I later discovered through Dave, that was deprecated. The source of the problem and biggest issue for me was, that both of the examples I followed in the PackageKit FAQ and the Vala tutorial, were obsolete and using dbus-glib. I have already talked with Richard Hughes about the first example and marked the second one as obsolete in the Vala tutorial wiki.

After this discovery, I started using the C API and the org.freedesktop.PackageKit.Transaction interface, which offers the InstallPackages method. I realised of course, that all the examples I looked at, used the org.freedesktop.PackageKit.Modify interface instead, but from my last experience, and since I did not see this interface documented anywhere in the API, I just went on working using the 'Transaction' interface. It also took me a long time to get it 'almost' working, but it never did completely. Another failure!

While I was in the middle of this frustrating process, Dave found out, that the 'Modify' interface was actually not obsolete, and pointed me to a very interesting link that took him some time to find and explained us why all the examples we saw, were using the 'Modify' interface. We both wondered why this was not documented and so hidden, and agreed that this should be somewhere more visible.

After making all the changes in the code again to use D-Bus and the 'Modify' interface instead, I talked to Richard Hughes regarding all these issues. He was really nice, and informed me that the reason why this was not documented in the API, was because the API is just documenting the 'system interface', since the 'session interface' isn't really part of the core PackageKit project but a reference implementation that both KDE and GNOME provide. He also pointed me to another very useful link and agreed on the need of a better entry in the PackageKit FAQ, to provide the users with all these information and documentation, something I will be helping with.

Gained knowledge
I could resume what I have learned about PackageKit in a few paragraphs, that I hope will be useful for you in the future.

There are two different levels of API in PackageKit:

  - The system API: It is the 'Transaction' interface, which is more low level, but allows the developer to control everything, including things like GPG keys and EULAs. Everything is explained in the PackageKit reference manual.

  - The session API: It is the 'Modify' and 'Query' interface, which allows the developer to install a package without taking care of the low level part. This is the one used in Cheese. The documentation in this case, is not so visible as I already mentioned before, but you can find what you need in the git.gnome.org repositories under the /src and /docs directories of gnome-packagekit.

Dave wrote a nice generic synchronous example of PackageKit usage in Vala, using the 'Modify' interface:

[DBus (name = "org.freedesktop.PackageKit.Modify")]
interface Packagekit : Object {
    public abstract void install_package_names (uint xid, string[] packages,
                                                                            string interaction) throws IOError;}


int main () { 
    Packagekit pk;
    try {
        pk = Bus.get_proxy_sync (BusType.SESSION, "org.freedesktop.PackageKit",
                                                   "/org/freedesktop/PackageKit");

        string[] packages = {"nautilus-sendto" };
        var interaction = "hide-confirm-search,hide-finished,hide-warning";
        pk.install_package_names (0, packages, interaction);
    } catch (IOError error) {
        critical ("D-Bus error: %s", error.message);
        return 1;
    }
    return 0;

}

This is basically what you need to know if you want to install any package at runtime in your application using PackageKit, and do not want to bother with the details. I have used the asynchronous version of it for Cheese.

PackageKit in Cheese.

This has been a long post, but as you can see, it was quite an adventure to get here! I will write soon with more news!

17 January, 2012

Add 'Share' functionality to Cheese - check!

Great news! The sharing functionality I have been lately working on, have been merged into Cheese master! Now, users will be able to share pictures and videos within different technologies! This needs some improvement though.

First of all, nautilus-sendto needs a good check in the configure.ac file. We are talking here about a runtime dependency, and it would be really nice to have a hint for the user in the form of a message at configure time if nautilus-sendto is not installed on their system or they have the wrong version of it. I already tried something, but it is not completely working, and therefore had to be dropped from the patch for the merge:

# Check for nautilus-sendto runtime dependency.
NAUTILUS_SENDTO_DEP_MSG="This is a runtime dependency just needed for using the sharing functionality in Cheese."
NAUTILUS_SENDTO_REQUIRED=2.91.0
AC_PATH_PROGS([NAUTILUS_SENDTO], [nautilus-sendto], [notfound])
AS_IF([test "x$NAUTILUS_SENDTO" = "xnotfound"],
   [AC_MSG_WARN([Unable to find nautilus-sendto >= $NAUTILUS_SENDTO_REQUIRED in the path. $NAUTILUS_SENDTO_DEP_MSG])],
   [NAUTILUS_SENDTO_SYSTEM=`nautilus-sendto --version | $SED 's/nautilus-sendto //g'`
    AS_VERSION_COMPARE([$NAUTILUS_SENDTO_SYSTEM], [$NAUTILUS_SENDTO_REQUIRED],
         [NS_VERSION_COMPARE=0],
         [NS_VERSION_COMPARE=1],
         [NS_VERSION_COMPARE=1])
    AS_IF([test $NS_VERSION_COMPARE = 0],
       [AC_MSG_WARN([Unable to check the version of nautilus-sendto, it is probably too old. At least $NAUTILUS_SENDTO_REQUIRED is required. $NAUTILUS_SENDTO_DEP_MSG])])]
)

The problem with this solution, is that it will only work for those versions of nautilus-sendto that include support for the --version argument, currently just nautilus-sendto master, since this is a feature I also worked on during the nautilus-sendto integration, and was merged about a week ago. This means, that old versions of nautilus-sendto will not recognize this argument, and therefore return an error message ("Could not parse command-line options: Unknown option --version"), that AS_VERSION_COMPARE will use, comparing a version number with a string, instead of a version number with another version number, which will of course make the check useless. In the meantime, while I work on finding an improved solution, the user will be informed in two ways in case they hit this problem: through the UI by an insensitive 'Share' action and through the README file.

There are other bits that also need some improvement. As I already explained a few blog posts ago, for accomplishing this task,  I used nautilus-sendto, that internally uses libsocialweb, which needs to have some libsocialweb accounts first set up for working. Right now, the only way for setting those accounts up is using Bisho, that is also giving some problems. The idea now and next challenge, is to use GOA (GNOME Online Accounts) in libsocialweb instead, at least, and just for the moment, for the Google services, so my next tasks will be to focus on porting the current libsocialweb YouTube service to use GOA, and to fix all of those underlying bits that are not working correctly, to make the sharing functionality work really well!

As you can see, I do not get bored. I will be back soon with more news!

24 December, 2011

Integrating nautilus-sendto in Cheese

Among other things, last week I have been very focused and working on the integration of nautilus-sendto in Cheese.

First, I spent some time playing around with nautilus-sendto, and during this process, I filed some bugs and made patches for them too. I first could not compile master during maintainer mode due to some deprecated symbols that I replaced at the end in the form of a patch. After that, I have been having problems with the libsocialweb plugin, which is loaded by nautilus-sendto. At run time, the nautilus-sendto dialog did not show any of the libsocialweb offered technolgies. After talking to Bastien about this issue, he informed me, that in order to show the above mentioned accounts in nautilus-sendto, it is necessary to create your own libsocialweb accounts with Bisho (MeeGo configuration tool for libsocialweb social network aggregator) first. Once the accounts have been created, nautilus-sendto should show those accounts in its dialog. I also filed a bug and submitted a patch updating the README file of nautilus-sendto with this information, which was not available anywhere and updated the diagram I used in my last post with the following one:

Sharing videos and images with Cheese.

The truth is, that even using Bisho now, nautilus-sendto is not showing the libsocialweb accounts for me, which is something I have to go on investigating.

Bisho is also not very stable. It is currently showing just 3 different account types: Facebook, Twitter and Flickr, and just Flickr is working. After what has happened with Meego and the integration of GNOME Online Accounts (GOA) in GNOME, it might be nice and wise to migrate from Bisho, to GOA, another thing I filed a bug about.

Bisho.

After getting familiar with nautilus-sendto, I started working on the integration itself and made a small wrapper in Cheese. Now we can say, that Cheese has the capacity to share images and videos through different technologies. Look that I just said the capacity, which does not mean that is completely working yet! For my changes, I have created a new "shareable-media" branch in Cheese that you are very welcome to test!

This is how it is currently looking in the UI:

Share images and videos Cheese option.

 Integration of nautilus-sendto in Cheese.

I have also realised, that multiple selection of images and videos is not completely working on Cheese. A user is able to select several images and videos that are together one next to the other, but not different separate ones, which is something we will also try to fix.

This, improving the current code and fixing the different issues within nautilus-sendto and Bisho are the next points in my TODOs list. Lots of fun!! :))

I will write back soon with more updates! Thanks for reading!