libunity-7.1.4+14.04.20140210/ 0000755 0000150 0000156 00000000000 12276054354 015714 5 ustar pbuser pbgroup 0000000 0000000 libunity-7.1.4+14.04.20140210/extras/ 0000755 0000150 0000156 00000000000 12276054354 017222 5 ustar pbuser pbgroup 0000000 0000000 libunity-7.1.4+14.04.20140210/extras/unity-extra-utils.vala 0000644 0000150 0000156 00000011052 12276054226 023513 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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 Pawel Stolowski
*/
[CCode (gir_namespace = "UnityExtras", gir_version = "1.0")]
namespace Unity.Extras
{
private static const string FILE_MANAGER_DBUS_NAME = "org.freedesktop.FileManager1";
private static const string FILE_MANAGER_DBUS_PATH = "/org/freedesktop/FileManager1";
public delegate void CreateScopeCallback ();
[DBus (name = "org.freedesktop.FileManager1")]
internal interface FileManagerInterface: GLib.Object
{
public abstract async void show_items (string[] uris, string startup_id) throws Error;
/* These methods are currently unused
public abstract async void show_folders (string[] uris, string startup_id) throws Error;
public abstract async void show_item_properties (string[] uris, string startup_id) throws Error;*/
}
/**
* Opens file manager showing given uri in its parent folder.
* It tries to activate file manager using org.freedesktop.FileManager1 interface first and if it fails,
* uses GLib.AppInfo.launch_default_for_uri.
*/
public async void show_in_folder (string uri) throws Error
{
string[] uris = {uri};
var file = File.new_for_uri (uri);
if (file != null)
{
File? parent_dir = file.get_parent ();
if (parent_dir != null)
{
// try to launch file manager via dbus interface first
try
{
FileManagerInterface service = yield Bus.get_proxy (BusType.SESSION, FILE_MANAGER_DBUS_NAME, FILE_MANAGER_DBUS_PATH);
yield service.show_items (uris, "");
return;
}
catch (GLib.Error e)
{
warning ("Failed to activate file manager via dbus: '%s', uri '%s'", e.message, uri);
}
// fallback
GLib.AppInfo.launch_default_for_uri (parent_dir.get_uri (), null); // may throw
return;
}
else
{
throw new GLib.IOError.FAILED ("Failed to get parent dir for uri: '%s'".printf (uri));
}
}
else
{
throw new GLib.IOError.FAILED ("Failed to create file object for uri: '%s'".printf (uri));
}
}
/**
* Check if a given well known DBus is owned. Failure (exception) means ownership couldn't be determined.
* WARNING: This does sync IO!
*
* @param name DBus name to test for availability
* @return true if name is available
*/
public static bool dbus_name_has_owner (string name) throws Error
{
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;
}
/**
* Attempts to own DBus name (calls dbus_name_has_owner first). CreateScopeCallback should create Lens/Scope object -
* it will be called after initial dbus name availability check, but before acquiring the name, so this function may
* still fail even after executing the callback.
*
* @param name DBus name to own
* @param scope_creation_cb callback that creates Lens/Scope object
* @return application instance (on success)
*/
public static GLib.Application? dbus_own_name (string name, CreateScopeCallback scope_creation_cb) throws Error
{
GLib.Application? app = null;
if (!dbus_name_has_owner (name))
{
scope_creation_cb ();
app = new Application (name, ApplicationFlags.IS_SERVICE);
app.register ();
if (app.get_is_remote ())
{
app = null;
}
else
{
/* Hold()ing the app makes sure the GApplication doesn't exit */
app.hold ();
}
}
return app;
}
}
libunity-7.1.4+14.04.20140210/extras/unity-extra-preview-player-client.vala 0000644 0000150 0000156 00000007467 12276054226 026621 0 ustar pbuser pbgroup 0000000 0000000 /*
* 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 Pawel Stolowski
*/
[CCode (gir_namespace = "UnityExtras", gir_version = "1.0")]
namespace Unity.Extras {
static const string PREVIEW_PLAYER_DBUS_NAME = "com.canonical.Unity.Lens.Music.PreviewPlayer";
static const string PREVIEW_PLAYER_DBUS_PATH = "/com/canonical/Unity/Lens/Music/PreviewPlayer";
[DBus (name = "com.canonical.Unity.Lens.Music.PreviewPlayer")]
internal interface PreviewPlayerService: GLib.Object
{
public signal void progress(string uri, uint32 state, double progress);
public abstract async void play (string uri) throws Error;
public abstract async void pause () throws Error;
public abstract async void pause_resume () throws Error;
public abstract async void resume () throws Error;
public abstract async void stop () throws Error;
public abstract async void close () throws Error;
public abstract async HashTable video_properties (string uri) throws Error;
}
/**
* Client class for preview player DBus interface (com.canonical.Unity.Lens.Music.PreviewPlayer).
*/
public class PreviewPlayer: GLib.Object
{
/**
* Reports progress of playback for given track uri.
*/
public signal void progress(string uri, Unity.MusicPreview.TrackState state, double progress);
private async void connect_to () throws Error
{
_preview_player_service = yield Bus.get_proxy (BusType.SESSION, PREVIEW_PLAYER_DBUS_NAME, PREVIEW_PLAYER_DBUS_PATH);
_preview_player_service.progress.connect (on_progress_signal);
}
public async void play (string uri) throws Error
{
if (_preview_player_service == null)
{
yield connect_to ();
}
yield _preview_player_service.play (uri);
}
public async void pause () throws Error
{
if (_preview_player_service == null)
{
yield connect_to ();
}
yield _preview_player_service.pause ();
}
public async void pause_resume () throws Error
{
if (_preview_player_service == null)
{
yield connect_to ();
}
yield _preview_player_service.pause_resume ();
}
public async void resume () throws Error
{
if (_preview_player_service == null)
{
yield connect_to ();
}
yield _preview_player_service.resume ();
}
public async void stop () throws Error
{
if (_preview_player_service == null)
{
yield connect_to ();
}
yield _preview_player_service.stop ();
}
public async void close () throws Error
{
if (_preview_player_service == null)
{
yield connect_to ();
}
yield _preview_player_service.close ();
}
public async HashTable video_properties (string uri) throws Error
{
if (_preview_player_service == null)
{
yield connect_to ();
}
var props = yield _preview_player_service.video_properties (uri);
return props;
}
internal void on_progress_signal (string uri, uint32 state, double progress_value)
{
progress(uri, (Unity.MusicPreview.TrackState)state, progress_value);
}
private PreviewPlayerService _preview_player_service;
}
} libunity-7.1.4+14.04.20140210/extras/Makefile.am 0000644 0000150 0000156 00000005566 12276054226 021270 0 ustar pbuser pbgroup 0000000 0000000 NULL =
BUILT_SOURCES =
CLEANFILES =
EXTRA_FLAGS =
lib_LTLIBRARIES = libunity-extras.la
extrasvapidir = $(datadir)/vala/vapi
nodist_extrasvapi_DATA = \
unity-extras.vapi \
$(NULL)
extrasgirdir = $(datadir)/gir-1.0
extrasgir_DATA = UnityExtras-@GIR_VERSION@.gir
unity_extras_includedir = $(includedir)/unity/unity
nodist_unity_extras_include_HEADERS = unity-extras.h
libunity_extras_la_VALAFLAGS = \
-C \
-d . \
-H unity-extras.h \
--gir=UnityExtras-@GIR_VERSION@.gir \
--library unity-extras \
--internal-vapi=unity-extras-internal.vapi \
--internal-header=unity-extras-internal.h \
--thread \
--use-header \
--vapidir $(top_srcdir)/vapi \
--vapidir $(top_builddir)/src \
--vapidir $(top_builddir)/protocol \
--pkg unity-protocol \
--pkg config \
--pkg unity-trace \
--pkg unity \
$(LIBUNITY_PACKAGES) \
$(MAINTAINER_VALAFLAGS)
nodist_libunity_extras_la_SOURCES = \
$(libunity_extras_la_VALASOURCES:.vala=.c) \
$(NULL)
$(nodist_libunity_extras_la_SOURCES): libunity_extras_la_vala.stamp
libunity_extras_la_VALASOURCES = \
unity-extra-preview-player-client.vala \
unity-extra-utils.vala \
$(NULL)
if !ENABLE_C_WARNINGS
EXTRA_FLAGS += -w
endif
libunity_extras_la_CPPFLAGS = \
-DG_LOG_DOMAIN=\"libunity-extras\" \
-DPKGDATADIR=\"$(PKGDATADIR)\" \
-DDATADIR=\"$(DATADIR)\" \
-I$(srcdir) \
-I$(top_builddir)/protocol \
-I$(top_builddir)/src \
$(EXTRA_FLAGS) \
$(LIBUNITY_CFLAGS)
libunity_extras_la_LIBADD = \
$(LIBUNITY_LIBS) $(top_builddir)/src/libunity.la
libunity_extras_la_LDFLAGS = \
$(LIBUNITY_EXTRAS_LT_LDFLAGS) \
$(COVERAGE_LDFLAGS)
libunity_extras_la_GENERATED = \
unity-extras.vapi \
UnityExtras-@GIR_VERSION@.gir \
unity-extras-internal.h \
unity-extras-internal.vapi \
$(NULL)
# Used by tests
noinst_DATA = unity-extras-internal.h unity-extras-internal.vapi
$(libunity_la_GENERATED): libunity_la_vala.stamp
libunity_extras_la_vala.stamp: $(libunity_extras_la_VALASOURCES)
$(AM_V_GEN) $(VALAC) $(libunity_extras_la_VALAFLAGS) $^
@sed -i -e 's///g' UnityExtras-@GIR_VERSION@.gir
@sed -i -e 's/"Extras/"/g;s/"extras_/"/' UnityExtras-@GIR_VERSION@.gir
@sed -i -e 's/