mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-05 19:15:32 +00:00
manager: Differentiate the NO_ORIGIN state
This avoids confusion when only the SIP plugin is loaded, but no account is being used. For this we introduce two new functions in the abstract CallsProvider class: `is_modem()` to indicate whether the the provider deals with PTSN telephony and `is_operational()` which by default simply checks if there any avalaible origins
This commit is contained in:
parent
98d66743a1
commit
44f2002f86
7 changed files with 90 additions and 5 deletions
|
@ -365,6 +365,12 @@ calls_mm_provider_get_protocols (CallsProvider *provider)
|
|||
return supported_protocols;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_mm_provider_is_modem (CallsProvider *provider)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
|
@ -427,6 +433,7 @@ calls_mm_provider_class_init (CallsMMProviderClass *klass)
|
|||
provider_class->get_status = calls_mm_provider_get_status;
|
||||
provider_class->get_origins = calls_mm_provider_get_origins;
|
||||
provider_class->get_protocols = calls_mm_provider_get_protocols;
|
||||
provider_class->is_modem = calls_mm_provider_is_modem;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -306,6 +306,12 @@ calls_ofono_provider_get_protocols (CallsProvider *provider)
|
|||
return supported_protocols;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_ofono_provider_is_modem (CallsProvider *provider)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
modem_added_cb (GDBOManager *manager,
|
||||
const gchar *path,
|
||||
|
@ -535,6 +541,7 @@ calls_ofono_provider_class_init (CallsOfonoProviderClass *klass)
|
|||
provider_class->get_status = calls_ofono_provider_get_status;
|
||||
provider_class->get_origins = calls_ofono_provider_get_origins;
|
||||
provider_class->get_protocols = calls_ofono_provider_get_protocols;
|
||||
provider_class->is_modem = calls_ofono_provider_is_modem;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -315,10 +315,14 @@ state_changed_cb (CallsMainWindow *self,
|
|||
case CALLS_MANAGER_STATE_READY:
|
||||
break;
|
||||
|
||||
case CALLS_MANAGER_STATE_NO_ORIGIN:
|
||||
case CALLS_MANAGER_STATE_NO_VOICE_MODEM:
|
||||
error = _("Can't place calls: No voice-capable modem available");
|
||||
break;
|
||||
|
||||
case CALLS_MANAGER_STATE_NO_ORIGIN:
|
||||
error = _("Can't place calls: No modem or VoIP account available");
|
||||
break;
|
||||
|
||||
case CALLS_MANAGER_STATE_UNKNOWN:
|
||||
case CALLS_MANAGER_STATE_NO_PROVIDER:
|
||||
error = _("Can't place calls: No backend service");
|
||||
|
|
|
@ -92,6 +92,10 @@ static void
|
|||
update_state (CallsManager *self)
|
||||
{
|
||||
guint n_items;
|
||||
GHashTableIter iter;
|
||||
gpointer key;
|
||||
gpointer value;
|
||||
|
||||
g_assert (CALLS_IS_MANAGER (self));
|
||||
|
||||
if (g_hash_table_size (self->providers) == 0) {
|
||||
|
@ -99,9 +103,15 @@ update_state (CallsManager *self)
|
|||
return;
|
||||
}
|
||||
|
||||
if (g_hash_table_contains (self->providers, "dummy")) {
|
||||
set_state (self, CALLS_MANAGER_STATE_READY);
|
||||
return;
|
||||
g_hash_table_iter_init (&iter, self->providers);
|
||||
|
||||
while (g_hash_table_iter_next (&iter, &key, &value)) {
|
||||
CallsProvider *provider = CALLS_PROVIDER (value);
|
||||
|
||||
if (calls_provider_is_modem (provider) && !calls_provider_is_operational (provider)) {
|
||||
set_state (self, CALLS_MANAGER_STATE_NO_VOICE_MODEM);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
n_items = g_list_model_get_n_items (G_LIST_MODEL (self->origins));
|
||||
|
|
|
@ -42,6 +42,7 @@ typedef enum
|
|||
CALLS_MANAGER_STATE_NO_PLUGIN,
|
||||
CALLS_MANAGER_STATE_NO_PROVIDER,
|
||||
CALLS_MANAGER_STATE_NO_ORIGIN,
|
||||
CALLS_MANAGER_STATE_NO_VOICE_MODEM,
|
||||
CALLS_MANAGER_STATE_READY,
|
||||
} CallsManagerState;
|
||||
|
||||
|
|
|
@ -78,6 +78,25 @@ calls_provider_real_get_protocols (CallsProvider *self)
|
|||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_provider_real_is_modem (CallsProvider *self)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
calls_provider_real_is_operational (CallsProvider *self)
|
||||
{
|
||||
GListModel *origins;
|
||||
|
||||
origins = calls_provider_get_origins (self);
|
||||
|
||||
if (origins)
|
||||
return !!g_list_model_get_n_items (origins);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
calls_provider_get_property (GObject *object,
|
||||
|
@ -108,6 +127,8 @@ calls_provider_class_init (CallsProviderClass *klass)
|
|||
klass->get_status = calls_provider_real_get_status;
|
||||
klass->get_origins = calls_provider_real_get_origins;
|
||||
klass->get_protocols = calls_provider_real_get_protocols;
|
||||
klass->is_modem = calls_provider_real_is_modem;
|
||||
klass->is_operational = calls_provider_real_is_operational;
|
||||
|
||||
props[PROP_STATUS] =
|
||||
g_param_spec_string ("status",
|
||||
|
@ -244,3 +265,34 @@ calls_provider_get_protocols (CallsProvider *self)
|
|||
|
||||
return CALLS_PROVIDER_GET_CLASS (self)->get_protocols (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_provider_is_modem:
|
||||
* @self: A #CallsProvider
|
||||
*
|
||||
* Returns: %TRUE is this provider handles modems, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
calls_provider_is_modem (CallsProvider *self)
|
||||
{
|
||||
g_return_val_if_fail (CALLS_IS_PROVIDER (self), FALSE);
|
||||
|
||||
return CALLS_PROVIDER_GET_CLASS (self)->is_modem (self);
|
||||
}
|
||||
|
||||
/**
|
||||
* calls_provider_is_operational:
|
||||
* @self: A #CallsProvider
|
||||
*
|
||||
* Returns: %TRUE is this provider is operational, %FALSE otherwise
|
||||
*
|
||||
* If not subclassed this method will simply test if there are any
|
||||
* origins available.
|
||||
*/
|
||||
gboolean
|
||||
calls_provider_is_operational (CallsProvider *self)
|
||||
{
|
||||
g_return_val_if_fail (CALLS_IS_PROVIDER (self), FALSE);
|
||||
|
||||
return CALLS_PROVIDER_GET_CLASS (self)->is_operational (self);
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ struct _CallsProviderClass
|
|||
const char *(*get_status) (CallsProvider *self);
|
||||
GListModel *(*get_origins) (CallsProvider *self);
|
||||
const char * const *(*get_protocols) (CallsProvider *self);
|
||||
gboolean (*is_modem) (CallsProvider *self);
|
||||
gboolean (*is_operational) (CallsProvider *self);
|
||||
};
|
||||
|
||||
const char *calls_provider_get_name (CallsProvider *self);
|
||||
|
@ -55,7 +57,9 @@ const char *calls_provider_get_status (CallsProvider *self);
|
|||
GListModel *calls_provider_get_origins (CallsProvider *self);
|
||||
CallsProvider *calls_provider_load_plugin (const char *name);
|
||||
void calls_provider_unload_plugin (const char *name);
|
||||
const char * const *calls_provider_get_protocols (CallsProvider *self);
|
||||
const char * const *calls_provider_get_protocols (CallsProvider *self);
|
||||
gboolean calls_provider_is_modem (CallsProvider *self);
|
||||
gboolean calls_provider_is_operational (CallsProvider *self);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
Loading…
Reference in a new issue