more rename PV -> PINOS, Pv -> Pinos, pv -> pinos

This commit is contained in:
Wim Taymans 2015-07-07 16:46:23 +02:00
parent 0dd41f5e40
commit a3505fb880
46 changed files with 2333 additions and 2267 deletions

View file

@ -21,13 +21,13 @@
#include <gst/gst.h>
#include <gio/gio.h>
#include <server/pv-daemon.h>
#include "pv-client-source.h"
#include <server/daemon.h>
#include <server/client-source.h>
#define PV_CLIENT_SOURCE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_CLIENT_SOURCE, PvClientSourcePrivate))
#define PINOS_CLIENT_SOURCE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_CLIENT_SOURCE, PinosClientSourcePrivate))
struct _PvClientSourcePrivate
struct _PinosClientSourcePrivate
{
GstElement *pipeline;
GstElement *src;
@ -37,16 +37,18 @@ struct _PvClientSourcePrivate
GSocket *socket;
PvSourceOutput *input;
PinosSourceOutput *input;
};
G_DEFINE_TYPE (PvClientSource, pv_client_source, PV_TYPE_SOURCE);
G_DEFINE_TYPE (PinosClientSource, pinos_client_source, PINOS_TYPE_SOURCE);
static gboolean
bus_handler (GstBus * bus, GstMessage * message, gpointer user_data)
bus_handler (GstBus *bus,
GstMessage *message,
gpointer user_data)
{
PvSource *source = user_data;
PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (source)->priv;
PinosSource *source = user_data;
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_ERROR:
@ -58,7 +60,7 @@ bus_handler (GstBus * bus, GstMessage * message, gpointer user_data)
g_print ("got error %s (%s)\n", error->message, debug);
g_free (debug);
pv_source_report_error (source, error);
pinos_source_report_error (source, error);
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
break;
}
@ -69,9 +71,9 @@ bus_handler (GstBus * bus, GstMessage * message, gpointer user_data)
}
static void
setup_pipeline (PvClientSource *source)
setup_pipeline (PinosClientSource *source)
{
PvClientSourcePrivate *priv = source->priv;
PinosClientSourcePrivate *priv = source->priv;
GstBus *bus;
priv->pipeline = gst_parse_launch ("socketsrc name=src ! "
@ -95,9 +97,10 @@ setup_pipeline (PvClientSource *source)
}
static GstCaps *
collect_caps (PvSource * source, GstCaps *filter)
collect_caps (PinosSource *source,
GstCaps *filter)
{
PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (source)->priv;
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
GstCaps *res;
GstQuery *query;
@ -111,36 +114,39 @@ collect_caps (PvSource * source, GstCaps *filter)
}
static gboolean
client_set_state (PvSource *source, PvSourceState state)
client_set_state (PinosSource *source,
PinosSourceState state)
{
PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (source)->priv;
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
switch (state) {
case PV_SOURCE_STATE_SUSPENDED:
case PINOS_SOURCE_STATE_SUSPENDED:
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
break;
case PV_SOURCE_STATE_INIT:
case PINOS_SOURCE_STATE_INIT:
gst_element_set_state (priv->pipeline, GST_STATE_READY);
break;
case PV_SOURCE_STATE_IDLE:
case PINOS_SOURCE_STATE_IDLE:
gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
break;
case PV_SOURCE_STATE_RUNNING:
case PINOS_SOURCE_STATE_RUNNING:
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
break;
case PV_SOURCE_STATE_ERROR:
case PINOS_SOURCE_STATE_ERROR:
break;
}
pv_source_update_state (source, state);
pinos_source_update_state (source, state);
return TRUE;
}
static GBytes *
client_get_formats (PvSource *source, GBytes *filter)
client_get_formats (PinosSource *source,
GBytes *filter)
{
GstCaps *caps, *cfilter;
gchar *str;
@ -163,8 +169,8 @@ on_socket_notify (GObject *gobject,
GParamSpec *pspec,
gpointer user_data)
{
PvClientSource *source = user_data;
PvClientSourcePrivate *priv = source->priv;
PinosClientSource *source = user_data;
PinosClientSourcePrivate *priv = source->priv;
GSocket *socket;
guint num_handles;
@ -195,20 +201,20 @@ on_socket_notify (GObject *gobject,
}
}
static PvSourceOutput *
client_create_source_output (PvSource *source,
static PinosSourceOutput *
client_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
{
PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (source)->priv;
PvSourceOutput *output;
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv;
PinosSourceOutput *output;
/* propose format of input */
g_object_get (priv->input, "format", &format_filter, NULL);
output = PV_SOURCE_CLASS (pv_client_source_parent_class)
output = PINOS_SOURCE_CLASS (pinos_client_source_parent_class)
->create_source_output (source,
client_path,
format_filter,
@ -226,26 +232,27 @@ client_create_source_output (PvSource *source,
}
static gboolean
client_release_source_output (PvSource *source, PvSourceOutput *output)
client_release_source_output (PinosSource *source,
PinosSourceOutput *output)
{
return PV_SOURCE_CLASS (pv_client_source_parent_class)->release_source_output (source, output);
return PINOS_SOURCE_CLASS (pinos_client_source_parent_class)->release_source_output (source, output);
}
static void
client_source_dispose (GObject * object)
{
PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (object)->priv;
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv;
g_source_remove (priv->id);
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
G_OBJECT_CLASS (pv_client_source_parent_class)->dispose (object);
G_OBJECT_CLASS (pinos_client_source_parent_class)->dispose (object);
}
static void
client_source_finalize (GObject * object)
{
PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (object)->priv;
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv;
g_clear_object (&priv->input);
g_clear_object (&priv->filter);
@ -253,7 +260,7 @@ client_source_finalize (GObject * object)
g_clear_object (&priv->src);
g_clear_object (&priv->pipeline);
G_OBJECT_CLASS (pv_client_source_parent_class)->finalize (object);
G_OBJECT_CLASS (pinos_client_source_parent_class)->finalize (object);
}
@ -262,8 +269,8 @@ on_input_socket_notify (GObject *gobject,
GParamSpec *pspec,
gpointer user_data)
{
PvClientSource *source = user_data;
PvClientSourcePrivate *priv = source->priv;
PinosClientSource *source = user_data;
PinosClientSourcePrivate *priv = source->priv;
GSocket *socket;
GBytes *requested_format;
GstCaps *caps;
@ -293,21 +300,21 @@ on_input_socket_notify (GObject *gobject,
gst_element_set_state (priv->pipeline, GST_STATE_READY);
}
PvSourceOutput *
pv_client_source_get_source_input (PvClientSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
PinosSourceOutput *
pinos_client_source_get_source_input (PinosClientSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
{
PvClientSourcePrivate *priv;
PinosClientSourcePrivate *priv;
g_return_val_if_fail (PV_IS_CLIENT_SOURCE (source), NULL);
g_return_val_if_fail (PINOS_IS_CLIENT_SOURCE (source), NULL);
priv = source->priv;
if (priv->input == NULL) {
priv->input = PV_SOURCE_CLASS (pv_client_source_parent_class)
->create_source_output (PV_SOURCE (source),
priv->input = PINOS_SOURCE_CLASS (pinos_client_source_parent_class)
->create_source_output (PINOS_SOURCE (source),
client_path,
format_filter,
prefix,
@ -321,12 +328,12 @@ pv_client_source_get_source_input (PvClientSource *source,
}
static void
pv_client_source_class_init (PvClientSourceClass * klass)
pinos_client_source_class_init (PinosClientSourceClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
PvSourceClass *source_class = PV_SOURCE_CLASS (klass);
PinosSourceClass *source_class = PINOS_SOURCE_CLASS (klass);
g_type_class_add_private (klass, sizeof (PvClientSourcePrivate));
g_type_class_add_private (klass, sizeof (PinosClientSourcePrivate));
gobject_class->dispose = client_source_dispose;
gobject_class->finalize = client_source_finalize;
@ -338,15 +345,18 @@ pv_client_source_class_init (PvClientSourceClass * klass)
}
static void
pv_client_source_init (PvClientSource * source)
pinos_client_source_init (PinosClientSource * source)
{
source->priv = PV_CLIENT_SOURCE_GET_PRIVATE (source);
source->priv = PINOS_CLIENT_SOURCE_GET_PRIVATE (source);
setup_pipeline (source);
}
PvSource *
pv_client_source_new (PvDaemon *daemon)
PinosSource *
pinos_client_source_new (PinosDaemon *daemon)
{
return g_object_new (PV_TYPE_CLIENT_SOURCE, "daemon", daemon, "name", "client-source", NULL);
return g_object_new (PINOS_TYPE_CLIENT_SOURCE,
"daemon", daemon,
"name", "client-source",
NULL);
}

View file

@ -0,0 +1,77 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PINOS_CLIENT_SOURCE_H__
#define __PINOS_CLIENT_SOURCE_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
typedef struct _PinosClientSource PinosClientSource;
typedef struct _PinosClientSourceClass PinosClientSourceClass;
typedef struct _PinosClientSourcePrivate PinosClientSourcePrivate;
#include "server/source.h"
#define PINOS_TYPE_CLIENT_SOURCE (pinos_client_source_get_type ())
#define PINOS_IS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE))
#define PINOS_IS_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SOURCE))
#define PINOS_CLIENT_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SOURCE, PinosClientSourceClass))
#define PINOS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SOURCE, PinosClientSource))
#define PINOS_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SOURCE, PinosClientSourceClass))
#define PINOS_CLIENT_SOURCE_CAST(obj) ((PinosClientSource*)(obj))
#define PINOS_CLIENT_SOURCE_CLASS_CAST(klass) ((PinosClientSourceClass*)(klass))
/**
* PinosClientSource:
*
* Pinos client source object class.
*/
struct _PinosClientSource {
PinosSource object;
PinosClientSourcePrivate *priv;
};
/**
* PinosClientSourceClass:
*
* Pinos client source object class.
*/
struct _PinosClientSourceClass {
PinosSourceClass parent_class;
};
/* normal GObject stuff */
GType pinos_client_source_get_type (void);
PinosSource * pinos_client_source_new (PinosDaemon *daemon);
PinosSourceOutput * pinos_client_source_get_source_input (PinosClientSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error);
G_END_DECLS
#endif /* __PINOS_CLIENT_SOURCE_H__ */

View file

@ -20,29 +20,29 @@
#include <string.h>
#include "client/pinos.h"
#include "client/pv-enumtypes.h"
#include "client/enumtypes.h"
#include "server/pv-client.h"
#include "server/pv-client-source.h"
#include "server/client.h"
#include "server/client-source.h"
#include "dbus/org-pinos.h"
struct _PvClientPrivate
struct _PinosClientPrivate
{
PvDaemon *daemon;
PinosDaemon *daemon;
gchar *sender;
gchar *object_path;
GVariant *properties;
PvClient1 *client1;
PinosClient1 *client1;
GList *outputs;
};
#define PV_CLIENT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_CLIENT, PvClientPrivate))
#define PINOS_CLIENT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_CLIENT, PinosClientPrivate))
G_DEFINE_TYPE (PvClient, pv_client, G_TYPE_OBJECT);
G_DEFINE_TYPE (PinosClient, pinos_client, G_TYPE_OBJECT);
enum
{
@ -62,13 +62,13 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
static void
pv_client_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
pinos_client_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PvClient *client = PV_CLIENT (_object);
PvClientPrivate *priv = client->priv;
PinosClient *client = PINOS_CLIENT (_object);
PinosClientPrivate *priv = client->priv;
switch (prop_id) {
case PROP_DAEMON:
@ -94,13 +94,13 @@ pv_client_get_property (GObject *_object,
}
static void
pv_client_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
pinos_client_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PvClient *client = PV_CLIENT (_object);
PvClientPrivate *priv = client->priv;
PinosClient *client = PINOS_CLIENT (_object);
PinosClientPrivate *priv = client->priv;
switch (prop_id) {
case PROP_DAEMON:
@ -128,54 +128,54 @@ pv_client_set_property (GObject *_object,
}
static void
handle_remove_source_output (PvSourceOutput *output,
gpointer user_data)
handle_remove_source_output (PinosSourceOutput *output,
gpointer user_data)
{
PvClient *client = user_data;
PvClientPrivate *priv = client->priv;
PinosClient *client = user_data;
PinosClientPrivate *priv = client->priv;
priv->outputs = g_list_remove (priv->outputs, output);
g_object_unref (output);
}
static gboolean
handle_create_source_output (PvClient1 *interface,
handle_create_source_output (PinosClient1 *interface,
GDBusMethodInvocation *invocation,
const gchar *arg_source,
const gchar *arg_accepted_formats,
gpointer user_data)
{
PvClient *client = user_data;
PvClientPrivate *priv = client->priv;
PvSource *source;
PvSourceOutput *output;
PinosClient *client = user_data;
PinosClientPrivate *priv = client->priv;
PinosSource *source;
PinosSourceOutput *output;
const gchar *object_path, *sender;
GBytes *formats;
GError *error = NULL;
sender = g_dbus_method_invocation_get_sender (invocation);
if (g_strcmp0 (pv_client_get_sender (client), sender) != 0)
if (g_strcmp0 (pinos_client_get_sender (client), sender) != 0)
goto not_allowed;
formats = g_bytes_new (arg_accepted_formats, strlen (arg_accepted_formats) + 1);
source = pv_daemon_find_source (priv->daemon,
arg_source,
priv->properties,
formats,
&error);
source = pinos_daemon_find_source (priv->daemon,
arg_source,
priv->properties,
formats,
&error);
if (source == NULL)
goto no_source;
output = pv_source_create_source_output (source,
priv->object_path,
formats,
priv->object_path,
&error);
output = pinos_source_create_source_output (source,
priv->object_path,
formats,
priv->object_path,
&error);
if (output == NULL)
goto no_output;
object_path = pv_source_output_get_object_path (output);
object_path = pinos_source_output_get_object_path (output);
priv->outputs = g_list_prepend (priv->outputs, output);
@ -213,29 +213,29 @@ no_output:
}
static gboolean
handle_create_source_input (PvClient1 *interface,
handle_create_source_input (PinosClient1 *interface,
GDBusMethodInvocation *invocation,
const gchar *arg_possible_formats,
gpointer user_data)
{
PvClient *client = user_data;
PvClientPrivate *priv = client->priv;
PvSource *source;
PvSourceOutput *input;
PinosClient *client = user_data;
PinosClientPrivate *priv = client->priv;
PinosSource *source;
PinosSourceOutput *input;
const gchar *source_input_path, *sender;
GBytes *formats;
GError *error = NULL;
sender = g_dbus_method_invocation_get_sender (invocation);
if (g_strcmp0 (pv_client_get_sender (client), sender) != 0)
if (g_strcmp0 (pinos_client_get_sender (client), sender) != 0)
goto not_allowed;
source = pv_client_source_new (priv->daemon);
source = pinos_client_source_new (priv->daemon);
if (source == NULL)
goto no_source;
g_object_set_data_full (G_OBJECT (client),
pv_source_get_object_path (PV_SOURCE (source)),
pinos_source_get_object_path (PINOS_SOURCE (source)),
source,
g_object_unref);
@ -243,15 +243,15 @@ handle_create_source_input (PvClient1 *interface,
formats = g_bytes_new (arg_possible_formats, strlen (arg_possible_formats) + 1);
input = pv_client_source_get_source_input (PV_CLIENT_SOURCE (source),
priv->object_path,
formats,
priv->object_path,
&error);
input = pinos_client_source_get_source_input (PINOS_CLIENT_SOURCE (source),
priv->object_path,
formats,
priv->object_path,
&error);
if (input == NULL)
goto no_input;
source_input_path = pv_source_output_get_object_path (input);
source_input_path = pinos_source_output_get_object_path (input);
priv->outputs = g_list_prepend (priv->outputs, input);
@ -288,11 +288,11 @@ no_input:
}
}
static gboolean
handle_disconnect (PvClient1 *interface,
handle_disconnect (PinosClient1 *interface,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
PvClient *client = user_data;
PinosClient *client = user_data;
g_signal_emit (client, signals[SIGNAL_DISCONNECT], 0, NULL);
@ -302,19 +302,20 @@ handle_disconnect (PvClient1 *interface,
}
static void
client_register_object (PvClient *client, const gchar *prefix)
client_register_object (PinosClient *client,
const gchar *prefix)
{
PvClientPrivate *priv = client->priv;
PvDaemon *daemon = priv->daemon;
PvObjectSkeleton *skel;
PinosClientPrivate *priv = client->priv;
PinosDaemon *daemon = priv->daemon;
PinosObjectSkeleton *skel;
gchar *name;
name = g_strdup_printf ("%s/client", prefix);
skel = pv_object_skeleton_new (name);
skel = pinos_object_skeleton_new (name);
g_free (name);
priv->client1 = pv_client1_skeleton_new ();
pv_client1_set_name (priv->client1, priv->sender);
priv->client1 = pinos_client1_skeleton_new ();
pinos_client1_set_name (priv->client1, priv->sender);
g_signal_connect (priv->client1, "handle-create-source-output",
(GCallback) handle_create_source_output,
client);
@ -324,83 +325,84 @@ client_register_object (PvClient *client, const gchar *prefix)
g_signal_connect (priv->client1, "handle-disconnect",
(GCallback) handle_disconnect,
client);
pv_object_skeleton_set_client1 (skel, priv->client1);
pinos_object_skeleton_set_client1 (skel, priv->client1);
g_free (priv->object_path);
priv->object_path = pv_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
}
static void
client_unregister_object (PvClient *client)
client_unregister_object (PinosClient *client)
{
PvClientPrivate *priv = client->priv;
PvDaemon *daemon = priv->daemon;
PinosClientPrivate *priv = client->priv;
PinosDaemon *daemon = priv->daemon;
g_clear_object (&priv->client1);
pv_daemon_unexport (daemon, priv->object_path);
pinos_daemon_unexport (daemon, priv->object_path);
g_free (priv->object_path);
}
static void
do_remove_output (PvSourceOutput *output, PvClient *client)
do_remove_output (PinosSourceOutput *output,
PinosClient *client)
{
pv_source_output_remove (output);
pinos_source_output_remove (output);
}
static void
pv_client_dispose (GObject * object)
pinos_client_dispose (GObject * object)
{
PvClient *client = PV_CLIENT (object);
PvClientPrivate *priv = client->priv;
PinosClient *client = PINOS_CLIENT (object);
PinosClientPrivate *priv = client->priv;
g_list_foreach (priv->outputs, (GFunc) do_remove_output, client);
client_unregister_object (client);
G_OBJECT_CLASS (pv_client_parent_class)->dispose (object);
G_OBJECT_CLASS (pinos_client_parent_class)->dispose (object);
}
static void
pv_client_finalize (GObject * object)
pinos_client_finalize (GObject * object)
{
PvClient *client = PV_CLIENT (object);
PvClientPrivate *priv = client->priv;
PinosClient *client = PINOS_CLIENT (object);
PinosClientPrivate *priv = client->priv;
if (priv->properties)
g_variant_unref (priv->properties);
G_OBJECT_CLASS (pv_client_parent_class)->finalize (object);
G_OBJECT_CLASS (pinos_client_parent_class)->finalize (object);
}
static void
pv_client_constructed (GObject * object)
pinos_client_constructed (GObject * object)
{
PvClient *client = PV_CLIENT (object);
PvClientPrivate *priv = client->priv;
PinosClient *client = PINOS_CLIENT (object);
PinosClientPrivate *priv = client->priv;
client_register_object (client, priv->object_path);
G_OBJECT_CLASS (pv_client_parent_class)->constructed (object);
G_OBJECT_CLASS (pinos_client_parent_class)->constructed (object);
}
static void
pv_client_class_init (PvClientClass * klass)
pinos_client_class_init (PinosClientClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (PvClientPrivate));
g_type_class_add_private (klass, sizeof (PinosClientPrivate));
gobject_class->constructed = pv_client_constructed;
gobject_class->dispose = pv_client_dispose;
gobject_class->finalize = pv_client_finalize;
gobject_class->set_property = pv_client_set_property;
gobject_class->get_property = pv_client_get_property;
gobject_class->constructed = pinos_client_constructed;
gobject_class->dispose = pinos_client_dispose;
gobject_class->finalize = pinos_client_finalize;
gobject_class->set_property = pinos_client_set_property;
gobject_class->get_property = pinos_client_get_property;
g_object_class_install_property (gobject_class,
PROP_DAEMON,
g_param_spec_object ("daemon",
"Daemon",
"The daemon",
PV_TYPE_DAEMON,
PINOS_TYPE_DAEMON,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@ -448,70 +450,70 @@ pv_client_class_init (PvClientClass * klass)
}
static void
pv_client_init (PvClient * client)
pinos_client_init (PinosClient * client)
{
client->priv = PV_CLIENT_GET_PRIVATE (client);
client->priv = PINOS_CLIENT_GET_PRIVATE (client);
}
/**
* pv_client_new:
* @daemon: a #PvDaemon
* pinos_client_new:
* @daemon: a #PinosDaemon
* @prefix: a prefix
*
* Make a new #PvClient object and register it to @daemon under the @prefix.
* Make a new #PinosClient object and register it to @daemon under the @prefix.
*
* Returns: a new #PvClient
* Returns: a new #PinosClient
*/
PvClient *
pv_client_new (PvDaemon *daemon,
const gchar *sender,
const gchar *prefix,
GVariant *properties)
PinosClient *
pinos_client_new (PinosDaemon *daemon,
const gchar *sender,
const gchar *prefix,
GVariant *properties)
{
g_return_val_if_fail (PV_IS_DAEMON (daemon), NULL);
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
g_return_val_if_fail (g_variant_is_object_path (prefix), NULL);
return g_object_new (PV_TYPE_CLIENT, "daemon", daemon,
"sender", sender,
"object-path", prefix,
"properties", properties,
NULL);
return g_object_new (PINOS_TYPE_CLIENT, "daemon", daemon,
"sender", sender,
"object-path", prefix,
"properties", properties,
NULL);
}
/**
* pv_client_get_sender:
* @client: a #PvClient
* pinos_client_get_sender:
* @client: a #PinosClient
*
* Get the sender of @client.
*
* Returns: the sender of @client
*/
const gchar *
pv_client_get_sender (PvClient *client)
pinos_client_get_sender (PinosClient *client)
{
PvClientPrivate *priv;
PinosClientPrivate *priv;
g_return_val_if_fail (PV_IS_CLIENT (client), NULL);
g_return_val_if_fail (PINOS_IS_CLIENT (client), NULL);
priv = client->priv;
return priv->sender;
}
/**
* pv_client_get_object_path:
* @client: a #PvClient
* pinos_client_get_object_path:
* @client: a #PinosClient
*
* Get the object path of @client.
*
* Returns: the object path of @client
*/
const gchar *
pv_client_get_object_path (PvClient *client)
pinos_client_get_object_path (PinosClient *client)
{
PvClientPrivate *priv;
PinosClientPrivate *priv;
g_return_val_if_fail (PV_IS_CLIENT (client), NULL);
g_return_val_if_fail (PINOS_IS_CLIENT (client), NULL);
priv = client->priv;
return priv->object_path;

76
src/server/client.h Normal file
View file

@ -0,0 +1,76 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PINOS_CLIENT_H__
#define __PINOS_CLIENT_H__
#include <glib-object.h>
#include "daemon.h"
G_BEGIN_DECLS
#define PINOS_TYPE_CLIENT (pinos_client_get_type ())
#define PINOS_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_CLIENT))
#define PINOS_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_CLIENT))
#define PINOS_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_CLIENT, PinosClientClass))
#define PINOS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_CLIENT, PinosClient))
#define PINOS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_CLIENT, PinosClientClass))
#define PINOS_CLIENT_CAST(obj) ((PinosClient*)(obj))
#define PINOS_CLIENT_CLASS_CAST(klass) ((PinosClientClass*)(klass))
typedef struct _PinosClient PinosClient;
typedef struct _PinosClientClass PinosClientClass;
typedef struct _PinosClientPrivate PinosClientPrivate;
/**
* PinosClient:
*
* Pinos client object class.
*/
struct _PinosClient {
GObject object;
PinosClientPrivate *priv;
};
/**
* PinosClientClass:
*
* Pinos client object class.
*/
struct _PinosClientClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pinos_client_get_type (void);
PinosClient * pinos_client_new (PinosDaemon *daemon,
const gchar *sender,
const gchar *prefix,
GVariant *properties);
const gchar * pinos_client_get_sender (PinosClient *client);
const gchar * pinos_client_get_object_path (PinosClient *client);
G_END_DECLS
#endif /* __PINOS_CLIENT_H__ */

View file

@ -23,15 +23,15 @@
#include "client/pinos.h"
#include "server/pv-daemon.h"
#include "server/pv-client.h"
#include "server/daemon.h"
#include "server/client.h"
#include "dbus/org-pinos.h"
#define PV_DAEMON_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_DAEMON, PvDaemonPrivate))
#define PINOS_DAEMON_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_DAEMON, PinosDaemonPrivate))
struct _PvDaemonPrivate
struct _PinosDaemonPrivate
{
guint id;
GDBusConnection *connection;
@ -45,18 +45,18 @@ struct _PvDaemonPrivate
typedef struct {
guint id;
gchar *sender;
PvDaemon *daemon;
PinosDaemon *daemon;
GList *objects;
} SenderData;
static void
client_name_appeared_handler (GDBusConnection *connection,
const gchar *name,
const gchar *name_owner,
gpointer user_data)
const gchar *name,
const gchar *name_owner,
gpointer user_data)
{
SenderData *data = user_data;
PvDaemonPrivate *priv = data->daemon->priv;
PinosDaemonPrivate *priv = data->daemon->priv;
g_hash_table_insert (priv->senders, data->sender, data);
@ -66,8 +66,8 @@ client_name_appeared_handler (GDBusConnection *connection,
static void
client_name_vanished_handler (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
const gchar *name,
gpointer user_data)
{
SenderData *data = user_data;
@ -84,9 +84,10 @@ data_free (SenderData *data)
}
static SenderData *
sender_data_new (PvDaemon *daemon, const gchar *sender)
sender_data_new (PinosDaemon *daemon,
const gchar *sender)
{
PvDaemonPrivate *priv = daemon->priv;
PinosDaemonPrivate *priv = daemon->priv;
SenderData *data;
data = g_new0 (SenderData, 1);
@ -106,15 +107,15 @@ sender_data_new (PvDaemon *daemon, const gchar *sender)
}
static void
handle_disconnect_client (PvClient *client,
gpointer user_data)
handle_disconnect_client (PinosClient *client,
gpointer user_data)
{
PvDaemon *daemon = user_data;
PvDaemonPrivate *priv = daemon->priv;
PinosDaemon *daemon = user_data;
PinosDaemonPrivate *priv = daemon->priv;
const gchar *sender;
SenderData *data;
sender = pv_client_get_sender (client);
sender = pinos_client_get_sender (client);
data = g_hash_table_lookup (priv->senders, sender);
if (data == NULL)
@ -125,23 +126,23 @@ handle_disconnect_client (PvClient *client,
}
static gboolean
handle_connect_client (PvDaemon1 *interface,
handle_connect_client (PinosDaemon1 *interface,
GDBusMethodInvocation *invocation,
GVariant *arg_properties,
gpointer user_data)
{
PvDaemon *daemon = user_data;
PvClient *client;
PinosDaemon *daemon = user_data;
PinosClient *client;
const gchar *sender, *object_path;
sender = g_dbus_method_invocation_get_sender (invocation);
client = pv_client_new (daemon, sender, PV_DBUS_OBJECT_PREFIX, arg_properties);
client = pinos_client_new (daemon, sender, PINOS_DBUS_OBJECT_PREFIX, arg_properties);
g_signal_connect (client, "disconnect", (GCallback) handle_disconnect_client, daemon);
pv_daemon_track_object (daemon, sender, G_OBJECT (client));
pinos_daemon_track_object (daemon, sender, G_OBJECT (client));
object_path = pv_client_get_object_path (client);
object_path = pinos_client_get_object_path (client);
g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(o)", object_path));
@ -149,21 +150,22 @@ handle_connect_client (PvDaemon1 *interface,
}
static void
export_server_object (PvDaemon *daemon, GDBusObjectManagerServer *manager)
export_server_object (PinosDaemon *daemon,
GDBusObjectManagerServer *manager)
{
PvObjectSkeleton *skel;
PinosObjectSkeleton *skel;
skel = pv_object_skeleton_new (PV_DBUS_OBJECT_SERVER);
skel = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_SERVER);
{
PvDaemon1 *iface;
PinosDaemon1 *iface;
iface = pv_daemon1_skeleton_new ();
iface = pinos_daemon1_skeleton_new ();
g_signal_connect (iface, "handle-connect-client", (GCallback) handle_connect_client, daemon);
pv_daemon1_set_user_name (iface, g_get_user_name ());
pv_daemon1_set_host_name (iface, g_get_host_name ());
pv_daemon1_set_version (iface, PACKAGE_VERSION);
pv_daemon1_set_name (iface, PACKAGE_NAME);
pv_object_skeleton_set_daemon1 (skel, iface);
pinos_daemon1_set_user_name (iface, g_get_user_name ());
pinos_daemon1_set_host_name (iface, g_get_host_name ());
pinos_daemon1_set_version (iface, PACKAGE_VERSION);
pinos_daemon1_set_name (iface, PACKAGE_NAME);
pinos_object_skeleton_set_daemon1 (skel, iface);
g_object_unref (iface);
}
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (skel));
@ -172,11 +174,11 @@ export_server_object (PvDaemon *daemon, GDBusObjectManagerServer *manager)
static void
bus_acquired_handler (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
const gchar *name,
gpointer user_data)
{
PvDaemon *daemon = user_data;
PvDaemonPrivate *priv = daemon->priv;
PinosDaemon *daemon = user_data;
PinosDaemonPrivate *priv = daemon->priv;
GDBusObjectManagerServer *manager = priv->server_manager;
priv->connection = connection;
@ -188,56 +190,56 @@ bus_acquired_handler (GDBusConnection *connection,
static void
name_acquired_handler (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
const gchar *name,
gpointer user_data)
{
}
static void
name_lost_handler (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
const gchar *name,
gpointer user_data)
{
PvDaemon *daemon = user_data;
PvDaemonPrivate *priv = daemon->priv;
PinosDaemon *daemon = user_data;
PinosDaemonPrivate *priv = daemon->priv;
GDBusObjectManagerServer *manager = priv->server_manager;
g_dbus_object_manager_server_unexport (manager, PV_DBUS_OBJECT_SERVER);
g_dbus_object_manager_server_unexport (manager, PINOS_DBUS_OBJECT_SERVER);
g_dbus_object_manager_server_set_connection (manager, connection);
priv->connection = connection;
}
/**
* pv_daemon_new:
* pinos_daemon_new:
*
* Make a new #PvDaemon object
* Make a new #PinosDaemon object
*
* Returns: a new #PvDaemon
* Returns: a new #PinosDaemon
*/
PvDaemon *
pv_daemon_new (void)
PinosDaemon *
pinos_daemon_new (void)
{
return g_object_new (PV_TYPE_DAEMON, NULL);
return g_object_new (PINOS_TYPE_DAEMON, NULL);
}
/**
* pv_daemon_start:
* @daemon: a #PvDaemon
* pinos_daemon_start:
* @daemon: a #PinosDaemon
*
* Start the @daemon.
*/
void
pv_daemon_start (PvDaemon *daemon)
pinos_daemon_start (PinosDaemon *daemon)
{
PvDaemonPrivate *priv;
PinosDaemonPrivate *priv;
g_return_if_fail (PV_IS_DAEMON (daemon));
g_return_if_fail (PINOS_IS_DAEMON (daemon));
priv = daemon->priv;
g_return_if_fail (priv->id == 0);
priv->id = g_bus_own_name (G_BUS_TYPE_SESSION,
PV_DBUS_SERVICE,
PINOS_DBUS_SERVICE,
G_BUS_NAME_OWNER_FLAGS_REPLACE,
bus_acquired_handler,
name_acquired_handler,
@ -247,17 +249,17 @@ pv_daemon_start (PvDaemon *daemon)
}
/**
* pv_daemon_stop:
* @daemon: a #PvDaemon
* pinos_daemon_stop:
* @daemon: a #PinosDaemon
*
* Stop the @daemon.
*/
void
pv_daemon_stop (PvDaemon *daemon)
pinos_daemon_stop (PinosDaemon *daemon)
{
PvDaemonPrivate *priv = daemon->priv;
PinosDaemonPrivate *priv = daemon->priv;
g_return_if_fail (PV_IS_DAEMON (daemon));
g_return_if_fail (PINOS_IS_DAEMON (daemon));
if (priv->id != 0) {
g_bus_unown_name (priv->id);
@ -266,8 +268,8 @@ pv_daemon_stop (PvDaemon *daemon)
}
/**
* pv_daemon_export_uniquely:
* @daemon: a #PvDaemon
* pinos_daemon_export_uniquely:
* @daemon: a #PinosDaemon
* @skel: a #GDBusObjectSkeleton
*
* Export @skel with @daemon with a unique name
@ -275,9 +277,10 @@ pv_daemon_stop (PvDaemon *daemon)
* Returns: the unique named used to export @skel.
*/
gchar *
pv_daemon_export_uniquely (PvDaemon *daemon, GDBusObjectSkeleton *skel)
pinos_daemon_export_uniquely (PinosDaemon *daemon,
GDBusObjectSkeleton *skel)
{
g_return_val_if_fail (PV_IS_DAEMON (daemon), NULL);
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
g_return_val_if_fail (G_IS_DBUS_OBJECT_SKELETON (skel), NULL);
g_dbus_object_manager_server_export_uniquely (daemon->priv->server_manager, skel);
@ -286,30 +289,31 @@ pv_daemon_export_uniquely (PvDaemon *daemon, GDBusObjectSkeleton *skel)
}
/**
* pv_daemon_unexport:
* @daemon: a #PvDaemon
* pinos_daemon_unexport:
* @daemon: a #PinosDaemon
* @object_path: an object path
*
* Unexport the object on @object_path
*/
void
pv_daemon_unexport (PvDaemon *daemon, const gchar *object_path)
pinos_daemon_unexport (PinosDaemon *daemon,
const gchar *object_path)
{
g_return_if_fail (PV_IS_DAEMON (daemon));
g_return_if_fail (PINOS_IS_DAEMON (daemon));
g_return_if_fail (g_variant_is_object_path (object_path));
g_dbus_object_manager_server_unexport (daemon->priv->server_manager, object_path);
}
void
pv_daemon_track_object (PvDaemon *daemon,
const gchar *sender,
GObject *object)
pinos_daemon_track_object (PinosDaemon *daemon,
const gchar *sender,
GObject *object)
{
PvDaemonPrivate *priv;
PinosDaemonPrivate *priv;
SenderData *data;
g_return_if_fail (PV_IS_DAEMON (daemon));
g_return_if_fail (PINOS_IS_DAEMON (daemon));
g_return_if_fail (sender != NULL);
g_return_if_fail (G_IS_OBJECT (object));
@ -323,51 +327,53 @@ pv_daemon_track_object (PvDaemon *daemon,
}
void
pv_daemon_add_source (PvDaemon *daemon, PvSource *source)
pinos_daemon_add_source (PinosDaemon *daemon,
PinosSource *source)
{
PvDaemonPrivate *priv;
PinosDaemonPrivate *priv;
g_return_if_fail (PV_IS_DAEMON (daemon));
g_return_if_fail (PV_IS_SOURCE (source));
g_return_if_fail (PINOS_IS_DAEMON (daemon));
g_return_if_fail (PINOS_IS_SOURCE (source));
priv = daemon->priv;
priv->sources = g_list_prepend (priv->sources, source);
}
void
pv_daemon_remove_source (PvDaemon *daemon, PvSource *source)
pinos_daemon_remove_source (PinosDaemon *daemon,
PinosSource *source)
{
PvDaemonPrivate *priv;
PinosDaemonPrivate *priv;
g_return_if_fail (PV_IS_DAEMON (daemon));
g_return_if_fail (PV_IS_SOURCE (source));
g_return_if_fail (PINOS_IS_DAEMON (daemon));
g_return_if_fail (PINOS_IS_SOURCE (source));
priv = daemon->priv;
priv->sources = g_list_remove (priv->sources, source);
}
PvSource *
pv_daemon_find_source (PvDaemon *daemon,
const gchar *name,
GVariant *props,
GBytes *format_filter,
GError **error)
PinosSource *
pinos_daemon_find_source (PinosDaemon *daemon,
const gchar *name,
GVariant *props,
GBytes *format_filter,
GError **error)
{
PvDaemonPrivate *priv;
PvSource *best = NULL;
PinosDaemonPrivate *priv;
PinosSource *best = NULL;
GList *walk;
g_return_val_if_fail (PV_IS_DAEMON (daemon), NULL);
g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL);
priv = daemon->priv;
for (walk = priv->sources; walk; walk = g_list_next (walk)) {
PvSource *s = walk->data;
PinosSource *s = walk->data;
if (name == NULL) {
best = s;
break;
}
else if (g_str_has_suffix (pv_source_get_object_path (s), name))
else if (g_str_has_suffix (pinos_source_get_object_path (s), name))
best = s;
}
@ -380,46 +386,46 @@ pv_daemon_find_source (PvDaemon *daemon,
return best;
}
G_DEFINE_TYPE (PvDaemon, pv_daemon, G_TYPE_OBJECT);
G_DEFINE_TYPE (PinosDaemon, pinos_daemon, G_TYPE_OBJECT);
static void
pv_daemon_dispose (GObject * object)
pinos_daemon_dispose (GObject * object)
{
PvDaemon *daemon = PV_DAEMON_CAST (object);
PinosDaemon *daemon = PINOS_DAEMON_CAST (object);
pv_daemon_stop (daemon);
pinos_daemon_stop (daemon);
G_OBJECT_CLASS (pv_daemon_parent_class)->dispose (object);
G_OBJECT_CLASS (pinos_daemon_parent_class)->dispose (object);
}
static void
pv_daemon_finalize (GObject * object)
pinos_daemon_finalize (GObject * object)
{
PvDaemon *daemon = PV_DAEMON_CAST (object);
PvDaemonPrivate *priv = daemon->priv;
PinosDaemon *daemon = PINOS_DAEMON_CAST (object);
PinosDaemonPrivate *priv = daemon->priv;
g_clear_object (&priv->server_manager);
G_OBJECT_CLASS (pv_daemon_parent_class)->finalize (object);
G_OBJECT_CLASS (pinos_daemon_parent_class)->finalize (object);
}
static void
pv_daemon_class_init (PvDaemonClass * klass)
pinos_daemon_class_init (PinosDaemonClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (PvDaemonPrivate));
g_type_class_add_private (klass, sizeof (PinosDaemonPrivate));
gobject_class->dispose = pv_daemon_dispose;
gobject_class->finalize = pv_daemon_finalize;
gobject_class->dispose = pinos_daemon_dispose;
gobject_class->finalize = pinos_daemon_finalize;
}
static void
pv_daemon_init (PvDaemon * daemon)
pinos_daemon_init (PinosDaemon * daemon)
{
PvDaemonPrivate *priv = daemon->priv = PV_DAEMON_GET_PRIVATE (daemon);
PinosDaemonPrivate *priv = daemon->priv = PINOS_DAEMON_GET_PRIVATE (daemon);
priv->server_manager = g_dbus_object_manager_server_new (PV_DBUS_OBJECT_PREFIX);
priv->server_manager = g_dbus_object_manager_server_new (PINOS_DBUS_OBJECT_PREFIX);
priv->senders = g_hash_table_new (g_str_hash, g_str_equal);
}

89
src/server/daemon.h Normal file
View file

@ -0,0 +1,89 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PINOS_DAEMON_H__
#define __PINOS_DAEMON_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
#define PINOS_TYPE_DAEMON (pinos_daemon_get_type ())
#define PINOS_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_DAEMON))
#define PINOS_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_DAEMON))
#define PINOS_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_DAEMON, PinosDaemonClass))
#define PINOS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_DAEMON, PinosDaemon))
#define PINOS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_DAEMON, PinosDaemonClass))
#define PINOS_DAEMON_CAST(obj) ((PinosDaemon*)(obj))
#define PINOS_DAEMON_CLASS_CAST(klass) ((PinosDaemonClass*)(klass))
typedef struct _PinosDaemon PinosDaemon;
typedef struct _PinosDaemonClass PinosDaemonClass;
typedef struct _PinosDaemonPrivate PinosDaemonPrivate;
#include <server/source.h>
/**
* PinosDaemon:
*
* Pinos daemon object class.
*/
struct _PinosDaemon {
GObject object;
PinosDaemonPrivate *priv;
};
/**
* PinosDaemonClass:
*
* Pinos daemon object class.
*/
struct _PinosDaemonClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pinos_daemon_get_type (void);
PinosDaemon * pinos_daemon_new (void);
void pinos_daemon_start (PinosDaemon *daemon);
void pinos_daemon_stop (PinosDaemon *daemon);
gchar * pinos_daemon_export_uniquely (PinosDaemon *daemon, GDBusObjectSkeleton *skel);
void pinos_daemon_unexport (PinosDaemon *daemon, const gchar *name);
void pinos_daemon_track_object (PinosDaemon *daemon,
const gchar *sender,
GObject *object);
void pinos_daemon_add_source (PinosDaemon *daemon, PinosSource *source);
void pinos_daemon_remove_source (PinosDaemon *daemon, PinosSource *source);
PinosSource * pinos_daemon_find_source (PinosDaemon *daemon,
const gchar *name,
GVariant *props,
GBytes *format_filter,
GError **error);
G_END_DECLS
#endif /* __PINOS_DAEMON_H__ */

View file

@ -1,77 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PV_CLIENT_SOURCE_H__
#define __PV_CLIENT_SOURCE_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
typedef struct _PvClientSource PvClientSource;
typedef struct _PvClientSourceClass PvClientSourceClass;
typedef struct _PvClientSourcePrivate PvClientSourcePrivate;
#include "server/pv-source.h"
#define PV_TYPE_CLIENT_SOURCE (pv_client_source_get_type ())
#define PV_IS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_SOURCE))
#define PV_IS_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_SOURCE))
#define PV_CLIENT_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_SOURCE, PvClientSourceClass))
#define PV_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_SOURCE, PvClientSource))
#define PV_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_SOURCE, PvClientSourceClass))
#define PV_CLIENT_SOURCE_CAST(obj) ((PvClientSource*)(obj))
#define PV_CLIENT_SOURCE_CLASS_CAST(klass) ((PvClientSourceClass*)(klass))
/**
* PvClientSource:
*
* Pinos client source object class.
*/
struct _PvClientSource {
PvSource object;
PvClientSourcePrivate *priv;
};
/**
* PvClientSourceClass:
*
* Pinos client source object class.
*/
struct _PvClientSourceClass {
PvSourceClass parent_class;
};
/* normal GObject stuff */
GType pv_client_source_get_type (void);
PvSource * pv_client_source_new (PvDaemon *daemon);
PvSourceOutput * pv_client_source_get_source_input (PvClientSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error);
G_END_DECLS
#endif /* __PV_CLIENT_SOURCE_H__ */

View file

@ -1,76 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PV_CLIENT_H__
#define __PV_CLIENT_H__
#include <glib-object.h>
#include "pv-daemon.h"
G_BEGIN_DECLS
#define PV_TYPE_CLIENT (pv_client_get_type ())
#define PV_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_CLIENT))
#define PV_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_CLIENT))
#define PV_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_CLIENT, PvClientClass))
#define PV_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_CLIENT, PvClient))
#define PV_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_CLIENT, PvClientClass))
#define PV_CLIENT_CAST(obj) ((PvClient*)(obj))
#define PV_CLIENT_CLASS_CAST(klass) ((PvClientClass*)(klass))
typedef struct _PvClient PvClient;
typedef struct _PvClientClass PvClientClass;
typedef struct _PvClientPrivate PvClientPrivate;
/**
* PvClient:
*
* Pinos client object class.
*/
struct _PvClient {
GObject object;
PvClientPrivate *priv;
};
/**
* PvClientClass:
*
* Pinos client object class.
*/
struct _PvClientClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pv_client_get_type (void);
PvClient * pv_client_new (PvDaemon *daemon,
const gchar *sender,
const gchar *prefix,
GVariant *properties);
const gchar * pv_client_get_sender (PvClient *client);
const gchar * pv_client_get_object_path (PvClient *client);
G_END_DECLS
#endif /* __PV_CLIENT_H__ */

View file

@ -1,87 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PV_DAEMON_H__
#define __PV_DAEMON_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
#define PV_TYPE_DAEMON (pv_daemon_get_type ())
#define PV_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_DAEMON))
#define PV_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_DAEMON))
#define PV_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_DAEMON, PvDaemonClass))
#define PV_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_DAEMON, PvDaemon))
#define PV_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_DAEMON, PvDaemonClass))
#define PV_DAEMON_CAST(obj) ((PvDaemon*)(obj))
#define PV_DAEMON_CLASS_CAST(klass) ((PvDaemonClass*)(klass))
typedef struct _PvDaemon PvDaemon;
typedef struct _PvDaemonClass PvDaemonClass;
typedef struct _PvDaemonPrivate PvDaemonPrivate;
#include <server/pv-source.h>
/**
* PvDaemon:
*
* Pinos daemon object class.
*/
struct _PvDaemon {
GObject object;
PvDaemonPrivate *priv;
};
/**
* PvDaemonClass:
*
* Pinos daemon object class.
*/
struct _PvDaemonClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pv_daemon_get_type (void);
PvDaemon * pv_daemon_new (void);
void pv_daemon_start (PvDaemon *daemon);
void pv_daemon_stop (PvDaemon *daemon);
gchar * pv_daemon_export_uniquely (PvDaemon *daemon, GDBusObjectSkeleton *skel);
void pv_daemon_unexport (PvDaemon *daemon, const gchar *name);
void pv_daemon_track_object (PvDaemon *daemon, const gchar *sender, GObject *object);
void pv_daemon_add_source (PvDaemon *daemon, PvSource *source);
void pv_daemon_remove_source (PvDaemon *daemon, PvSource *source);
PvSource * pv_daemon_find_source (PvDaemon *daemon,
const gchar *name,
GVariant *props,
GBytes *format_filter,
GError **error);
G_END_DECLS
#endif /* __PV_DAEMON_H__ */

View file

@ -1,70 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PV_SOURCE_OUTPUT_H__
#define __PV_SOURCE_OUTPUT_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define PV_TYPE_SOURCE_OUTPUT (pv_source_output_get_type ())
#define PV_IS_SOURCE_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_SOURCE_OUTPUT))
#define PV_IS_SOURCE_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_SOURCE_OUTPUT))
#define PV_SOURCE_OUTPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_SOURCE_OUTPUT, PvSourceOutputClass))
#define PV_SOURCE_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_SOURCE_OUTPUT, PvSourceOutput))
#define PV_SOURCE_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_SOURCE_OUTPUT, PvSourceOutputClass))
#define PV_SOURCE_OUTPUT_CAST(obj) ((PvSourceOutput*)(obj))
#define PV_SOURCE_OUTPUT_CLASS_CAST(klass) ((PvSourceOutputClass*)(klass))
typedef struct _PvSourceOutput PvSourceOutput;
typedef struct _PvSourceOutputClass PvSourceOutputClass;
typedef struct _PvSourceOutputPrivate PvSourceOutputPrivate;
/**
* PvSourceOutput:
*
* Pinos source output object class.
*/
struct _PvSourceOutput {
GObject object;
PvSourceOutputPrivate *priv;
};
/**
* PvSourceOutputClass:
*
* Pinos source output object class.
*/
struct _PvSourceOutputClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pv_source_output_get_type (void);
void pv_source_output_remove (PvSourceOutput *output);
const gchar * pv_source_output_get_object_path (PvSourceOutput *output);
G_END_DECLS
#endif /* __PV_SOURCE_OUTPUT_H__ */

View file

@ -1,101 +0,0 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PV_SOURCE_H__
#define __PV_SOURCE_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
typedef struct _PvSource PvSource;
typedef struct _PvSourceClass PvSourceClass;
typedef struct _PvSourcePrivate PvSourcePrivate;
#include "client/pv-introspect.h"
#include "server/pv-source-output.h"
#define PV_TYPE_SOURCE (pv_source_get_type ())
#define PV_IS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_SOURCE))
#define PV_IS_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_SOURCE))
#define PV_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_SOURCE, PvSourceClass))
#define PV_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_SOURCE, PvSource))
#define PV_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_SOURCE, PvSourceClass))
#define PV_SOURCE_CAST(obj) ((PvSource*)(obj))
#define PV_SOURCE_CLASS_CAST(klass) ((PvSourceClass*)(klass))
/**
* PvSource:
*
* Pinos source object class.
*/
struct _PvSource {
GObject object;
PvSourcePrivate *priv;
};
/**
* PvSourceClass:
* @get_formats: called to get a list of supported formats from the source
* @set_state: called to change the current state of the source
* @create_source_output: called to create a new source-output object
* @release_source_output: called to release a source-output object
*
* Pinos source object class.
*/
struct _PvSourceClass {
GObjectClass parent_class;
GBytes * (*get_formats) (PvSource *source, GBytes *filter);
gboolean (*set_state) (PvSource *source, PvSourceState);
PvSourceOutput * (*create_source_output) (PvSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error);
gboolean (*release_source_output) (PvSource *source,
PvSourceOutput *output);
};
/* normal GObject stuff */
GType pv_source_get_type (void);
const gchar * pv_source_get_object_path (PvSource *source);
GBytes * pv_source_get_formats (PvSource *source, GBytes *filter);
gboolean pv_source_set_state (PvSource *source, PvSourceState state);
void pv_source_update_state (PvSource *source, PvSourceState state);
void pv_source_report_error (PvSource *source, GError *error);
PvSourceOutput * pv_source_create_source_output (PvSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error);
gboolean pv_source_release_source_output (PvSource *source, PvSourceOutput *output);
G_END_DECLS
#endif /* __PV_SOURCE_H__ */

View file

@ -22,17 +22,17 @@
#include <gio/gunixfdlist.h>
#include "client/pv-enumtypes.h"
#include "client/enumtypes.h"
#include "server/pv-daemon.h"
#include "server/pv-source-output.h"
#include "server/daemon.h"
#include "server/source-output.h"
#include "dbus/org-pinos.h"
struct _PvSourceOutputPrivate
struct _PinosSourceOutputPrivate
{
PvDaemon *daemon;
PvSourceOutput1 *iface;
PinosDaemon *daemon;
PinosSourceOutput1 *iface;
gchar *object_path;
gchar *client_path;
@ -45,10 +45,10 @@ struct _PvSourceOutputPrivate
GSocket *socket;
};
#define PV_SOURCE_OUTPUT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_SOURCE_OUTPUT, PvSourceOutputPrivate))
#define PINOS_SOURCE_OUTPUT_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SOURCE_OUTPUT, PinosSourceOutputPrivate))
G_DEFINE_TYPE (PvSourceOutput, pv_source_output, G_TYPE_OBJECT);
G_DEFINE_TYPE (PinosSourceOutput, pinos_source_output, G_TYPE_OBJECT);
enum
{
@ -72,13 +72,13 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
static void
pv_source_output_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
pinos_source_output_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PvSourceOutput *output = PV_SOURCE_OUTPUT (_object);
PvSourceOutputPrivate *priv = output->priv;
PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (_object);
PinosSourceOutputPrivate *priv = output->priv;
switch (prop_id) {
case PROP_DAEMON:
@ -120,13 +120,13 @@ pv_source_output_get_property (GObject *_object,
}
static void
pv_source_output_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
pinos_source_output_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PvSourceOutput *output = PV_SOURCE_OUTPUT (_object);
PvSourceOutputPrivate *priv = output->priv;
PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (_object);
PinosSourceOutputPrivate *priv = output->priv;
switch (prop_id) {
case PROP_DAEMON:
@ -168,13 +168,13 @@ pv_source_output_set_property (GObject *_object,
}
static gboolean
handle_start (PvSourceOutput1 *interface,
handle_start (PinosSourceOutput1 *interface,
GDBusMethodInvocation *invocation,
const gchar *arg_requested_format,
gpointer user_data)
{
PvSourceOutput *output = user_data;
PvSourceOutputPrivate *priv = output->priv;
PinosSourceOutput *output = user_data;
PinosSourceOutputPrivate *priv = output->priv;
GUnixFDList *fdlist;
gint fd[2];
@ -212,9 +212,9 @@ no_format:
}
static void
clear_socket (PvSourceOutput *output)
clear_socket (PinosSourceOutput *output)
{
PvSourceOutputPrivate *priv = output->priv;
PinosSourceOutputPrivate *priv = output->priv;
g_clear_object (&priv->socket);
g_clear_pointer (&priv->requested_format, g_bytes_unref);
@ -223,9 +223,9 @@ clear_socket (PvSourceOutput *output)
static void
stop_transfer (PvSourceOutput *output)
stop_transfer (PinosSourceOutput *output)
{
PvSourceOutputPrivate *priv = output->priv;
PinosSourceOutputPrivate *priv = output->priv;
if (priv->socket) {
clear_socket (output);
@ -234,11 +234,11 @@ stop_transfer (PvSourceOutput *output)
}
static gboolean
handle_stop (PvSourceOutput1 *interface,
handle_stop (PinosSourceOutput1 *interface,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
PvSourceOutput *output = user_data;
PinosSourceOutput *output = user_data;
stop_transfer (output);
@ -248,11 +248,11 @@ handle_stop (PvSourceOutput1 *interface,
}
static gboolean
handle_remove (PvSourceOutput1 *interface,
handle_remove (PinosSourceOutput1 *interface,
GDBusMethodInvocation *invocation,
gpointer user_data)
{
PvSourceOutput *output = user_data;
PinosSourceOutput *output = user_data;
stop_transfer (output);
@ -264,46 +264,47 @@ handle_remove (PvSourceOutput1 *interface,
}
static void
output_register_object (PvSourceOutput *output, const gchar *prefix)
output_register_object (PinosSourceOutput *output,
const gchar *prefix)
{
PvSourceOutputPrivate *priv = output->priv;
PvObjectSkeleton *skel;
PinosSourceOutputPrivate *priv = output->priv;
PinosObjectSkeleton *skel;
gchar *name;
name = g_strdup_printf ("%s/output", prefix);
skel = pv_object_skeleton_new (name);
skel = pinos_object_skeleton_new (name);
g_free (name);
pv_object_skeleton_set_source_output1 (skel, priv->iface);
pinos_object_skeleton_set_source_output1 (skel, priv->iface);
g_free (priv->object_path);
priv->object_path = pv_daemon_export_uniquely (priv->daemon, G_DBUS_OBJECT_SKELETON (skel));
priv->object_path = pinos_daemon_export_uniquely (priv->daemon, G_DBUS_OBJECT_SKELETON (skel));
}
static void
output_unregister_object (PvSourceOutput *output)
output_unregister_object (PinosSourceOutput *output)
{
PvSourceOutputPrivate *priv = output->priv;
PinosSourceOutputPrivate *priv = output->priv;
pv_daemon_unexport (priv->daemon, priv->object_path);
pinos_daemon_unexport (priv->daemon, priv->object_path);
}
static void
pv_source_output_dispose (GObject * object)
pinos_source_output_dispose (GObject * object)
{
PvSourceOutput *output = PV_SOURCE_OUTPUT (object);
PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object);
clear_socket (output);
output_unregister_object (output);
G_OBJECT_CLASS (pv_source_output_parent_class)->dispose (object);
G_OBJECT_CLASS (pinos_source_output_parent_class)->dispose (object);
}
static void
pv_source_output_finalize (GObject * object)
pinos_source_output_finalize (GObject * object)
{
PvSourceOutput *output = PV_SOURCE_OUTPUT (object);
PvSourceOutputPrivate *priv = output->priv;
PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object);
PinosSourceOutputPrivate *priv = output->priv;
g_clear_object (&priv->daemon);
g_clear_object (&priv->iface);
@ -311,39 +312,39 @@ pv_source_output_finalize (GObject * object)
g_free (priv->object_path);
g_free (priv->source_path);
G_OBJECT_CLASS (pv_source_output_parent_class)->finalize (object);
G_OBJECT_CLASS (pinos_source_output_parent_class)->finalize (object);
}
static void
pv_source_output_constructed (GObject * object)
pinos_source_output_constructed (GObject * object)
{
PvSourceOutput *output = PV_SOURCE_OUTPUT (object);
PvSourceOutputPrivate *priv = output->priv;
PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object);
PinosSourceOutputPrivate *priv = output->priv;
output_register_object (output, priv->object_path);
G_OBJECT_CLASS (pv_source_output_parent_class)->constructed (object);
G_OBJECT_CLASS (pinos_source_output_parent_class)->constructed (object);
}
static void
pv_source_output_class_init (PvSourceOutputClass * klass)
pinos_source_output_class_init (PinosSourceOutputClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (PvSourceOutputPrivate));
g_type_class_add_private (klass, sizeof (PinosSourceOutputPrivate));
gobject_class->constructed = pv_source_output_constructed;
gobject_class->dispose = pv_source_output_dispose;
gobject_class->finalize = pv_source_output_finalize;
gobject_class->set_property = pv_source_output_set_property;
gobject_class->get_property = pv_source_output_get_property;
gobject_class->constructed = pinos_source_output_constructed;
gobject_class->dispose = pinos_source_output_dispose;
gobject_class->finalize = pinos_source_output_finalize;
gobject_class->set_property = pinos_source_output_set_property;
gobject_class->get_property = pinos_source_output_get_property;
g_object_class_install_property (gobject_class,
PROP_DAEMON,
g_param_spec_object ("daemon",
"Daemon",
"The Daemon",
PV_TYPE_DAEMON,
PINOS_TYPE_DAEMON,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@ -427,18 +428,18 @@ pv_source_output_class_init (PvSourceOutputClass * klass)
}
static void
pv_source_output_init (PvSourceOutput * output)
pinos_source_output_init (PinosSourceOutput * output)
{
PvSourceOutputPrivate *priv = output->priv = PV_SOURCE_OUTPUT_GET_PRIVATE (output);
PinosSourceOutputPrivate *priv = output->priv = PINOS_SOURCE_OUTPUT_GET_PRIVATE (output);
priv->iface = pv_source_output1_skeleton_new ();
priv->iface = pinos_source_output1_skeleton_new ();
g_signal_connect (priv->iface, "handle-start", (GCallback) handle_start, output);
g_signal_connect (priv->iface, "handle-stop", (GCallback) handle_stop, output);
g_signal_connect (priv->iface, "handle-remove", (GCallback) handle_remove, output);
}
void
pv_source_output_remove (PvSourceOutput *output)
pinos_source_output_remove (PinosSourceOutput *output)
{
stop_transfer (output);
@ -446,11 +447,11 @@ pv_source_output_remove (PvSourceOutput *output)
}
const gchar *
pv_source_output_get_object_path (PvSourceOutput *output)
pinos_source_output_get_object_path (PinosSourceOutput *output)
{
PvSourceOutputPrivate *priv;
PinosSourceOutputPrivate *priv;
g_return_val_if_fail (PV_IS_SOURCE_OUTPUT (output), NULL);
g_return_val_if_fail (PINOS_IS_SOURCE_OUTPUT (output), NULL);
priv = output->priv;
return priv->object_path;

View file

@ -0,0 +1,70 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PINOS_SOURCE_OUTPUT_H__
#define __PINOS_SOURCE_OUTPUT_H__
#include <glib-object.h>
G_BEGIN_DECLS
#define PINOS_TYPE_SOURCE_OUTPUT (pinos_source_output_get_type ())
#define PINOS_IS_SOURCE_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE_OUTPUT))
#define PINOS_IS_SOURCE_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SOURCE_OUTPUT))
#define PINOS_SOURCE_OUTPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SOURCE_OUTPUT, PinosSourceOutputClass))
#define PINOS_SOURCE_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SOURCE_OUTPUT, PinosSourceOutput))
#define PINOS_SOURCE_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SOURCE_OUTPUT, PinosSourceOutputClass))
#define PINOS_SOURCE_OUTPUT_CAST(obj) ((PinosSourceOutput*)(obj))
#define PINOS_SOURCE_OUTPUT_CLASS_CAST(klass) ((PinosSourceOutputClass*)(klass))
typedef struct _PinosSourceOutput PinosSourceOutput;
typedef struct _PinosSourceOutputClass PinosSourceOutputClass;
typedef struct _PinosSourceOutputPrivate PinosSourceOutputPrivate;
/**
* PinosSourceOutput:
*
* Pinos source output object class.
*/
struct _PinosSourceOutput {
GObject object;
PinosSourceOutputPrivate *priv;
};
/**
* PinosSourceOutputClass:
*
* Pinos source output object class.
*/
struct _PinosSourceOutputClass {
GObjectClass parent_class;
};
/* normal GObject stuff */
GType pinos_source_output_get_type (void);
void pinos_source_output_remove (PinosSourceOutput *output);
const gchar * pinos_source_output_get_object_path (PinosSourceOutput *output);
G_END_DECLS
#endif /* __PINOS_SOURCE_OUTPUT_H__ */

View file

@ -20,33 +20,33 @@
#include <gio/gio.h>
#include "client/pinos.h"
#include "client/pv-enumtypes.h"
#include "client/enumtypes.h"
#include "server/pv-source.h"
#include "server/pv-daemon.h"
#include "server/source.h"
#include "server/daemon.h"
#include "dbus/org-pinos.h"
#define PV_SOURCE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_SOURCE, PvSourcePrivate))
#define PINOS_SOURCE_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SOURCE, PinosSourcePrivate))
struct _PvSourcePrivate
struct _PinosSourcePrivate
{
PvDaemon *daemon;
PvSource1 *iface;
PinosDaemon *daemon;
PinosSource1 *iface;
gchar *object_path;
gchar *name;
GVariant *properties;
PvSourceState state;
PinosSourceState state;
GError *error;
GList *outputs;
};
G_DEFINE_ABSTRACT_TYPE (PvSource, pv_source, G_TYPE_OBJECT);
G_DEFINE_ABSTRACT_TYPE (PinosSource, pinos_source, G_TYPE_OBJECT);
enum
{
@ -59,13 +59,13 @@ enum
};
static void
pv_source_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
pinos_source_get_property (GObject *_object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
PvSource *source = PV_SOURCE (_object);
PvSourcePrivate *priv = source->priv;
PinosSource *source = PINOS_SOURCE (_object);
PinosSourcePrivate *priv = source->priv;
switch (prop_id) {
case PROP_DAEMON:
@ -95,13 +95,13 @@ pv_source_get_property (GObject *_object,
}
static void
pv_source_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
pinos_source_set_property (GObject *_object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
PvSource *source = PV_SOURCE (_object);
PvSourcePrivate *priv = source->priv;
PinosSource *source = PINOS_SOURCE (_object);
PinosSourcePrivate *priv = source->priv;
switch (prop_id) {
case PROP_DAEMON:
@ -131,124 +131,130 @@ pv_source_set_property (GObject *_object,
}
static void
source_register_object (PvSource *source)
source_register_object (PinosSource *source)
{
PvSourcePrivate *priv = source->priv;
PvDaemon *daemon = priv->daemon;
PvObjectSkeleton *skel;
PinosSourcePrivate *priv = source->priv;
PinosDaemon *daemon = priv->daemon;
PinosObjectSkeleton *skel;
skel = pv_object_skeleton_new (PV_DBUS_OBJECT_SOURCE);
skel = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_SOURCE);
priv->iface = pv_source1_skeleton_new ();
priv->iface = pinos_source1_skeleton_new ();
g_object_set (priv->iface, "name", priv->name,
"state", priv->state,
"properties", priv->properties,
NULL);
pv_object_skeleton_set_source1 (skel, priv->iface);
pinos_object_skeleton_set_source1 (skel, priv->iface);
g_free (priv->object_path);
priv->object_path = pv_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
pv_daemon_add_source (daemon, source);
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
pinos_daemon_add_source (daemon, source);
return;
}
static void
source_unregister_object (PvSource *source)
source_unregister_object (PinosSource *source)
{
PvSourcePrivate *priv = source->priv;
PinosSourcePrivate *priv = source->priv;
pv_daemon_remove_source (priv->daemon, source);
pv_daemon_unexport (priv->daemon, priv->object_path);
pinos_daemon_remove_source (priv->daemon, source);
pinos_daemon_unexport (priv->daemon, priv->object_path);
g_clear_object (&priv->iface);
}
static void
pv_source_constructed (GObject * object)
pinos_source_constructed (GObject * object)
{
PvSource *source = PV_SOURCE (object);
PinosSource *source = PINOS_SOURCE (object);
source_register_object (source);
G_OBJECT_CLASS (pv_source_parent_class)->constructed (object);
G_OBJECT_CLASS (pinos_source_parent_class)->constructed (object);
}
static void
do_remove_output (PvSourceOutput *output,
do_remove_output (PinosSourceOutput *output,
gpointer user_data)
{
pv_source_output_remove (output);
pinos_source_output_remove (output);
}
static void
pv_source_dispose (GObject * object)
pinos_source_dispose (GObject * object)
{
PvSource *source = PV_SOURCE (object);
PvSourcePrivate *priv = source->priv;
PinosSource *source = PINOS_SOURCE (object);
PinosSourcePrivate *priv = source->priv;
g_list_foreach (priv->outputs, (GFunc) do_remove_output, source);
source_unregister_object (source);
G_OBJECT_CLASS (pv_source_parent_class)->dispose (object);
G_OBJECT_CLASS (pinos_source_parent_class)->dispose (object);
}
static void
pv_source_finalize (GObject * object)
pinos_source_finalize (GObject * object)
{
PvSource *source = PV_SOURCE (object);
PvSourcePrivate *priv = source->priv;
PinosSource *source = PINOS_SOURCE (object);
PinosSourcePrivate *priv = source->priv;
g_free (priv->object_path);
g_free (priv->name);
if (priv->properties)
g_variant_unref (priv->properties);
G_OBJECT_CLASS (pv_source_parent_class)->finalize (object);
G_OBJECT_CLASS (pinos_source_parent_class)->finalize (object);
}
static gboolean
default_set_state (PvSource *source, PvSourceState state)
default_set_state (PinosSource *source,
PinosSourceState state)
{
pv_source_update_state (source, state);
pinos_source_update_state (source, state);
return TRUE;
}
static void
handle_remove_output (PvSourceOutput *output,
gpointer user_data)
handle_remove_output (PinosSourceOutput *output,
gpointer user_data)
{
PvSource *source = user_data;
PinosSource *source = user_data;
pv_source_release_source_output (source, output);
pinos_source_release_source_output (source, output);
}
static PvSourceOutput *
default_create_source_output (PvSource *source,
static PinosSourceOutput *
default_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
{
PvSourcePrivate *priv = source->priv;
PvSourceOutput *output;
PinosSourcePrivate *priv = source->priv;
PinosSourceOutput *output;
output = g_object_new (PV_TYPE_SOURCE_OUTPUT, "daemon", priv->daemon,
"object-path", prefix,
"client-path", client_path,
"source-path", priv->object_path,
"possible-formats", format_filter,
NULL);
output = g_object_new (PINOS_TYPE_SOURCE_OUTPUT, "daemon", priv->daemon,
"object-path", prefix,
"client-path", client_path,
"source-path", priv->object_path,
"possible-formats", format_filter,
NULL);
g_signal_connect (output,
"remove",
(GCallback) handle_remove_output,
source);
g_signal_connect (output, "remove", (GCallback) handle_remove_output, source);
priv->outputs = g_list_prepend (priv->outputs, output);
return g_object_ref (output);
}
static gboolean
default_release_source_output (PvSource *source, PvSourceOutput *output)
default_release_source_output (PinosSource *source,
PinosSourceOutput *output)
{
PvSourcePrivate *priv = source->priv;
PinosSourcePrivate *priv = source->priv;
GList *find;
find = g_list_find (priv->outputs, output);
@ -262,24 +268,24 @@ default_release_source_output (PvSource *source, PvSourceOutput *output)
}
static void
pv_source_class_init (PvSourceClass * klass)
pinos_source_class_init (PinosSourceClass * klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (PvSourcePrivate));
g_type_class_add_private (klass, sizeof (PinosSourcePrivate));
gobject_class->constructed = pv_source_constructed;
gobject_class->dispose = pv_source_dispose;
gobject_class->finalize = pv_source_finalize;
gobject_class->set_property = pv_source_set_property;
gobject_class->get_property = pv_source_get_property;
gobject_class->constructed = pinos_source_constructed;
gobject_class->dispose = pinos_source_dispose;
gobject_class->finalize = pinos_source_finalize;
gobject_class->set_property = pinos_source_set_property;
gobject_class->get_property = pinos_source_get_property;
g_object_class_install_property (gobject_class,
PROP_DAEMON,
g_param_spec_object ("daemon",
"Daemon",
"The Daemon",
PV_TYPE_DAEMON,
PINOS_TYPE_DAEMON,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
@ -308,8 +314,8 @@ pv_source_class_init (PvSourceClass * klass)
g_param_spec_enum ("state",
"State",
"The state of the source",
PV_TYPE_SOURCE_STATE,
PV_SOURCE_STATE_INIT,
PINOS_TYPE_SOURCE_STATE,
PINOS_SOURCE_STATE_INIT,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS));
@ -330,20 +336,21 @@ pv_source_class_init (PvSourceClass * klass)
}
static void
pv_source_init (PvSource * source)
pinos_source_init (PinosSource * source)
{
source->priv = PV_SOURCE_GET_PRIVATE (source);
source->priv = PINOS_SOURCE_GET_PRIVATE (source);
}
GBytes *
pv_source_get_formats (PvSource *source, GBytes *filter)
pinos_source_get_formats (PinosSource *source,
GBytes *filter)
{
PvSourceClass *klass;
PinosSourceClass *klass;
GBytes *res;
g_return_val_if_fail (PV_IS_SOURCE (source), NULL);
g_return_val_if_fail (PINOS_IS_SOURCE (source), NULL);
klass = PV_SOURCE_GET_CLASS (source);
klass = PINOS_SOURCE_GET_CLASS (source);
if (klass->get_formats)
res = klass->get_formats (source, filter);
@ -354,14 +361,15 @@ pv_source_get_formats (PvSource *source, GBytes *filter)
}
gboolean
pv_source_set_state (PvSource *source, PvSourceState state)
pinos_source_set_state (PinosSource *source,
PinosSourceState state)
{
PvSourceClass *klass;
PinosSourceClass *klass;
gboolean res;
g_return_val_if_fail (PV_IS_SOURCE (source), FALSE);
g_return_val_if_fail (PINOS_IS_SOURCE (source), FALSE);
klass = PV_SOURCE_GET_CLASS (source);
klass = PINOS_SOURCE_GET_CLASS (source);
if (klass->set_state)
res = klass->set_state (source, state);
@ -372,47 +380,49 @@ pv_source_set_state (PvSource *source, PvSourceState state)
}
void
pv_source_update_state (PvSource *source, PvSourceState state)
pinos_source_update_state (PinosSource *source,
PinosSourceState state)
{
PvSourcePrivate *priv;
PinosSourcePrivate *priv;
g_return_if_fail (PV_IS_SOURCE (source));
g_return_if_fail (PINOS_IS_SOURCE (source));
priv = source->priv;
if (priv->state != state) {
priv->state = state;
pv_source1_set_state (priv->iface, state);
pinos_source1_set_state (priv->iface, state);
g_object_notify (G_OBJECT (source), "state");
}
}
void
pv_source_report_error (PvSource *source, GError *error)
pinos_source_report_error (PinosSource *source,
GError *error)
{
PvSourcePrivate *priv;
PinosSourcePrivate *priv;
g_return_if_fail (PV_IS_SOURCE (source));
g_return_if_fail (PINOS_IS_SOURCE (source));
priv = source->priv;
g_clear_error (&priv->error);
priv->error = error;
priv->state = PV_SOURCE_STATE_ERROR;
priv->state = PINOS_SOURCE_STATE_ERROR;
g_object_notify (G_OBJECT (source), "state");
}
PvSourceOutput *
pv_source_create_source_output (PvSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
PinosSourceOutput *
pinos_source_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error)
{
PvSourceClass *klass;
PvSourceOutput *res;
PinosSourceClass *klass;
PinosSourceOutput *res;
g_return_val_if_fail (PV_IS_SOURCE (source), NULL);
g_return_val_if_fail (PINOS_IS_SOURCE (source), NULL);
klass = PV_SOURCE_GET_CLASS (source);
klass = PINOS_SOURCE_GET_CLASS (source);
if (klass->create_source_output) {
res = klass->create_source_output (source, client_path, format_filter, prefix, error);
@ -429,15 +439,16 @@ pv_source_create_source_output (PvSource *source,
}
gboolean
pv_source_release_source_output (PvSource *source, PvSourceOutput *output)
pinos_source_release_source_output (PinosSource *source,
PinosSourceOutput *output)
{
PvSourceClass *klass;
PinosSourceClass *klass;
gboolean res;
g_return_val_if_fail (PV_IS_SOURCE (source), FALSE);
g_return_val_if_fail (PV_IS_SOURCE_OUTPUT (output), FALSE);
g_return_val_if_fail (PINOS_IS_SOURCE (source), FALSE);
g_return_val_if_fail (PINOS_IS_SOURCE_OUTPUT (output), FALSE);
klass = PV_SOURCE_GET_CLASS (source);
klass = PINOS_SOURCE_GET_CLASS (source);
if (klass->release_source_output)
res = klass->release_source_output (source, output);
@ -448,11 +459,11 @@ pv_source_release_source_output (PvSource *source, PvSourceOutput *output)
}
const gchar *
pv_source_get_object_path (PvSource *source)
pinos_source_get_object_path (PinosSource *source)
{
PvSourcePrivate *priv;
PinosSourcePrivate *priv;
g_return_val_if_fail (PV_IS_SOURCE (source), NULL);
g_return_val_if_fail (PINOS_IS_SOURCE (source), NULL);
priv = source->priv;
return priv->object_path;

102
src/server/source.h Normal file
View file

@ -0,0 +1,102 @@
/* Pinos
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PINOS_SOURCE_H__
#define __PINOS_SOURCE_H__
#include <glib-object.h>
#include <gio/gio.h>
G_BEGIN_DECLS
typedef struct _PinosSource PinosSource;
typedef struct _PinosSourceClass PinosSourceClass;
typedef struct _PinosSourcePrivate PinosSourcePrivate;
#include "client/introspect.h"
#include "server/source-output.h"
#define PINOS_TYPE_SOURCE (pinos_source_get_type ())
#define PINOS_IS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE))
#define PINOS_IS_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SOURCE))
#define PINOS_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SOURCE, PinosSourceClass))
#define PINOS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SOURCE, PinosSource))
#define PINOS_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SOURCE, PinosSourceClass))
#define PINOS_SOURCE_CAST(obj) ((PinosSource*)(obj))
#define PINOS_SOURCE_CLASS_CAST(klass) ((PinosSourceClass*)(klass))
/**
* PinosSource:
*
* Pinos source object class.
*/
struct _PinosSource {
GObject object;
PinosSourcePrivate *priv;
};
/**
* PinosSourceClass:
* @get_formats: called to get a list of supported formats from the source
* @set_state: called to change the current state of the source
* @create_source_output: called to create a new source-output object
* @release_source_output: called to release a source-output object
*
* Pinos source object class.
*/
struct _PinosSourceClass {
GObjectClass parent_class;
GBytes * (*get_formats) (PinosSource *source, GBytes *filter);
gboolean (*set_state) (PinosSource *source, PinosSourceState);
PinosSourceOutput * (*create_source_output) (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error);
gboolean (*release_source_output) (PinosSource *source,
PinosSourceOutput *output);
};
/* normal GObject stuff */
GType pinos_source_get_type (void);
const gchar * pinos_source_get_object_path (PinosSource *source);
GBytes * pinos_source_get_formats (PinosSource *source, GBytes *filter);
gboolean pinos_source_set_state (PinosSource *source, PinosSourceState state);
void pinos_source_update_state (PinosSource *source, PinosSourceState state);
void pinos_source_report_error (PinosSource *source, GError *error);
PinosSourceOutput * pinos_source_create_source_output (PinosSource *source,
const gchar *client_path,
GBytes *format_filter,
const gchar *prefix,
GError **error);
gboolean pinos_source_release_source_output (PinosSource *source,
PinosSourceOutput *output);
G_END_DECLS
#endif /* __PINOS_SOURCE_H__ */