Unverified Commit 3d4b547d authored by Julian Sparber's avatar Julian Sparber
Browse files

Ringer: Use Manager

parent c5cb1a97
......@@ -335,7 +335,7 @@ start_proper (CallsApplication *self)
provider = calls_manager_get_real_provider (calls_manager_get_default ());
g_assert (provider != NULL);
self->ringer = calls_ringer_new (provider);
self->ringer = calls_ringer_new ();
g_assert (self->ringer != NULL);
self->record_store = calls_record_store_new (provider);
......
......@@ -23,7 +23,7 @@
*/
#include "calls-ringer.h"
#include "calls-enumerate.h"
#include "calls-manager.h"
#include "config.h"
#include <gsound.h>
......@@ -35,7 +35,6 @@ struct _CallsRinger
{
GObject parent_instance;
CallsProvider *provider;
gchar *theme_name;
GSoundContext *ctx;
unsigned ring_count;
......@@ -44,13 +43,6 @@ struct _CallsRinger
G_DEFINE_TYPE (CallsRinger, calls_ringer, G_TYPE_OBJECT);
enum {
PROP_0,
PROP_PROVIDER,
PROP_LAST_PROP,
};
static GParamSpec *props[PROP_LAST_PROP];
static void
ringer_error (CallsRinger *self,
......@@ -330,83 +322,55 @@ static void
call_added_cb (CallsRinger *self, CallsCall *call)
{
update_count (self, call, +1);
g_signal_connect_swapped (call,
"state-changed",
G_CALLBACK (state_changed_cb),
self);
}
static void
call_removed_cb (CallsRinger *self, CallsCall *call, const gchar *reason)
call_removed_cb (CallsRinger *self, CallsCall *call)
{
update_count (self, call, -1);
}
static void
calls_ringer_init (CallsRinger *self)
{
g_signal_handlers_disconnect_by_data (call, self);
}
static void
set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
calls_ringer_init (CallsRinger *self)
{
CallsRinger *self = CALLS_RINGER (object);
switch (property_id) {
case PROP_PROVIDER:
g_set_object (&self->provider, CALLS_PROVIDER (g_value_get_object (value)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
set_up_provider (CallsRinger *self)
{
CallsEnumerateParams *params;
params = calls_enumerate_params_new (self);
calls_enumerate_params_add
(params, CALLS_TYPE_ORIGIN, "call-added", G_CALLBACK (call_added_cb));
calls_enumerate_params_add
(params, CALLS_TYPE_ORIGIN, "call-removed", G_CALLBACK (call_removed_cb));
calls_enumerate_params_add
(params, CALLS_TYPE_CALL, "state-changed", G_CALLBACK (state_changed_cb));
calls_enumerate (self->provider, params);
g_object_unref (params);
}
static void
constructed (GObject *object)
{
g_autoptr (GList) calls = NULL;
GList *c;
CallsRinger *self = CALLS_RINGER (object);
monitor_theme_name (self);
create_ctx (self);
set_up_provider (self);
G_OBJECT_CLASS (calls_ringer_parent_class)->constructed (object);
}
g_signal_connect_swapped (calls_manager_get_default (),
"call-add",
G_CALLBACK (call_added_cb),
self);
static void
dispose (GObject *object)
{
CallsRinger *self = CALLS_RINGER (object);
g_signal_connect_swapped (calls_manager_get_default (),
"call-remove",
G_CALLBACK (call_removed_cb),
self);
g_clear_object (&self->provider);
calls = calls_manager_get_calls (calls_manager_get_default ());
for (c = calls; c != NULL; c = c->next) {
call_added_cb (self, c->data);
}
G_OBJECT_CLASS (calls_ringer_parent_class)->dispose (object);
G_OBJECT_CLASS (calls_ringer_parent_class)->constructed (object);
}
......@@ -426,25 +390,12 @@ calls_ringer_class_init (CallsRingerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->set_property = set_property;
object_class->constructed = constructed;
object_class->dispose = dispose;
object_class->finalize = finalize;
props[PROP_PROVIDER] =
g_param_spec_object ("provider",
_("Provider"),
_("An object implementing low-level call-making functionality"),
CALLS_TYPE_PROVIDER,
G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, PROP_LAST_PROP, props);
}
CallsRinger *
calls_ringer_new (CallsProvider *provider)
calls_ringer_new (void)
{
return g_object_new (CALLS_TYPE_RINGER,
"provider", provider,
NULL);
return g_object_new (CALLS_TYPE_RINGER, NULL);
}
......@@ -25,7 +25,7 @@
#ifndef CALLS_RINGER_H__
#define CALLS_RINGER_H__
#include "calls-provider.h"
#include <glib-object.h>
G_BEGIN_DECLS
......@@ -33,7 +33,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CallsRinger, calls_ringer, CALLS, RINGER, GObject);
CallsRinger *calls_ringer_new (CallsProvider *provider);
CallsRinger *calls_ringer_new (void);
G_END_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment