summaryrefslogtreecommitdiff
path: root/src/analysis/db/items/bookmark.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-09-17 22:06:54 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-09-17 22:06:54 (GMT)
commit3dc843b3f7991dcd738a30821ff56c7fe13f1094 (patch)
tree22b40ef7cd933a57942bd01d61c9e6a07fdd80c6 /src/analysis/db/items/bookmark.c
parent682159e73cfbf8ec61d2f2aba765be1016a30ded (diff)
Kept tracks of current active DB items.
Diffstat (limited to 'src/analysis/db/items/bookmark.c')
-rw-r--r--src/analysis/db/items/bookmark.c87
1 files changed, 80 insertions, 7 deletions
diff --git a/src/analysis/db/items/bookmark.c b/src/analysis/db/items/bookmark.c
index 20f98ea..3d66f6b 100644
--- a/src/analysis/db/items/bookmark.c
+++ b/src/analysis/db/items/bookmark.c
@@ -73,6 +73,12 @@ static void g_db_bookmark_dispose(GDbBookmark *);
/* Procède à la libération totale de la mémoire. */
static void g_db_bookmark_finalize(GDbBookmark *);
+/* Calcule le condensat associé à l'élément vu comme clef. */
+static guint g_db_bookmark_hash_key(const GDbBookmark *);
+
+/* Compare deux éléments en tant que clefs. */
+static gboolean g_db_bookmark_cmp_key(const GDbBookmark *, const GDbBookmark *);
+
/* Effectue la comparaison entre deux signets de collection. */
static gint g_db_bookmark_cmp(GDbBookmark *, GDbBookmark *, bool);
@@ -178,6 +184,9 @@ static void g_db_bookmark_class_init(GDbBookmarkClass *klass)
item->feature = DBF_BOOKMARKS;
+ item->hash_key = (hash_db_item_key_fc)g_db_bookmark_hash_key;
+ item->cmp_key = (cmp_db_item_key_fc)g_db_bookmark_cmp_key;
+
item->cmp = (cmp_db_item_fc)g_db_bookmark_cmp;
item->unpack = (unpack_db_item_fc)g_db_bookmark_unpack;
@@ -319,6 +328,56 @@ bool g_db_bookmark_fill(GDbBookmark *bookmark, const vmpa2t *addr, const char *c
/******************************************************************************
* *
+* Paramètres : bookmark = élément de collection à consulter. *
+* *
+* Description : Calcule le condensat associé à l'élément vu comme clef. *
+* *
+* Retour : Condensat associé à l'élément. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static guint g_db_bookmark_hash_key(const GDbBookmark *bookmark)
+{
+ guint result; /* Valeur "unique" à renvoyer */
+
+ result = hash_vmpa(&bookmark->addr);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : a = premier élément de collection à consulter. *
+* b = second élément de collection à consulter. *
+* *
+* Description : Compare deux éléments en tant que clefs. *
+* *
+* Retour : Bilan de la comparaison. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static gboolean g_db_bookmark_cmp_key(const GDbBookmark *a, const GDbBookmark *b)
+{
+ gboolean result; /* Bilan à retourner */
+ int ret; /* Bilan intermédiaire */
+
+ ret = cmp_vmpa(&a->addr, &b->addr);
+
+ result = (ret == 0);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : a = premier élément à analyser. *
* b = second élément à analyser. *
* with = précise les horodatages à prendre en compte. *
@@ -424,22 +483,36 @@ static char *g_db_bookmark_build_label(GDbBookmark *bookmark)
{
char *result; /* Description à retourner */
DbItemFlags flags; /* Propriétés de l'élément */
- const char *prefix; /* Préfixe à ajouter */
const char *text; /* Commentaire associé */
+ const char *prefix; /* Préfixe à ajouter */
flags = g_db_item_get_flags(G_DB_ITEM(bookmark));
if (flags & DIF_ERASER)
- prefix = _("Removed");
+ asprintf(&result, _("Removed bookmark"));
+
+ else if (flags & DIF_UPDATED)
+ {
+ text = get_rle_string(&bookmark->comment);
+
+ if (text != NULL)
+ asprintf(&result, _("Updated bookmark: \"%s\""), text);
+ else
+ asprintf(&result, _("Reset bookmark"));
+ }
+
else
+ {
prefix = _("Created");
- text = get_rle_string(&bookmark->comment);
+ text = get_rle_string(&bookmark->comment);
- if (text != NULL)
- asprintf(&result, _("%s bookmark \"%s\""), prefix, text);
- else
- asprintf(&result, _("%s empty bookmark"), prefix);
+ if (text != NULL)
+ asprintf(&result, _("%s bookmark \"%s\""), prefix, text);
+ else
+ asprintf(&result, _("%s empty bookmark"), prefix);
+
+ }
return result;