1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-06 11:35:32 +00:00

account: Add address property

This commit is contained in:
Evangelos Ribeiro Tzaras 2021-07-04 00:24:30 +02:00 committed by Evangelos Ribeiro Tzaras
parent dd3fbf646e
commit a638b64402
3 changed files with 53 additions and 1 deletions

View file

@ -70,6 +70,7 @@ enum {
PROP_ACC_LOCAL_PORT,
PROP_SIP_CONTEXT,
PROP_ACC_STATE,
PROP_ACC_ADDRESS,
PROP_CALLS,
PROP_COUNTRY_CODE,
PROP_LAST_PROP,
@ -873,7 +874,6 @@ go_online (CallsAccount *account,
CallsSipOrigin *self;
g_assert (CALLS_IS_ACCOUNT (account));
g_assert (CALLS_IS_ORIGIN (account));
g_assert (CALLS_IS_SIP_ORIGIN (account));
self = CALLS_SIP_ORIGIN (account);
@ -901,6 +901,19 @@ go_online (CallsAccount *account,
}
}
static const char *
get_address (CallsAccount *account)
{
CallsSipOrigin *self;
g_assert (CALLS_IS_ACCOUNT (account));
g_assert (CALLS_IS_SIP_ORIGIN (account));
self = CALLS_SIP_ORIGIN (account);
return self->address;
}
static void
setup_account_for_direct_connection (CallsSipOrigin *self)
@ -1141,6 +1154,10 @@ calls_sip_origin_get_property (GObject *object,
g_value_set_enum (value, self->state);
break;
case PROP_ACC_ADDRESS:
g_value_set_string (value, get_address (CALLS_ACCOUNT (self)));
break;
case PROP_COUNTRY_CODE:
g_value_set_string (value, NULL);
break;
@ -1314,6 +1331,9 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass)
g_object_class_override_property (object_class, PROP_ACC_STATE, "account-state");
props[PROP_ACC_STATE] = g_object_class_find_property (object_class, "account-state");
g_object_class_override_property (object_class, PROP_ACC_ADDRESS, "address");
props[PROP_ACC_ADDRESS] = g_object_class_find_property (object_class, "address");
#define IMPLEMENTS(ID, NAME) \
g_object_class_override_property (object_class, ID, NAME); \
props[ID] = g_object_class_find_property(object_class, NAME);
@ -1343,6 +1363,7 @@ static void
calls_sip_origin_accounts_interface_init (CallsAccountInterface *iface)
{
iface->go_online = go_online;
iface->get_address = get_address;
}

View file

@ -48,6 +48,15 @@ calls_account_default_init (CallsAccountInterface *iface)
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY));
g_object_interface_install_property (iface,
g_param_spec_string ("address",
"Address",
"The address of this account",
NULL,
G_PARAM_READABLE |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY));
}
/**
@ -88,3 +97,23 @@ calls_account_get_state (CallsAccount *self)
return state;
}
/**
* calls_account_get_address:
* @self: A #CallsAccount
*
* Returns: The address under which this account can be reached.
* For example: alice@example.org for SIP and XMPP/Jingle or @alice:example.org for Matrix
*/
const char *
calls_account_get_address (CallsAccount *self)
{
CallsAccountInterface *iface;
g_return_val_if_fail (CALLS_IS_ACCOUNT (self), NULL);
iface = CALLS_ACCOUNT_GET_IFACE (self);
g_return_val_if_fail (iface->get_address, NULL);
return iface->get_address (self);
}

View file

@ -42,6 +42,7 @@ struct _CallsAccountInterface
void (*go_online) (CallsAccount *self,
gboolean online);
const char *(*get_address) (CallsAccount *self);
};
/**
* CallsAccountState:
@ -69,6 +70,7 @@ typedef enum {
void calls_account_go_online (CallsAccount *self,
gboolean online);
const char *calls_account_get_address (CallsAccount *self);
CallsAccountState calls_account_get_state (CallsAccount *self);
G_END_DECLS