mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2024-11-04 23:51:17 +00:00
sip: Store media encryption account preference to disk
This commit is contained in:
parent
aeae044534
commit
50e7c87a4d
6 changed files with 108 additions and 63 deletions
|
@ -126,6 +126,23 @@ get_selected_protocol (CallsSipAccountWidget *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static SipMediaEncryption
|
||||||
|
get_selected_media_encryption (CallsSipAccountWidget *self)
|
||||||
|
{
|
||||||
|
g_autoptr (HdyValueObject) obj = NULL;
|
||||||
|
SipMediaEncryption media_encryption = SIP_MEDIA_ENCRYPTION_NONE;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if ((i = hdy_combo_row_get_selected_index (self->media_encryption)) != -1) {
|
||||||
|
obj = g_list_model_get_item (G_LIST_MODEL (self->media_encryption_store), i);
|
||||||
|
media_encryption = (SipMediaEncryption) GPOINTER_TO_INT (g_object_get_data (G_OBJECT (obj), "value"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return media_encryption;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_media_encryption (CallsSipAccountWidget *self)
|
update_media_encryption (CallsSipAccountWidget *self)
|
||||||
{
|
{
|
||||||
|
@ -477,6 +494,7 @@ on_login_clicked (CallsSipAccountWidget *self)
|
||||||
gtk_entry_get_text (GTK_ENTRY (self->display_name)),
|
gtk_entry_get_text (GTK_ENTRY (self->display_name)),
|
||||||
get_selected_protocol (self),
|
get_selected_protocol (self),
|
||||||
get_port (self),
|
get_port (self),
|
||||||
|
get_selected_media_encryption (self),
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|
||||||
self->origin = origin;
|
self->origin = origin;
|
||||||
|
@ -510,6 +528,7 @@ on_apply_clicked (CallsSipAccountWidget *self)
|
||||||
gtk_entry_get_text (self->display_name),
|
gtk_entry_get_text (self->display_name),
|
||||||
get_selected_protocol (self),
|
get_selected_protocol (self),
|
||||||
get_port (self),
|
get_port (self),
|
||||||
|
get_selected_media_encryption (self),
|
||||||
gtk_switch_get_state (self->tel_switch),
|
gtk_switch_get_state (self->tel_switch),
|
||||||
gtk_switch_get_state (self->auto_connect_switch));
|
gtk_switch_get_state (self->auto_connect_switch));
|
||||||
|
|
||||||
|
|
|
@ -1671,15 +1671,16 @@ calls_sip_origin_init (CallsSipOrigin *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
calls_sip_origin_set_credentials (CallsSipOrigin *self,
|
calls_sip_origin_set_credentials (CallsSipOrigin *self,
|
||||||
const char *host,
|
const char *host,
|
||||||
const char *user,
|
const char *user,
|
||||||
const char *password,
|
const char *password,
|
||||||
const char *display_name,
|
const char *display_name,
|
||||||
const char *transport_protocol,
|
const char *transport_protocol,
|
||||||
gint port,
|
gint port,
|
||||||
gboolean can_tel,
|
SipMediaEncryption media_encryption,
|
||||||
gboolean auto_connect)
|
gboolean can_tel,
|
||||||
|
gboolean auto_connect)
|
||||||
{
|
{
|
||||||
g_return_if_fail (CALLS_IS_SIP_ORIGIN (self));
|
g_return_if_fail (CALLS_IS_SIP_ORIGIN (self));
|
||||||
|
|
||||||
|
@ -1715,8 +1716,8 @@ calls_sip_origin_set_credentials (CallsSipOrigin *self,
|
||||||
self->transport_protocol = g_strdup ("UDP");
|
self->transport_protocol = g_strdup ("UDP");
|
||||||
|
|
||||||
self->port = port;
|
self->port = port;
|
||||||
|
|
||||||
self->can_tel = can_tel;
|
self->can_tel = can_tel;
|
||||||
|
self->media_encryption = media_encryption;
|
||||||
|
|
||||||
update_name (self);
|
update_name (self);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "calls-sip-util.h"
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -32,14 +34,15 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (CallsSipOrigin, calls_sip_origin, CALLS, SIP_ORIGIN, GObject)
|
G_DECLARE_FINAL_TYPE (CallsSipOrigin, calls_sip_origin, CALLS, SIP_ORIGIN, GObject)
|
||||||
|
|
||||||
void calls_sip_origin_set_credentials (CallsSipOrigin *self,
|
void calls_sip_origin_set_credentials (CallsSipOrigin *self,
|
||||||
const char *host,
|
const char *host,
|
||||||
const char *user,
|
const char *user,
|
||||||
const char *password,
|
const char *password,
|
||||||
const char *display_name,
|
const char *display_name,
|
||||||
const char *transport_protocol,
|
const char *transport_protocol,
|
||||||
gint port,
|
gint port,
|
||||||
gboolean use_for_tel,
|
SipMediaEncryption media_encryption,
|
||||||
gboolean auto_connect);
|
gboolean use_for_tel,
|
||||||
|
gboolean auto_connect);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -128,6 +128,7 @@ on_origin_pw_looked_up (GObject *source,
|
||||||
gboolean auto_connect = TRUE;
|
gboolean auto_connect = TRUE;
|
||||||
gboolean direct_mode = FALSE;
|
gboolean direct_mode = FALSE;
|
||||||
gboolean can_tel = FALSE;
|
gboolean can_tel = FALSE;
|
||||||
|
SipMediaEncryption media_encryption = SIP_MEDIA_ENCRYPTION_NONE;
|
||||||
|
|
||||||
g_assert (user_data);
|
g_assert (user_data);
|
||||||
|
|
||||||
|
@ -159,6 +160,10 @@ on_origin_pw_looked_up (GObject *source,
|
||||||
can_tel =
|
can_tel =
|
||||||
g_key_file_get_boolean (data->key_file, data->name, "CanTel", NULL);
|
g_key_file_get_boolean (data->key_file, data->name, "CanTel", NULL);
|
||||||
|
|
||||||
|
if (g_key_file_has_key (data->key_file, data->name, "MediaEncryption", NULL))
|
||||||
|
media_encryption =
|
||||||
|
(SipMediaEncryption) g_key_file_get_integer (data->key_file, data->name, "MediaEncryption", NULL);
|
||||||
|
|
||||||
/* PW */
|
/* PW */
|
||||||
password = secret_password_lookup_finish (result, &error);
|
password = secret_password_lookup_finish (result, &error);
|
||||||
if (!direct_mode && error) {
|
if (!direct_mode && error) {
|
||||||
|
@ -185,6 +190,7 @@ on_origin_pw_looked_up (GObject *source,
|
||||||
display_name,
|
display_name,
|
||||||
protocol,
|
protocol,
|
||||||
port,
|
port,
|
||||||
|
media_encryption,
|
||||||
auto_connect,
|
auto_connect,
|
||||||
direct_mode,
|
direct_mode,
|
||||||
local_port,
|
local_port,
|
||||||
|
@ -292,6 +298,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
|
||||||
gboolean auto_connect;
|
gboolean auto_connect;
|
||||||
gboolean direct_mode;
|
gboolean direct_mode;
|
||||||
gboolean can_tel;
|
gboolean can_tel;
|
||||||
|
SipMediaEncryption media_encryption;
|
||||||
|
|
||||||
g_assert (CALLS_IS_SIP_ORIGIN (origin));
|
g_assert (CALLS_IS_SIP_ORIGIN (origin));
|
||||||
g_assert (key_file);
|
g_assert (key_file);
|
||||||
|
@ -308,6 +315,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
|
||||||
"direct-mode", &direct_mode,
|
"direct-mode", &direct_mode,
|
||||||
"local-port", &local_port,
|
"local-port", &local_port,
|
||||||
"can-tel", &can_tel,
|
"can-tel", &can_tel,
|
||||||
|
"media-encryption", &media_encryption,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_key_file_set_string (key_file, name, "Id", id);
|
g_key_file_set_string (key_file, name, "Id", id);
|
||||||
|
@ -320,6 +328,7 @@ origin_to_keyfile (CallsSipOrigin *origin,
|
||||||
g_key_file_set_boolean (key_file, name, "DirectMode", direct_mode);
|
g_key_file_set_boolean (key_file, name, "DirectMode", direct_mode);
|
||||||
g_key_file_set_integer (key_file, name, "LocalPort", local_port);
|
g_key_file_set_integer (key_file, name, "LocalPort", local_port);
|
||||||
g_key_file_set_boolean (key_file, name, "CanTel", can_tel);
|
g_key_file_set_boolean (key_file, name, "CanTel", can_tel);
|
||||||
|
g_key_file_set_integer (key_file, name, "MediaEncryption", media_encryption);
|
||||||
|
|
||||||
label_secret = g_strdup_printf ("Calls Password for %s", id);
|
label_secret = g_strdup_printf ("Calls Password for %s", id);
|
||||||
|
|
||||||
|
@ -648,6 +657,8 @@ calls_sip_provider_init (CallsSipProvider *self)
|
||||||
* @password: The password to use
|
* @password: The password to use
|
||||||
* @display_name: The display name
|
* @display_name: The display name
|
||||||
* @transport_protocol: The transport protocol to use, can be one of "UDP", "TCP" or "TLS"
|
* @transport_protocol: The transport protocol to use, can be one of "UDP", "TCP" or "TLS"
|
||||||
|
* @port: The port of the host
|
||||||
|
* @media_encryption: A #SipMediaEncryption specifying if media should be encrypted
|
||||||
* @store_credentials: Whether to store credentials for this origin to disk
|
* @store_credentials: Whether to store credentials for this origin to disk
|
||||||
*
|
*
|
||||||
* Adds a new origin (SIP account)
|
* Adds a new origin (SIP account)
|
||||||
|
@ -655,15 +666,16 @@ calls_sip_provider_init (CallsSipProvider *self)
|
||||||
* Return: (transfer none): A #CallsSipOrigin
|
* Return: (transfer none): A #CallsSipOrigin
|
||||||
*/
|
*/
|
||||||
CallsSipOrigin *
|
CallsSipOrigin *
|
||||||
calls_sip_provider_add_origin (CallsSipProvider *self,
|
calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||||
const char *id,
|
const char *id,
|
||||||
const char *host,
|
const char *host,
|
||||||
const char *user,
|
const char *user,
|
||||||
const char *password,
|
const char *password,
|
||||||
const char *display_name,
|
const char *display_name,
|
||||||
const char *transport_protocol,
|
const char *transport_protocol,
|
||||||
gint port,
|
gint port,
|
||||||
gboolean store_credentials)
|
SipMediaEncryption media_encryption,
|
||||||
|
gboolean store_credentials)
|
||||||
{
|
{
|
||||||
return calls_sip_provider_add_origin_full (self,
|
return calls_sip_provider_add_origin_full (self,
|
||||||
id,
|
id,
|
||||||
|
@ -673,6 +685,7 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||||
display_name,
|
display_name,
|
||||||
transport_protocol,
|
transport_protocol,
|
||||||
port,
|
port,
|
||||||
|
media_encryption,
|
||||||
TRUE,
|
TRUE,
|
||||||
FALSE,
|
FALSE,
|
||||||
0,
|
0,
|
||||||
|
@ -689,6 +702,8 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||||
* @password: The password to use
|
* @password: The password to use
|
||||||
* @display_name: The display name
|
* @display_name: The display name
|
||||||
* @transport_protocol: The transport protocol to use, can be one of "UDP", "TCP" or "TLS"
|
* @transport_protocol: The transport protocol to use, can be one of "UDP", "TCP" or "TLS"
|
||||||
|
* @port: The port of the host
|
||||||
|
* @media_encryption: A #SipMediaEncryption specifying if media should be encrypted
|
||||||
* @auto_connect: Whether to automatically try going online
|
* @auto_connect: Whether to automatically try going online
|
||||||
* @direct_mode: Whether to use direct connection mode. Useful when you don't want to
|
* @direct_mode: Whether to use direct connection mode. Useful when you don't want to
|
||||||
* connect to a SIP server. Mostly useful for testing and debugging.
|
* connect to a SIP server. Mostly useful for testing and debugging.
|
||||||
|
@ -701,19 +716,20 @@ calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||||
* Return: (transfer none): A #CallsSipOrigin
|
* Return: (transfer none): A #CallsSipOrigin
|
||||||
*/
|
*/
|
||||||
CallsSipOrigin *
|
CallsSipOrigin *
|
||||||
calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
||||||
const char *id,
|
const char *id,
|
||||||
const char *host,
|
const char *host,
|
||||||
const char *user,
|
const char *user,
|
||||||
const char *password,
|
const char *password,
|
||||||
const char *display_name,
|
const char *display_name,
|
||||||
const char *transport_protocol,
|
const char *transport_protocol,
|
||||||
gint port,
|
gint port,
|
||||||
gboolean auto_connect,
|
SipMediaEncryption media_encryption,
|
||||||
gboolean direct_mode,
|
gboolean auto_connect,
|
||||||
gint local_port,
|
gboolean direct_mode,
|
||||||
gboolean can_tel,
|
gint local_port,
|
||||||
gboolean store_credentials)
|
gboolean can_tel,
|
||||||
|
gboolean store_credentials)
|
||||||
{
|
{
|
||||||
g_autoptr (CallsSipOrigin) origin = NULL;
|
g_autoptr (CallsSipOrigin) origin = NULL;
|
||||||
g_autofree char *protocol = NULL;
|
g_autofree char *protocol = NULL;
|
||||||
|
@ -743,6 +759,7 @@ calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
||||||
"display-name", display_name,
|
"display-name", display_name,
|
||||||
"transport-protocol", protocol ?: "UDP",
|
"transport-protocol", protocol ?: "UDP",
|
||||||
"port", port,
|
"port", port,
|
||||||
|
"media-encryption", media_encryption,
|
||||||
"auto-connect", auto_connect,
|
"auto-connect", auto_connect,
|
||||||
"direct-mode", direct_mode,
|
"direct-mode", direct_mode,
|
||||||
"local-port", local_port,
|
"local-port", local_port,
|
||||||
|
|
|
@ -37,28 +37,30 @@ G_BEGIN_DECLS
|
||||||
G_DECLARE_FINAL_TYPE (CallsSipProvider, calls_sip_provider, CALLS, SIP_PROVIDER, CallsProvider);
|
G_DECLARE_FINAL_TYPE (CallsSipProvider, calls_sip_provider, CALLS, SIP_PROVIDER, CallsProvider);
|
||||||
|
|
||||||
CallsSipProvider *calls_sip_provider_new (void);
|
CallsSipProvider *calls_sip_provider_new (void);
|
||||||
CallsSipOrigin *calls_sip_provider_add_origin (CallsSipProvider *self,
|
CallsSipOrigin *calls_sip_provider_add_origin (CallsSipProvider *self,
|
||||||
const char *id,
|
const char *id,
|
||||||
const char *host,
|
const char *host,
|
||||||
const char *user,
|
const char *user,
|
||||||
const char *password,
|
const char *password,
|
||||||
const char *display_name,
|
const char *display_name,
|
||||||
const char *transport_protocol,
|
const char *transport_protocol,
|
||||||
gint port,
|
gint port,
|
||||||
gboolean store_credentials);
|
SipMediaEncryption media_encryption,
|
||||||
CallsSipOrigin *calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
gboolean store_credentials);
|
||||||
const char *id,
|
CallsSipOrigin *calls_sip_provider_add_origin_full (CallsSipProvider *self,
|
||||||
const char *host,
|
const char *id,
|
||||||
const char *user,
|
const char *host,
|
||||||
const char *password,
|
const char *user,
|
||||||
const char *display_name,
|
const char *password,
|
||||||
const char *transport_protocol,
|
const char *display_name,
|
||||||
gint port,
|
const char *transport_protocol,
|
||||||
gboolean auto_connect,
|
gint port,
|
||||||
gboolean direct_mode,
|
SipMediaEncryption media_encryption,
|
||||||
gint local_port,
|
gboolean auto_connect,
|
||||||
gboolean use_for_tel,
|
gboolean direct_mode,
|
||||||
gboolean store_credentials);
|
gint local_port,
|
||||||
|
gboolean use_for_tel,
|
||||||
|
gboolean store_credentials);
|
||||||
gboolean calls_sip_provider_remove_origin (CallsSipProvider *self,
|
gboolean calls_sip_provider_remove_origin (CallsSipProvider *self,
|
||||||
CallsSipOrigin *origin);
|
CallsSipOrigin *origin);
|
||||||
void calls_sip_provider_load_accounts (CallsSipProvider *self,
|
void calls_sip_provider_load_accounts (CallsSipProvider *self,
|
||||||
|
|
|
@ -371,6 +371,7 @@ setup_sip_origins (SipFixture *fixture,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
|
SIP_MEDIA_ENCRYPTION_NONE,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
5060,
|
5060,
|
||||||
|
@ -386,6 +387,7 @@ setup_sip_origins (SipFixture *fixture,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
|
SIP_MEDIA_ENCRYPTION_NONE,
|
||||||
FALSE,
|
FALSE,
|
||||||
TRUE,
|
TRUE,
|
||||||
5061,
|
5061,
|
||||||
|
@ -401,6 +403,7 @@ setup_sip_origins (SipFixture *fixture,
|
||||||
NULL,
|
NULL,
|
||||||
"UDP",
|
"UDP",
|
||||||
0,
|
0,
|
||||||
|
SIP_MEDIA_ENCRYPTION_NONE,
|
||||||
FALSE,
|
FALSE,
|
||||||
FALSE,
|
FALSE,
|
||||||
0,
|
0,
|
||||||
|
|
Loading…
Reference in a new issue