mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 04:15:32 +00:00
origin: Add id property and adapt to changes
The id property will be used to keep track of which origin was used for a call, so that we can default to reusing the same origin when placing a call from the history.
This commit is contained in:
parent
04605efac7
commit
16b86c29b2
12 changed files with 101 additions and 6 deletions
|
@ -50,6 +50,7 @@ G_DEFINE_TYPE_WITH_CODE (CallsDummyOrigin, calls_dummy_origin, G_TYPE_OBJECT,
|
|||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_ID,
|
||||
/* Property for setting the origins name upon construction */
|
||||
PROP_DUMMY_NAME_CONSTRUCTOR,
|
||||
|
||||
|
@ -182,6 +183,9 @@ set_property (GObject *object,
|
|||
g_string_assign (self->name, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_ID: /* ignored for the dummy origin */
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -198,6 +202,10 @@ get_property (GObject *object,
|
|||
CallsDummyOrigin *self = CALLS_DUMMY_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ID:
|
||||
g_value_set_string (value, self->name->str);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, self->name->str);
|
||||
break;
|
||||
|
@ -263,6 +271,7 @@ calls_dummy_origin_class_init (CallsDummyOriginClass *klass)
|
|||
g_object_class_override_property (object_class, ID, NAME); \
|
||||
props[ID] = g_object_class_find_property(object_class, NAME);
|
||||
|
||||
IMPLEMENTS (PROP_ID, "id");
|
||||
IMPLEMENTS (PROP_NAME, "name");
|
||||
IMPLEMENTS (PROP_CALLS, "calls");
|
||||
IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
|
||||
|
|
|
@ -49,7 +49,9 @@ struct _CallsMMOrigin
|
|||
char *last_ussd_response;
|
||||
|
||||
gulong ussd_handle_id;
|
||||
gchar *name;
|
||||
|
||||
char *id;
|
||||
char *name;
|
||||
GHashTable *calls;
|
||||
char *country_code;
|
||||
};
|
||||
|
@ -68,6 +70,7 @@ G_DEFINE_TYPE_WITH_CODE (CallsMMOrigin, calls_mm_origin, G_TYPE_OBJECT,
|
|||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ID,
|
||||
PROP_NAME,
|
||||
PROP_CALLS,
|
||||
PROP_MODEM,
|
||||
|
@ -640,6 +643,10 @@ set_property (GObject *object,
|
|||
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ID:
|
||||
self->id = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_MODEM:
|
||||
g_set_object (&self->mm_obj, g_value_get_object(value));
|
||||
break;
|
||||
|
@ -660,6 +667,10 @@ get_property (GObject *object,
|
|||
CallsMMOrigin *self = CALLS_MM_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ID:
|
||||
g_value_set_string (value, self->id);
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, self->name);
|
||||
break;
|
||||
|
@ -884,6 +895,7 @@ calls_mm_origin_class_init (CallsMMOriginClass *klass)
|
|||
g_object_class_override_property (object_class, ID, NAME); \
|
||||
props[ID] = g_object_class_find_property(object_class, NAME);
|
||||
|
||||
IMPLEMENTS (PROP_ID, "id");
|
||||
IMPLEMENTS (PROP_NAME, "name");
|
||||
IMPLEMENTS (PROP_CALLS, "calls");
|
||||
IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
|
||||
|
@ -928,10 +940,12 @@ calls_mm_origin_init (CallsMMOrigin *self)
|
|||
}
|
||||
|
||||
CallsMMOrigin *
|
||||
calls_mm_origin_new (MMObject *mm_obj)
|
||||
calls_mm_origin_new (MMObject *mm_obj,
|
||||
const char *id)
|
||||
{
|
||||
return g_object_new (CALLS_TYPE_MM_ORIGIN,
|
||||
"mm-object", mm_obj,
|
||||
"id", id,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ G_BEGIN_DECLS
|
|||
|
||||
G_DECLARE_FINAL_TYPE (CallsMMOrigin, calls_mm_origin, CALLS, MM_ORIGIN, GObject);
|
||||
|
||||
CallsMMOrigin *calls_mm_origin_new (MMObject *modem);
|
||||
CallsMMOrigin *calls_mm_origin_new (MMObject *modem,
|
||||
const char *id);
|
||||
gboolean calls_mm_origin_matches (CallsMMOrigin *self,
|
||||
MMObject *modem);
|
||||
|
||||
|
|
|
@ -130,7 +130,9 @@ add_origin (CallsMMProvider *self,
|
|||
{
|
||||
MMObject *mm_obj;
|
||||
g_autoptr (CallsMMOrigin) origin = NULL;
|
||||
g_autoptr (MMModem3gpp) modem_3gpp = NULL;
|
||||
const gchar *path;
|
||||
g_autofree char *imei = NULL;
|
||||
|
||||
mm_obj = MM_OBJECT (object);
|
||||
path = g_dbus_object_get_object_path (object);
|
||||
|
@ -146,7 +148,10 @@ add_origin (CallsMMProvider *self,
|
|||
|
||||
g_assert (MM_IS_OBJECT (object));
|
||||
|
||||
origin = calls_mm_origin_new (mm_obj);
|
||||
modem_3gpp = mm_object_get_modem_3gpp (mm_obj);
|
||||
|
||||
origin = calls_mm_origin_new (mm_obj,
|
||||
mm_modem_3gpp_get_imei (modem_3gpp));
|
||||
g_list_store_append (self->origins, origin);
|
||||
|
||||
update_status (self);
|
||||
|
|
|
@ -55,6 +55,7 @@ G_DEFINE_TYPE_WITH_CODE (CallsOfonoOrigin, calls_ofono_origin, G_TYPE_OBJECT,
|
|||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ID,
|
||||
PROP_NAME,
|
||||
PROP_CALLS,
|
||||
PROP_MODEM,
|
||||
|
@ -143,6 +144,10 @@ set_property (GObject *object,
|
|||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ID:
|
||||
/* we're using a hardcoded value, so let's ignore it */
|
||||
break;
|
||||
|
||||
case PROP_MODEM:
|
||||
g_set_object
|
||||
(&self->modem, GDBO_MODEM (g_value_get_object (value)));
|
||||
|
@ -164,6 +169,10 @@ get_property (GObject *object,
|
|||
CallsOfonoOrigin *self = CALLS_OFONO_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ID:
|
||||
g_value_set_string (value, "ofono");
|
||||
break;
|
||||
|
||||
case PROP_NAME:
|
||||
g_value_set_string (value, self->name);
|
||||
break;
|
||||
|
@ -569,6 +578,7 @@ calls_ofono_origin_class_init (CallsOfonoOriginClass *klass)
|
|||
g_object_class_override_property (object_class, ID, NAME); \
|
||||
props[ID] = g_object_class_find_property(object_class, NAME);
|
||||
|
||||
IMPLEMENTS (PROP_NAME, "id");
|
||||
IMPLEMENTS (PROP_NAME, "name");
|
||||
IMPLEMENTS (PROP_CALLS, "calls");
|
||||
IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
|
||||
|
|
|
@ -359,10 +359,12 @@ static void
|
|||
on_login_clicked (CallsSipAccountWidget *self)
|
||||
{
|
||||
CallsSipOrigin *origin;
|
||||
g_autofree char *id = g_uuid_string_random ();
|
||||
|
||||
g_debug ("Logging into newly created account");
|
||||
|
||||
origin = calls_sip_provider_add_origin (self->provider,
|
||||
id,
|
||||
gtk_entry_get_text (GTK_ENTRY (self->host)),
|
||||
gtk_entry_get_text (GTK_ENTRY (self->user)),
|
||||
gtk_entry_get_text (GTK_ENTRY (self->password)),
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
enum {
|
||||
PROP_0,
|
||||
PROP_NAME,
|
||||
PROP_ID,
|
||||
PROP_ACC_HOST,
|
||||
PROP_ACC_USER,
|
||||
PROP_ACC_PASSWORD,
|
||||
|
@ -118,6 +119,7 @@ struct _CallsSipOrigin
|
|||
const char *protocol_prefix;
|
||||
char *address;
|
||||
char *name;
|
||||
char *id;
|
||||
|
||||
GList *calls;
|
||||
GHashTable *call_handles;
|
||||
|
@ -1188,6 +1190,10 @@ calls_sip_origin_set_property (GObject *object,
|
|||
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ID: /* contruct only */
|
||||
self->id = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
case PROP_ACC_HOST:
|
||||
g_free (self->host);
|
||||
self->host = g_value_dup_string (value);
|
||||
|
@ -1263,6 +1269,11 @@ calls_sip_origin_get_property (GObject *object,
|
|||
case PROP_NAME:
|
||||
g_value_set_string (value, self->name);
|
||||
break;
|
||||
|
||||
case PROP_ID:
|
||||
g_value_set_string (value, self->id);
|
||||
break;
|
||||
|
||||
case PROP_ACC_HOST:
|
||||
g_value_set_string (value, self->host);
|
||||
break;
|
||||
|
@ -1359,6 +1370,7 @@ calls_sip_origin_dispose (GObject *object)
|
|||
{
|
||||
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
|
||||
|
||||
g_clear_pointer (&self->id, g_free);
|
||||
g_clear_pointer (&self->own_ip, g_free);
|
||||
g_clear_pointer (&self->transport_protocol, g_free);
|
||||
g_clear_pointer (&self->display_name, g_free);
|
||||
|
@ -1495,6 +1507,7 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass)
|
|||
g_object_class_override_property (object_class, ID, NAME); \
|
||||
props[ID] = g_object_class_find_property(object_class, NAME);
|
||||
|
||||
IMPLEMENTS (PROP_ID, "id");
|
||||
IMPLEMENTS (PROP_NAME, "name");
|
||||
IMPLEMENTS (PROP_CALLS, "calls");
|
||||
IMPLEMENTS (PROP_COUNTRY_CODE, "country-code");
|
||||
|
|
|
@ -116,6 +116,7 @@ on_origin_pw_looked_up (GObject *source,
|
|||
{
|
||||
SipOriginLoadData *data;
|
||||
g_autoptr (GError) error = NULL;
|
||||
g_autofree char *id = NULL;
|
||||
g_autofree char *name = NULL;
|
||||
g_autofree char *host = NULL;
|
||||
g_autofree char *user = NULL;
|
||||
|
@ -132,6 +133,11 @@ on_origin_pw_looked_up (GObject *source,
|
|||
|
||||
data = user_data;
|
||||
|
||||
if (g_key_file_has_key (data->key_file, data->name, "Id", NULL))
|
||||
id = g_key_file_get_string (data->key_file, data->name, "Id", NULL);
|
||||
else
|
||||
id = g_strdup (data->name);
|
||||
|
||||
host = g_key_file_get_string (data->key_file, data->name, "Host", NULL);
|
||||
user = g_key_file_get_string (data->key_file, data->name, "User", NULL);
|
||||
display_name = g_key_file_get_string (data->key_file, data->name, "DisplayName", NULL);
|
||||
|
@ -172,6 +178,7 @@ on_origin_pw_looked_up (GObject *source,
|
|||
#undef IS_NULL_OR_EMPTY
|
||||
|
||||
calls_sip_provider_add_origin_full (data->provider,
|
||||
id,
|
||||
host,
|
||||
user,
|
||||
password,
|
||||
|
@ -273,6 +280,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
|
|||
GKeyFile *key_file,
|
||||
const char *name)
|
||||
{
|
||||
g_autofree char *id = NULL;
|
||||
g_autofree char *host = NULL;
|
||||
g_autofree char *user = NULL;
|
||||
g_autofree char *password = NULL;
|
||||
|
@ -289,6 +297,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
|
|||
g_assert (key_file);
|
||||
|
||||
g_object_get (origin,
|
||||
"id", &id,
|
||||
"host", &host,
|
||||
"user", &user,
|
||||
"password", &password,
|
||||
|
@ -301,6 +310,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
|
|||
"can-tel", &can_tel,
|
||||
NULL);
|
||||
|
||||
g_key_file_set_string (key_file, name, "Id", id);
|
||||
g_key_file_set_string (key_file, name, "Host", host);
|
||||
g_key_file_set_string (key_file, name, "User", user);
|
||||
g_key_file_set_string (key_file, name, "DisplayName", display_name ?: "");
|
||||
|
@ -311,8 +321,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
|
|||
g_key_file_set_integer (key_file, name, "LocalPort", local_port);
|
||||
g_key_file_set_boolean (key_file, name, "CanTel", can_tel);
|
||||
|
||||
label_secret = g_strdup_printf ("Calls Password for %s",
|
||||
calls_account_get_address (CALLS_ACCOUNT (origin)));
|
||||
label_secret = g_strdup_printf ("Calls Password for %s", id);
|
||||
|
||||
/* save to keyring */
|
||||
secret_password_store (calls_secret_get_schema (), NULL, label_secret, password,
|
||||
|
@ -632,6 +641,7 @@ calls_sip_provider_init (CallsSipProvider *self)
|
|||
/**
|
||||
* calls_sip_provider_add_origin:
|
||||
* @self: A #CallsSipProvider
|
||||
* @id: The id of the new origin (should be unique)
|
||||
* @host: The host to connect to
|
||||
* @user: The username to use
|
||||
* @password: The password to use
|
||||
|
@ -645,6 +655,7 @@ calls_sip_provider_init (CallsSipProvider *self)
|
|||
*/
|
||||
CallsSipOrigin *
|
||||
calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||
const char *id,
|
||||
const char *host,
|
||||
const char *user,
|
||||
const char *password,
|
||||
|
@ -654,6 +665,7 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
|
|||
gboolean store_credentials)
|
||||
{
|
||||
return calls_sip_provider_add_origin_full (self,
|
||||
id,
|
||||
host,
|
||||
user,
|
||||
password,
|
||||
|
@ -670,6 +682,7 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
|
|||
/**
|
||||
* calls_sip_provider_add_origin_full:
|
||||
* @self: A #CallsSipProvider
|
||||
* @id: The id of the new origin (should be unique)
|
||||
* @host: The host to connect to
|
||||
* @user: The username to use
|
||||
* @password: The password to use
|
||||
|
@ -688,6 +701,7 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
|
|||
*/
|
||||
CallsSipOrigin *
|
||||
calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
||||
const char *id,
|
||||
const char *host,
|
||||
const char *user,
|
||||
const char *password,
|
||||
|
@ -704,6 +718,7 @@ calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
|||
g_autofree char *protocol = NULL;
|
||||
|
||||
g_return_val_if_fail (CALLS_IS_SIP_PROVIDER (self), NULL);
|
||||
g_return_val_if_fail (id || *id, NULL);
|
||||
|
||||
/* direct-mode is mostly useful for testing without a SIP server */
|
||||
if (!direct_mode) {
|
||||
|
@ -719,6 +734,7 @@ calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
|||
}
|
||||
|
||||
origin = g_object_new (CALLS_TYPE_SIP_ORIGIN,
|
||||
"id", id,
|
||||
"sip-context", self->ctx,
|
||||
"host", host,
|
||||
"user", user,
|
||||
|
|
|
@ -38,6 +38,7 @@ G_DECLARE_FINAL_TYPE (CallsSipProvider, calls_sip_provider, CALLS, SIP_PROVIDER,
|
|||
|
||||
CallsSipProvider *calls_sip_provider_new (void);
|
||||
CallsSipOrigin *calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||
const char *id,
|
||||
const char *host,
|
||||
const char *user,
|
||||
const char *password,
|
||||
|
@ -46,6 +47,7 @@ CallsSipOrigin *calls_sip_provider_add_origin (CallsSipProvider *s
|
|||
gint port,
|
||||
gboolean store_credentials);
|
||||
CallsSipOrigin *calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
||||
const char *id,
|
||||
const char *host,
|
||||
const char *user,
|
||||
const char *password,
|
||||
|
|
|
@ -70,6 +70,14 @@ calls_origin_default_init (CallsOriginInterface *iface)
|
|||
NULL,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_interface_install_property (
|
||||
iface,
|
||||
g_param_spec_string ("id",
|
||||
"ID",
|
||||
"ID of the origin",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
signals[SIGNAL_CALL_ADDED] =
|
||||
g_signal_newv ("call-added",
|
||||
G_TYPE_FROM_INTERFACE (iface),
|
||||
|
@ -101,6 +109,17 @@ calls_origin_default_init (CallsOriginInterface *iface)
|
|||
*/
|
||||
DEFINE_ORIGIN_GETTER(name, char *, NULL);
|
||||
|
||||
/**
|
||||
* calls_origin_get_id:
|
||||
* @self: a #CallsOrigin
|
||||
*
|
||||
* Get the id of the origin.
|
||||
*
|
||||
* Returns (transfer full): A string containing the id. The string must be freed by
|
||||
* the caller.
|
||||
*/
|
||||
DEFINE_ORIGIN_GETTER(id, char *, NULL);
|
||||
|
||||
/**
|
||||
* calls_origin_get_calls:
|
||||
* @self: a #CallsOrigin
|
||||
|
|
|
@ -51,6 +51,7 @@ struct _CallsOriginInterface
|
|||
typedef void (*CallsOriginForeachCallFunc) (gpointer param, CallsCall* call, CallsOrigin* origin);
|
||||
|
||||
char * calls_origin_get_name (CallsOrigin *self);
|
||||
char * calls_origin_get_id (CallsOrigin *self);
|
||||
GList * calls_origin_get_calls (CallsOrigin *self);
|
||||
void calls_origin_foreach_call (CallsOrigin *self,
|
||||
CallsOriginForeachCallFunc callback,
|
||||
|
|
|
@ -364,6 +364,7 @@ setup_sip_origins (SipFixture *fixture,
|
|||
|
||||
fixture->origin_alice =
|
||||
calls_sip_provider_add_origin_full (fixture->provider,
|
||||
"sip1",
|
||||
NULL,
|
||||
"alice",
|
||||
NULL,
|
||||
|
@ -378,6 +379,7 @@ setup_sip_origins (SipFixture *fixture,
|
|||
|
||||
fixture->origin_bob =
|
||||
calls_sip_provider_add_origin_full (fixture->provider,
|
||||
"sip2",
|
||||
NULL,
|
||||
"bob",
|
||||
NULL,
|
||||
|
@ -392,6 +394,7 @@ setup_sip_origins (SipFixture *fixture,
|
|||
|
||||
fixture->origin_offline =
|
||||
calls_sip_provider_add_origin_full (fixture->provider,
|
||||
"sip3",
|
||||
"sip.imaginary-host.org",
|
||||
"username",
|
||||
"password",
|
||||
|
|
Loading…
Reference in a new issue