1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
4 * This file is part of tlm (Tiny Login Manager)
6 * Copyright (C) 2013 Intel Corporation.
8 * Contact: Amarnath Valluri <amarnath.valluri@linux.intel.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 #include "tlm-account-plugin.h"
29 * SECTION:tlm-account-plugin
30 * @short_description: an interface for implementing tlm account plugins
31 * @include: tlm-account-plugin.h
33 * #TlmAccountPlugin is an interface for implementing tlm account plugins.
35 * <refsect1><title>The plugin API</title></refsect1>
37 * Tlm account plugins provide an API for system-specific account operations:
38 * setting up and cleaning up guest user account, and checking username validity.
39 * They should implement the plugin interface specified here.
41 * <refsect1><title>Example plugins</title></refsect1>
43 * See example plugin implementation here:
44 * <ulink url="https://github.com/01org/tlm/tree/master/src/plugins/default">
45 * https://github.com/01org/tlm/tree/master/src/plugins/default</ulink> and here:
46 * <ulink url="https://github.com/01org/tlm/tree/master/src/plugins/gumd">
47 * https://github.com/01org/tlm/tree/master/src/plugins/gumd</ulink>.
53 * TlmAccountPluginInterface:
54 * @parent: parent interface type.
55 * @setup_guest_user_account: implementation of tlm_account_plugin_setup_guest_user_account()
56 * @is_valid_user: implementation of tlm_account_plugin_is_valid_user()
57 * @cleanup_guest_user: implementation of tlm_account_plugin_cleanup_guest_user()
59 * #TlmAccountPluginInterface interface containing pointers to methods that all
60 * plugin implementations should provide.
66 * Opaque #TlmAccountPlugin data structure.
68 G_DEFINE_INTERFACE (TlmAccountPlugin, tlm_account_plugin, 0)
71 tlm_account_plugin_default_init (TlmAccountPluginInterface *g_class)
74 * TlmAccountPlugin:config:
76 * This property holds a list of key-value pairs of plugin configuration
77 * taken from tlm.conf configuration file.
79 g_object_interface_install_property (g_class, g_param_spec_boxed (
80 "config", "Config", "Config parameters",
81 G_TYPE_HASH_TABLE, G_PARAM_CONSTRUCT_ONLY
82 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
86 * tlm_account_plugin_setup_guest_user_account
87 * @self: plugin instance
88 * @user_name: the user name
90 * This method creates and sets up a guest user account with a provided
93 * Returns: whether the operation succeeded.
96 tlm_account_plugin_setup_guest_user_account (TlmAccountPlugin *self,
97 const gchar *user_name)
99 g_return_val_if_fail(self && TLM_IS_PLUGIN (self), FALSE);
100 g_return_val_if_fail(
101 TLM_ACCOUNT_PLUGIN_GET_IFACE(self)->setup_guest_user_account, FALSE);
103 return TLM_ACCOUNT_PLUGIN_GET_IFACE (self)->setup_guest_user_account (
109 * tlm_account_plugin_is_valid_user:
110 * @self: plugin instance
111 * @user_name: user name to check
113 * Checks if the user with a given @user_name exists.
116 tlm_account_plugin_is_valid_user (TlmAccountPlugin *self,
117 const gchar *user_name)
119 g_return_val_if_fail (self && TLM_IS_PLUGIN (self), FALSE);
120 g_return_val_if_fail (TLM_ACCOUNT_PLUGIN_GET_IFACE(self)->is_valid_user,
123 return TLM_ACCOUNT_PLUGIN_GET_IFACE(self)->is_valid_user (self, user_name);
127 * tlm_account_plugin_cleanup_guest_user:
128 * @self: plugin instance
129 * @user_name: user name to clean up
130 * @delete_account: whether the user account should be deleted
132 * When a guest user logs out, this method is called. It should clean up the
133 * home directory of the user, and, if delete_user is set, delete the user
137 tlm_account_plugin_cleanup_guest_user (TlmAccountPlugin *self,
138 const gchar *user_name,
139 gboolean delete_account)
141 g_return_val_if_fail(self && TLM_IS_PLUGIN (self), FALSE);
142 g_return_val_if_fail(TLM_ACCOUNT_PLUGIN_GET_IFACE(self)->cleanup_guest_user,
145 return TLM_ACCOUNT_PLUGIN_GET_IFACE (self)->cleanup_guest_user (
146 self, user_name, delete_account);