GMutex property_lock;
ESource *source;
EUserPrompter *prompter;
+ GMainContext *main_context;
GSocketConnectable *connectable;
gboolean online;
enum {
PROP_0,
PROP_CONNECTABLE,
+ PROP_MAIN_CONTEXT,
PROP_ONLINE,
PROP_SOURCE,
PROP_USER_PROMPTER
E_BACKEND (object)));
return;
+ case PROP_MAIN_CONTEXT:
+ g_value_take_boxed (
+ value, e_backend_ref_main_context (
+ E_BACKEND (object)));
+ return;
+
case PROP_ONLINE:
g_value_set_boolean (
value, e_backend_get_online (
priv->network_changed_timeout_id = 0;
}
+ if (priv->main_context != NULL) {
+ g_main_context_unref (priv->main_context);
+ priv->main_context = NULL;
+ }
+
g_clear_object (&priv->source);
g_clear_object (&priv->prompter);
g_clear_object (&priv->connectable);
g_object_class_install_property (
object_class,
+ PROP_MAIN_CONTEXT,
+ g_param_spec_boxed (
+ "main-context",
+ "Main Context",
+ "The main loop context on "
+ "which to attach event sources",
+ G_TYPE_MAIN_CONTEXT,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (
+ object_class,
PROP_ONLINE,
g_param_spec_boolean (
"online",
backend->priv = E_BACKEND_GET_PRIVATE (backend);
backend->priv->prompter = e_user_prompter_new ();
+ backend->priv->main_context = g_main_context_ref_thread_default ();
g_mutex_init (&backend->priv->property_lock);
g_mutex_init (&backend->priv->network_monitor_cancellable_lock);
}
/**
+ * e_backend_ref_main_context:
+ * @backend: an #EBackend
+ *
+ * Returns the #GMainContext on which event sources for @backend are to
+ * be attached.
+ *
+ * The returned #GMainContext is referenced for thread-safety and must be
+ * unreferenced with g_main_context_unref() when finished with it.
+ *
+ * Returns: (transfer full): a #GMainContext
+ *
+ * Since: 3.8
+ **/
+GMainContext *
+e_backend_ref_main_context (EBackend *backend)
+{
+ g_return_val_if_fail (E_IS_BACKEND (backend), NULL);
+
+ return g_main_context_ref (backend->priv->main_context);
+}
+
+/**
* e_backend_authenticate_sync:
* @backend: an #EBackend
* @auth: an #ESourceAuthenticator
e_backend_ref_connectable (EBackend *backend);
void e_backend_set_connectable (EBackend *backend,
GSocketConnectable *connectable);
+GMainContext * e_backend_ref_main_context (EBackend *backend);
gboolean e_backend_authenticate_sync (EBackend *backend,
ESourceAuthenticator *auth,
GCancellable *cancellable,