mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-06 11:35:32 +00:00
sip: origin: Use CallsAccountState instead of SipAccountState
This commit is contained in:
parent
0e5bd82568
commit
781adaddee
4 changed files with 31 additions and 43 deletions
|
@ -25,6 +25,7 @@
|
|||
#define G_LOG_DOMAIN "CallsSipOrigin"
|
||||
|
||||
|
||||
#include "calls-account.h"
|
||||
#include "calls-credentials.h"
|
||||
#include "calls-message-source.h"
|
||||
#include "calls-origin.h"
|
||||
|
@ -34,6 +35,7 @@
|
|||
#include "calls-sip-util.h"
|
||||
#include "calls-sip-media-manager.h"
|
||||
#include "config.h"
|
||||
#include "enum-types.h"
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <glib-object.h>
|
||||
|
@ -82,7 +84,7 @@ struct _CallsSipOrigin
|
|||
/* Needed to handle shutdown correctly. See sip_callback and dispose method */
|
||||
gboolean is_nua_shutdown;
|
||||
|
||||
SipAccountState state;
|
||||
CallsAccountState state;
|
||||
|
||||
CallsSipMediaManager *media_manager;
|
||||
|
||||
|
@ -446,20 +448,20 @@ sip_r_register (int status,
|
|||
if (status == 200) {
|
||||
g_debug ("REGISTER successful");
|
||||
|
||||
origin->state = SIP_ACCOUNT_ONLINE;
|
||||
origin->state = CALLS_ACCOUNT_ONLINE;
|
||||
}
|
||||
else if (status == 401 || status == 407) {
|
||||
sip_authenticate (origin, nh, sip);
|
||||
|
||||
origin->state = SIP_ACCOUNT_AUTHENTICATING;
|
||||
origin->state = CALLS_ACCOUNT_AUTHENTICATING;
|
||||
}
|
||||
else if (status == 403) {
|
||||
g_warning ("wrong credentials?");
|
||||
origin->state = SIP_ACCOUNT_ERROR_RETRY;
|
||||
origin->state = CALLS_ACCOUNT_AUTHENTICATION_FAILURE;
|
||||
}
|
||||
else if (status == 904) {
|
||||
g_warning ("unmatched challenge");
|
||||
origin->state = SIP_ACCOUNT_ERROR_RETRY;
|
||||
origin->state = CALLS_ACCOUNT_AUTHENTICATION_FAILURE;
|
||||
}
|
||||
g_object_notify_by_pspec (G_OBJECT (origin), props[PROP_ACC_STATE]);
|
||||
}
|
||||
|
@ -882,7 +884,6 @@ static gboolean
|
|||
init_sip_account (CallsSipOrigin *self,
|
||||
GError **error)
|
||||
{
|
||||
gboolean recoverable = FALSE;
|
||||
gboolean auto_connect = FALSE;
|
||||
|
||||
if (self->use_direct_connection) {
|
||||
|
@ -895,7 +896,8 @@ init_sip_account (CallsSipOrigin *self,
|
|||
"Must have completed account setup before calling"
|
||||
"init_sip_account ()"
|
||||
"Try again when account is setup");
|
||||
recoverable = TRUE;
|
||||
|
||||
self->state = CALLS_ACCOUNT_NO_CREDENTIALS;
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -904,6 +906,8 @@ init_sip_account (CallsSipOrigin *self,
|
|||
if (self->nua == NULL) {
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Failed setting up nua context");
|
||||
|
||||
self->state = CALLS_ACCOUNT_NULL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -911,14 +915,16 @@ init_sip_account (CallsSipOrigin *self,
|
|||
if (self->oper == NULL) {
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Failed setting operation handles");
|
||||
|
||||
self->state = CALLS_ACCOUNT_NULL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* In the case of a direct connection we're immediately good to go */
|
||||
if (self->use_direct_connection)
|
||||
self->state = SIP_ACCOUNT_ONLINE;
|
||||
self->state = CALLS_ACCOUNT_ONLINE;
|
||||
else {
|
||||
self->state = SIP_ACCOUNT_OFFLINE;
|
||||
self->state = CALLS_ACCOUNT_OFFLINE;
|
||||
|
||||
g_object_get (self->credentials, "auto-connect", &auto_connect, NULL);
|
||||
/* try to go online */
|
||||
|
@ -930,7 +936,6 @@ init_sip_account (CallsSipOrigin *self,
|
|||
return TRUE;
|
||||
|
||||
err:
|
||||
self->state = recoverable ? SIP_ACCOUNT_ERROR_RETRY : SIP_ACCOUNT_ERROR;
|
||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_ACC_STATE]);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1041,7 +1046,7 @@ calls_sip_origin_dispose (GObject *object)
|
|||
{
|
||||
CallsSipOrigin *self = CALLS_SIP_ORIGIN (object);
|
||||
|
||||
if (self->state == SIP_ACCOUNT_NULL)
|
||||
if (self->state == CALLS_ACCOUNT_NULL)
|
||||
return;
|
||||
|
||||
remove_calls (self, NULL);
|
||||
|
@ -1050,7 +1055,7 @@ calls_sip_origin_dispose (GObject *object)
|
|||
g_clear_pointer (&self->oper->call_handle, nua_handle_unref);
|
||||
g_clear_pointer (&self->oper->register_handle, nua_handle_unref);
|
||||
|
||||
if (!self->use_direct_connection && self->state == SIP_ACCOUNT_OFFLINE)
|
||||
if (!self->use_direct_connection && self->state == CALLS_ACCOUNT_OFFLINE)
|
||||
calls_sip_origin_go_online (self, FALSE);
|
||||
}
|
||||
|
||||
|
@ -1066,7 +1071,7 @@ calls_sip_origin_dispose (GObject *object)
|
|||
self->nua = NULL;
|
||||
}
|
||||
|
||||
self->state = SIP_ACCOUNT_NULL;
|
||||
self->state = CALLS_ACCOUNT_NULL;
|
||||
|
||||
G_OBJECT_CLASS (calls_sip_origin_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -1130,8 +1135,8 @@ calls_sip_origin_class_init (CallsSipOriginClass *klass)
|
|||
g_param_spec_enum ("account-state",
|
||||
"Account state",
|
||||
"The state of the SIP account",
|
||||
SIP_TYPE_ACCOUNT_STATE,
|
||||
SIP_ACCOUNT_NULL,
|
||||
CALLS_TYPE_ACCOUNT_STATE,
|
||||
CALLS_ACCOUNT_NULL,
|
||||
G_PARAM_READWRITE);
|
||||
g_object_class_install_property (object_class, PROP_ACC_STATE, props[PROP_ACC_STATE]);
|
||||
|
||||
|
@ -1200,7 +1205,7 @@ calls_sip_origin_go_online (CallsSipOrigin *self,
|
|||
g_autofree char *display_name = NULL;
|
||||
g_autofree char *registrar_url = NULL;
|
||||
|
||||
if (self->state == SIP_ACCOUNT_ONLINE)
|
||||
if (self->state == CALLS_ACCOUNT_ONLINE)
|
||||
return;
|
||||
|
||||
g_object_get (self->credentials,
|
||||
|
@ -1217,7 +1222,7 @@ calls_sip_origin_go_online (CallsSipOrigin *self,
|
|||
TAG_END ());
|
||||
}
|
||||
else {
|
||||
if (self->state == SIP_ACCOUNT_OFFLINE)
|
||||
if (self->state == CALLS_ACCOUNT_OFFLINE)
|
||||
return;
|
||||
|
||||
nua_unregister (self->oper->register_handle,
|
||||
|
|
|
@ -57,27 +57,6 @@ typedef enum
|
|||
SIP_ENGINE_READY,
|
||||
} SipEngineState;
|
||||
|
||||
/**
|
||||
* SipAccountState:
|
||||
* @SIP_ACCOUNT_NULL: Not initialized
|
||||
* @SIP_ACCOUNT_OFFLINE: Account considered offline (not ready for placing or receiving calls)
|
||||
* @SIP_ACCOUNT_REGISTERING: REGISTER sent
|
||||
* @SIP_ACCOUNT_AUTHENTICATING: Authenticating using web-auth/proxy-auth
|
||||
* @SIP_ACCOUNT_ERROR: Unrecoverable error
|
||||
* @SIP_ACCOUNT_ERROR_RETRY: Recoverable error (f.e. using other credentials)
|
||||
* @SIP_ACCOUNT_ONLINE: Account considered online (can place and receive calls)
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SIP_ACCOUNT_NULL = 0,
|
||||
SIP_ACCOUNT_OFFLINE,
|
||||
SIP_ACCOUNT_REGISTERING,
|
||||
SIP_ACCOUNT_AUTHENTICATING,
|
||||
SIP_ACCOUNT_ERROR,
|
||||
SIP_ACCOUNT_ERROR_RETRY,
|
||||
SIP_ACCOUNT_ONLINE,
|
||||
} SipAccountState;
|
||||
|
||||
|
||||
gboolean check_sips (const gchar *addr);
|
||||
gboolean check_ipv6 (const gchar *host);
|
||||
|
|
|
@ -45,12 +45,13 @@ struct _CallsAccountInterface
|
|||
};
|
||||
/**
|
||||
* CallsAccountState:
|
||||
* @CALLS_ACCOUNT_NULL: Not initialized
|
||||
* @CALLS_ACCOUNT_NULL: Not initialized or error
|
||||
* @CALLS_ACCOUNT_OFFLINE: Account considered offline (not ready for placing or receiving calls)
|
||||
* @CALLS_ACCOUNT_CONNECTING: Trying to connect to server
|
||||
* @CALLS_ACCOUNT_CONNECTION_FAILURE: Could not connect to server (f.e. DNS error, unreachable)
|
||||
* @CALLS_ACCOUNT_AUTHENTICATING: Authenticating using web-auth/proxy-auth
|
||||
* @CALLS_ACCOUNT_AUTHENTICATION_FAILURE: Could not authenticate to server (f.e. wrong credentials)
|
||||
* @CALLS_ACCOUNT_NO_CREDENTIALS: Credentials are missing
|
||||
* @CALLS_ACCOUNT_ONLINE: Account considered online (can place and receive calls)
|
||||
*/
|
||||
typedef enum {
|
||||
|
@ -60,6 +61,8 @@ typedef enum {
|
|||
CALLS_ACCOUNT_CONNECTION_FAILURE,
|
||||
CALLS_ACCOUNT_AUTHENTICATING,
|
||||
CALLS_ACCOUNT_AUTHENTICATION_FAILURE,
|
||||
CALLS_ACCOUNT_NO_CREDENTIALS,
|
||||
CALLS_ACCOUNT_UNKNOWN_ERROR,
|
||||
CALLS_ACCOUNT_ONLINE
|
||||
} CallsAccountState;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "calls-sip-provider.h"
|
||||
#include "calls-sip-origin.h"
|
||||
#include "calls-sip-util.h"
|
||||
#include "calls-account.h"
|
||||
#include "gst-rfc3551.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
@ -84,7 +85,7 @@ static void
|
|||
test_sip_origin_objects (SipFixture *fixture,
|
||||
gconstpointer user_data)
|
||||
{
|
||||
SipAccountState state_alice, state_bob, state_offline;
|
||||
CallsAccountState state_alice, state_bob, state_offline;
|
||||
|
||||
g_assert_true (G_IS_OBJECT (fixture->origin_alice));
|
||||
g_assert_true (G_IS_OBJECT (fixture->origin_bob));
|
||||
|
@ -112,9 +113,9 @@ test_sip_origin_objects (SipFixture *fixture,
|
|||
"account-state", &state_offline,
|
||||
NULL);
|
||||
|
||||
g_assert_cmpint (state_alice, ==, SIP_ACCOUNT_ONLINE);
|
||||
g_assert_cmpint (state_bob, ==, SIP_ACCOUNT_ONLINE);
|
||||
g_assert_cmpint (state_offline, ==, SIP_ACCOUNT_OFFLINE);
|
||||
g_assert_cmpint (state_alice, ==, CALLS_ACCOUNT_ONLINE);
|
||||
g_assert_cmpint (state_bob, ==, CALLS_ACCOUNT_ONLINE);
|
||||
g_assert_cmpint (state_offline, ==, CALLS_ACCOUNT_OFFLINE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue