summaryrefslogtreecommitdiff
path: root/plugins/smartcard/gsd-smartcard.c
diff options
context:
space:
mode:
authorhaxar <[email protected]>2012-02-21 20:13:04 -0800
committerhaxar <[email protected]>2012-02-21 20:13:04 -0800
commitddaceb232c8b537a7d29a9708928d3a3671b98e5 (patch)
treed874e557f2999f9550ad2b710f0231ed06f50ba8 /plugins/smartcard/gsd-smartcard.c
parentecd8a153901507f5d210d6f85103693ef81d49c3 (diff)
downloadmate-settings-daemon-ddaceb232c8b537a7d29a9708928d3a3671b98e5.tar.bz2
mate-settings-daemon-ddaceb232c8b537a7d29a9708928d3a3671b98e5.tar.xz
gsd to msd complete rename patch by NiceandGently; code changes commit
Diffstat (limited to 'plugins/smartcard/gsd-smartcard.c')
-rw-r--r--plugins/smartcard/gsd-smartcard.c192
1 files changed, 96 insertions, 96 deletions
diff --git a/plugins/smartcard/gsd-smartcard.c b/plugins/smartcard/gsd-smartcard.c
index 22f4e12..9154200 100644
--- a/plugins/smartcard/gsd-smartcard.c
+++ b/plugins/smartcard/gsd-smartcard.c
@@ -1,4 +1,4 @@
-/* gsd-smartcard.c - smartcard object
+/* msd-smartcard.c - smartcard object
*
* Copyright (C) 2006 Ray Strode <[email protected]>
*
@@ -17,8 +17,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
-#define GSD_SMARTCARD_ENABLE_INTERNAL_API
-#include "gsd-smartcard.h"
+#define MSD_SMARTCARD_ENABLE_INTERNAL_API
+#include "msd-smartcard.h"
#include <errno.h>
#include <string.h>
@@ -34,9 +34,9 @@
#include <secmod.h>
#include <secerr.h>
-struct _GsdSmartcardPrivate {
+struct _MsdSmartcardPrivate {
SECMODModule *module;
- GsdSmartcardState state;
+ MsdSmartcardState state;
CK_SLOT_ID slot_id;
int slot_series;
@@ -48,36 +48,36 @@ struct _GsdSmartcardPrivate {
CERTCertificate *encryption_certificate;
};
-static void gsd_smartcard_finalize (GObject *object);
-static void gsd_smartcard_class_install_signals (GsdSmartcardClass *card_class);
-static void gsd_smartcard_class_install_properties (GsdSmartcardClass *card_class);
-static void gsd_smartcard_set_property (GObject *object,
+static void msd_smartcard_finalize (GObject *object);
+static void msd_smartcard_class_install_signals (MsdSmartcardClass *card_class);
+static void msd_smartcard_class_install_properties (MsdSmartcardClass *card_class);
+static void msd_smartcard_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
-static void gsd_smartcard_get_property (GObject *object,
+static void msd_smartcard_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
-static void gsd_smartcard_set_name (GsdSmartcard *card, const char *name);
-static void gsd_smartcard_set_slot_id (GsdSmartcard *card,
+static void msd_smartcard_set_name (MsdSmartcard *card, const char *name);
+static void msd_smartcard_set_slot_id (MsdSmartcard *card,
int slot_id);
-static void gsd_smartcard_set_slot_series (GsdSmartcard *card,
+static void msd_smartcard_set_slot_series (MsdSmartcard *card,
int slot_series);
-static void gsd_smartcard_set_module (GsdSmartcard *card,
+static void msd_smartcard_set_module (MsdSmartcard *card,
SECMODModule *module);
-static PK11SlotInfo *gsd_smartcard_find_slot_from_id (GsdSmartcard *card,
+static PK11SlotInfo *msd_smartcard_find_slot_from_id (MsdSmartcard *card,
int slot_id);
-static PK11SlotInfo *gsd_smartcard_find_slot_from_card_name (GsdSmartcard *card,
+static PK11SlotInfo *msd_smartcard_find_slot_from_card_name (MsdSmartcard *card,
const char *card_name);
-#ifndef GSD_SMARTCARD_DEFAULT_SLOT_ID
-#define GSD_SMARTCARD_DEFAULT_SLOT_ID ((gulong) -1)
+#ifndef MSD_SMARTCARD_DEFAULT_SLOT_ID
+#define MSD_SMARTCARD_DEFAULT_SLOT_ID ((gulong) -1)
#endif
-#ifndef GSD_SMARTCARD_DEFAULT_SLOT_SERIES
-#define GSD_SMARTCARD_DEFAULT_SLOT_SERIES -1
+#ifndef MSD_SMARTCARD_DEFAULT_SLOT_SERIES
+#define MSD_SMARTCARD_DEFAULT_SLOT_SERIES -1
#endif
enum {
@@ -95,73 +95,73 @@ enum {
NUMBER_OF_SIGNALS
};
-static guint gsd_smartcard_signals[NUMBER_OF_SIGNALS];
+static guint msd_smartcard_signals[NUMBER_OF_SIGNALS];
-G_DEFINE_TYPE (GsdSmartcard, gsd_smartcard, G_TYPE_OBJECT);
+G_DEFINE_TYPE (MsdSmartcard, msd_smartcard, G_TYPE_OBJECT);
static void
-gsd_smartcard_class_init (GsdSmartcardClass *card_class)
+msd_smartcard_class_init (MsdSmartcardClass *card_class)
{
GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (card_class);
- gobject_class->finalize = gsd_smartcard_finalize;
+ gobject_class->finalize = msd_smartcard_finalize;
- gsd_smartcard_class_install_signals (card_class);
- gsd_smartcard_class_install_properties (card_class);
+ msd_smartcard_class_install_signals (card_class);
+ msd_smartcard_class_install_properties (card_class);
g_type_class_add_private (card_class,
- sizeof (GsdSmartcardPrivate));
+ sizeof (MsdSmartcardPrivate));
}
static void
-gsd_smartcard_class_install_signals (GsdSmartcardClass *card_class)
+msd_smartcard_class_install_signals (MsdSmartcardClass *card_class)
{
GObjectClass *object_class;
object_class = G_OBJECT_CLASS (card_class);
- gsd_smartcard_signals[INSERTED] =
+ msd_smartcard_signals[INSERTED] =
g_signal_new ("inserted",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsdSmartcardClass,
+ G_STRUCT_OFFSET (MsdSmartcardClass,
inserted),
NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- gsd_smartcard_signals[REMOVED] =
+ msd_smartcard_signals[REMOVED] =
g_signal_new ("removed",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsdSmartcardClass,
+ G_STRUCT_OFFSET (MsdSmartcardClass,
removed),
NULL, NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
}
static void
-gsd_smartcard_class_install_properties (GsdSmartcardClass *card_class)
+msd_smartcard_class_install_properties (MsdSmartcardClass *card_class)
{
GObjectClass *object_class;
GParamSpec *param_spec;
object_class = G_OBJECT_CLASS (card_class);
- object_class->set_property = gsd_smartcard_set_property;
- object_class->get_property = gsd_smartcard_get_property;
+ object_class->set_property = msd_smartcard_set_property;
+ object_class->get_property = msd_smartcard_get_property;
param_spec = g_param_spec_ulong ("slot-id", _("Slot ID"),
_("The slot the card is in"),
1, G_MAXULONG,
- GSD_SMARTCARD_DEFAULT_SLOT_ID,
+ MSD_SMARTCARD_DEFAULT_SLOT_ID,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_SLOT_ID, param_spec);
param_spec = g_param_spec_int ("slot-series", _("Slot Series"),
_("per-slot card identifier"),
-1, G_MAXINT,
- GSD_SMARTCARD_DEFAULT_SLOT_SERIES,
+ MSD_SMARTCARD_DEFAULT_SLOT_SERIES,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_property (object_class, PROP_SLOT_SERIES, param_spec);
@@ -177,30 +177,30 @@ gsd_smartcard_class_install_properties (GsdSmartcardClass *card_class)
}
static void
-gsd_smartcard_set_property (GObject *object,
+msd_smartcard_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
- GsdSmartcard *card = GSD_SMARTCARD (object);
+ MsdSmartcard *card = MSD_SMARTCARD (object);
switch (prop_id) {
case PROP_NAME:
- gsd_smartcard_set_name (card, g_value_get_string (value));
+ msd_smartcard_set_name (card, g_value_get_string (value));
break;
case PROP_SLOT_ID:
- gsd_smartcard_set_slot_id (card,
+ msd_smartcard_set_slot_id (card,
g_value_get_ulong (value));
break;
case PROP_SLOT_SERIES:
- gsd_smartcard_set_slot_series (card,
+ msd_smartcard_set_slot_series (card,
g_value_get_int (value));
break;
case PROP_MODULE:
- gsd_smartcard_set_module (card,
+ msd_smartcard_set_module (card,
(SECMODModule *)
g_value_get_pointer (value));
break;
@@ -211,25 +211,25 @@ gsd_smartcard_set_property (GObject *object,
}
CK_SLOT_ID
-gsd_smartcard_get_slot_id (GsdSmartcard *card)
+msd_smartcard_get_slot_id (MsdSmartcard *card)
{
return card->priv->slot_id;
}
-GsdSmartcardState
-gsd_smartcard_get_state (GsdSmartcard *card)
+MsdSmartcardState
+msd_smartcard_get_state (MsdSmartcard *card)
{
return card->priv->state;
}
char *
-gsd_smartcard_get_name (GsdSmartcard *card)
+msd_smartcard_get_name (MsdSmartcard *card)
{
return g_strdup (card->priv->name);
}
gboolean
-gsd_smartcard_is_login_card (GsdSmartcard *card)
+msd_smartcard_is_login_card (MsdSmartcard *card)
{
const char *login_card_name;
login_card_name = g_getenv ("PKCS11_LOGIN_TOKEN_NAME");
@@ -246,27 +246,27 @@ gsd_smartcard_is_login_card (GsdSmartcard *card)
}
static void
-gsd_smartcard_get_property (GObject *object,
+msd_smartcard_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
- GsdSmartcard *card = GSD_SMARTCARD (object);
+ MsdSmartcard *card = MSD_SMARTCARD (object);
switch (prop_id) {
case PROP_NAME:
g_value_take_string (value,
- gsd_smartcard_get_name (card));
+ msd_smartcard_get_name (card));
break;
case PROP_SLOT_ID:
g_value_set_ulong (value,
- (gulong) gsd_smartcard_get_slot_id (card));
+ (gulong) msd_smartcard_get_slot_id (card));
break;
case PROP_SLOT_SERIES:
g_value_set_int (value,
- gsd_smartcard_get_slot_series (card));
+ msd_smartcard_get_slot_series (card));
break;
default:
@@ -275,7 +275,7 @@ gsd_smartcard_get_property (GObject *object,
}
static void
-gsd_smartcard_set_name (GsdSmartcard *card,
+msd_smartcard_set_name (MsdSmartcard *card,
const char *name)
{
if (name == NULL) {
@@ -288,7 +288,7 @@ gsd_smartcard_set_name (GsdSmartcard *card,
card->priv->name = g_strdup (name);
if (card->priv->slot == NULL) {
- card->priv->slot = gsd_smartcard_find_slot_from_card_name (card,
+ card->priv->slot = msd_smartcard_find_slot_from_card_name (card,
card->priv->name);
if (card->priv->slot != NULL) {
@@ -296,17 +296,17 @@ gsd_smartcard_set_name (GsdSmartcard *card,
slot_id = PK11_GetSlotID (card->priv->slot);
if (slot_id != card->priv->slot_id) {
- gsd_smartcard_set_slot_id (card, slot_id);
+ msd_smartcard_set_slot_id (card, slot_id);
}
slot_series = PK11_GetSlotSeries (card->priv->slot);
if (slot_series != card->priv->slot_series) {
- gsd_smartcard_set_slot_series (card, slot_series);
+ msd_smartcard_set_slot_series (card, slot_series);
}
- _gsd_smartcard_set_state (card, GSD_SMARTCARD_STATE_INSERTED);
+ _msd_smartcard_set_state (card, MSD_SMARTCARD_STATE_INSERTED);
} else {
- _gsd_smartcard_set_state (card, GSD_SMARTCARD_STATE_REMOVED);
+ _msd_smartcard_set_state (card, MSD_SMARTCARD_STATE_REMOVED);
}
}
@@ -315,14 +315,14 @@ gsd_smartcard_set_name (GsdSmartcard *card,
}
static void
-gsd_smartcard_set_slot_id (GsdSmartcard *card,
+msd_smartcard_set_slot_id (MsdSmartcard *card,
int slot_id)
{
if (card->priv->slot_id != slot_id) {
card->priv->slot_id = slot_id;
if (card->priv->slot == NULL) {
- card->priv->slot = gsd_smartcard_find_slot_from_id (card,
+ card->priv->slot = msd_smartcard_find_slot_from_id (card,
card->priv->slot_id);
if (card->priv->slot != NULL) {
@@ -332,12 +332,12 @@ gsd_smartcard_set_slot_id (GsdSmartcard *card,
if ((card->priv->name == NULL) ||
((card_name != NULL) &&
(strcmp (card_name, card->priv->name) != 0))) {
- gsd_smartcard_set_name (card, card_name);
+ msd_smartcard_set_name (card, card_name);
}
- _gsd_smartcard_set_state (card, GSD_SMARTCARD_STATE_INSERTED);
+ _msd_smartcard_set_state (card, MSD_SMARTCARD_STATE_INSERTED);
} else {
- _gsd_smartcard_set_state (card, GSD_SMARTCARD_STATE_REMOVED);
+ _msd_smartcard_set_state (card, MSD_SMARTCARD_STATE_REMOVED);
}
}
@@ -346,7 +346,7 @@ gsd_smartcard_set_slot_id (GsdSmartcard *card,
}
static void
-gsd_smartcard_set_slot_series (GsdSmartcard *card,
+msd_smartcard_set_slot_series (MsdSmartcard *card,
int slot_series)
{
if (card->priv->slot_series != slot_series) {
@@ -356,7 +356,7 @@ gsd_smartcard_set_slot_series (GsdSmartcard *card,
}
static void
-gsd_smartcard_set_module (GsdSmartcard *card,
+msd_smartcard_set_module (MsdSmartcard *card,
SECMODModule *module)
{
gboolean should_notify;
@@ -382,66 +382,66 @@ gsd_smartcard_set_module (GsdSmartcard *card,
}
int
-gsd_smartcard_get_slot_series (GsdSmartcard *card)
+msd_smartcard_get_slot_series (MsdSmartcard *card)
{
return card->priv->slot_series;
}
static void
-gsd_smartcard_init (GsdSmartcard *card)
+msd_smartcard_init (MsdSmartcard *card)
{
g_debug ("initializing smartcard ");
card->priv = G_TYPE_INSTANCE_GET_PRIVATE (card,
- GSD_TYPE_SMARTCARD,
- GsdSmartcardPrivate);
+ MSD_TYPE_SMARTCARD,
+ MsdSmartcardPrivate);
if (card->priv->slot != NULL) {
card->priv->name = g_strdup (PK11_GetTokenName (card->priv->slot));
}
}
-static void gsd_smartcard_finalize (GObject *object)
+static void msd_smartcard_finalize (GObject *object)
{
- GsdSmartcard *card;
+ MsdSmartcard *card;
GObjectClass *gobject_class;
- card = GSD_SMARTCARD (object);
+ card = MSD_SMARTCARD (object);
g_free (card->priv->name);
- gsd_smartcard_set_module (card, NULL);
+ msd_smartcard_set_module (card, NULL);
- gobject_class = G_OBJECT_CLASS (gsd_smartcard_parent_class);
+ gobject_class = G_OBJECT_CLASS (msd_smartcard_parent_class);
gobject_class->finalize (object);
}
-GQuark gsd_smartcard_error_quark (void)
+GQuark msd_smartcard_error_quark (void)
{
static GQuark error_quark = 0;
if (error_quark == 0) {
- error_quark = g_quark_from_static_string ("gsd-smartcard-error-quark");
+ error_quark = g_quark_from_static_string ("msd-smartcard-error-quark");
}
return error_quark;
}
-GsdSmartcard *
-_gsd_smartcard_new (SECMODModule *module,
+MsdSmartcard *
+_msd_smartcard_new (SECMODModule *module,
CK_SLOT_ID slot_id,
int slot_series)
{
- GsdSmartcard *card;
+ MsdSmartcard *card;
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (slot_id >= 1, NULL);
g_return_val_if_fail (slot_series > 0, NULL);
g_return_val_if_fail (sizeof (gulong) == sizeof (slot_id), NULL);
- card = GSD_SMARTCARD (g_object_new (GSD_TYPE_SMARTCARD,
+ card = MSD_SMARTCARD (g_object_new (MSD_TYPE_SMARTCARD,
"module", module,
"slot-id", (gulong) slot_id,
"slot-series", slot_series,
@@ -449,16 +449,16 @@ _gsd_smartcard_new (SECMODModule *module,
return card;
}
-GsdSmartcard *
-_gsd_smartcard_new_from_name (SECMODModule *module,
+MsdSmartcard *
+_msd_smartcard_new_from_name (SECMODModule *module,
const char *name)
{
- GsdSmartcard *card;
+ MsdSmartcard *card;
g_return_val_if_fail (module != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
- card = GSD_SMARTCARD (g_object_new (GSD_TYPE_SMARTCARD,
+ card = MSD_SMARTCARD (g_object_new (MSD_TYPE_SMARTCARD,
"module", module,
"name", name,
NULL));
@@ -466,16 +466,16 @@ _gsd_smartcard_new_from_name (SECMODModule *module,
}
void
-_gsd_smartcard_set_state (GsdSmartcard *card,
- GsdSmartcardState state)
+_msd_smartcard_set_state (MsdSmartcard *card,
+ MsdSmartcardState state)
{
if (card->priv->state != state) {
card->priv->state = state;
- if (state == GSD_SMARTCARD_STATE_INSERTED) {
- g_signal_emit (card, gsd_smartcard_signals[INSERTED], 0);
- } else if (state == GSD_SMARTCARD_STATE_REMOVED) {
- g_signal_emit (card, gsd_smartcard_signals[REMOVED], 0);
+ if (state == MSD_SMARTCARD_STATE_INSERTED) {
+ g_signal_emit (card, msd_smartcard_signals[INSERTED], 0);
+ } else if (state == MSD_SMARTCARD_STATE_REMOVED) {
+ g_signal_emit (card, msd_smartcard_signals[REMOVED], 0);
} else {
g_assert_not_reached ();
}
@@ -489,7 +489,7 @@ _gsd_smartcard_set_state (GsdSmartcard *card,
* and strdup it using NSPR's memory allocation routines.
*/
static char *
-gsd_smartcard_password_handler (PK11SlotInfo *slot,
+msd_smartcard_password_handler (PK11SlotInfo *slot,
PRBool is_retrying,
const char *password)
{
@@ -501,12 +501,12 @@ gsd_smartcard_password_handler (PK11SlotInfo *slot,
}
gboolean
-gsd_smartcard_unlock (GsdSmartcard *card,
+msd_smartcard_unlock (MsdSmartcard *card,
const char *password)
{
SECStatus status;
- PK11_SetPasswordFunc ((PK11PasswordFunc) gsd_smartcard_password_handler);
+ PK11_SetPasswordFunc ((PK11PasswordFunc) msd_smartcard_password_handler);
/* we pass PR_TRUE to load certificates
*/
@@ -520,7 +520,7 @@ gsd_smartcard_unlock (GsdSmartcard *card,
}
static PK11SlotInfo *
-gsd_smartcard_find_slot_from_card_name (GsdSmartcard *card,
+msd_smartcard_find_slot_from_card_name (MsdSmartcard *card,
const char *card_name)
{
int i;
@@ -540,7 +540,7 @@ gsd_smartcard_find_slot_from_card_name (GsdSmartcard *card,
}
static PK11SlotInfo *
-gsd_smartcard_find_slot_from_id (GsdSmartcard *card,
+msd_smartcard_find_slot_from_id (MsdSmartcard *card,
int slot_id)
{
int i;