aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJP Rosevear <jpr@helixcode.com>2000-10-25 00:21:10 +0800
committerJP Rosevear <jpr@src.gnome.org>2000-10-25 00:21:10 +0800
commite504870c44f30b89276793ef13905315c9495b95 (patch)
tree0bd1cef5f7c1418236349744ddfbb66e8e5f3ac3
parenta0ca956fc439bcf30a3b6a5a5af6907cfb3b8ab8 (diff)
downloadgsoc2013-evolution-e504870c44f30b89276793ef13905315c9495b95.tar.gz
gsoc2013-evolution-e504870c44f30b89276793ef13905315c9495b95.tar.zst
gsoc2013-evolution-e504870c44f30b89276793ef13905315c9495b95.zip
Lookup a pid by uid. (e_pilot_map_lookup_uid): Lookup a uid by pid. Now
2000-10-23 JP Rosevear <jpr@helixcode.com> * e-pilot-map.c (e_pilot_map_lookup_pid): Lookup a pid by uid. (e_pilot_map_lookup_uid): Lookup a uid by pid. Now this is wrapped, we can store archive info internally * e-pilot-map.h: New accessor prototype 2000-10-23 JP Rosevear <jpr@helixcode.com> * conduits/todo/todo-conduit.c (local_record_from_comp): Use new e-pilot-map lookup function (match): ditto * conduits/calendar/calendar-conduit.c (local_record_from_comp): Use new e-pilot-map lookup function (match): ditto svn path=/trunk/; revision=6146
-rw-r--r--calendar/ChangeLog10
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c23
-rw-r--r--calendar/conduits/todo/todo-conduit.c24
-rw-r--r--e-util/ChangeLog8
-rw-r--r--e-util/e-pilot-map.c25
-rw-r--r--e-util/e-pilot-map.h4
6 files changed, 56 insertions, 38 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 03b6968ac8..6da5bcb51b 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,13 @@
+2000-10-23 JP Rosevear <jpr@helixcode.com>
+
+ * conduits/todo/todo-conduit.c (local_record_from_comp): Use
+ new e-pilot-map lookup function
+ (match): ditto
+
+ * conduits/calendar/calendar-conduit.c (local_record_from_comp): Use
+ new e-pilot-map lookup function
+ (match): ditto
+
2000-10-23 Dan Winship <danw@helixcode.com>
* pcs/Makefile.am (INCLUDES):
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index f5ef766648..ac3bd515c3 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -236,19 +236,6 @@ get_ical_day (int day)
}
static void
-compute_pid (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *uid)
-{
- guint32 *pid;
-
- pid = g_hash_table_lookup (ctxt->map->uid_map, uid);
-
- if (pid)
- local->local.ID = *pid;
- else
- local->local.ID = 0;
-}
-
-static void
compute_status (ECalConduitContext *ctxt, ECalLocalRecord *local, const char *uid)
{
local->local.archived = FALSE;
@@ -314,7 +301,7 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC
local->comp = comp;
cal_component_get_uid (local->comp, &uid);
- compute_pid (ctxt, local, uid);
+ local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid);
compute_status (ctxt, local, uid);
local->appt = g_new0 (struct Appointment,1);
@@ -403,7 +390,7 @@ local_record_from_comp (ECalLocalRecord *local, CalComponent *comp, ECalConduitC
static void
local_record_from_uid (ECalLocalRecord *local,
- char *uid,
+ const char *uid,
ECalConduitContext *ctxt)
{
CalComponent *comp;
@@ -651,7 +638,7 @@ pre_sync (GnomePilotConduit *conduit,
switch (coc->type) {
case CALOBJ_UPDATED:
- if (g_hash_table_lookup (ctxt->map->uid_map, coc->uid))
+ if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0)
g_hash_table_insert (ctxt->modified, coc->uid, coc);
else
g_hash_table_insert (ctxt->added, coc->uid, coc);
@@ -965,7 +952,7 @@ match (GnomePilotConduitSyncAbs *conduit,
ECalLocalRecord **local,
ECalConduitContext *ctxt)
{
- char *uid;
+ const char *uid;
LOG ("match: looking for local copy of %s\n",
print_remote (remote));
@@ -974,7 +961,7 @@ match (GnomePilotConduitSyncAbs *conduit,
g_return_val_if_fail (remote != NULL, -1);
*local = NULL;
- uid = g_hash_table_lookup (ctxt->map->pid_map, &remote->ID);
+ uid = e_pilot_map_lookup_uid (ctxt->map, remote->ID);
if (!uid)
return 0;
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index 9158f55c30..d4b715f4e8 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -215,19 +215,6 @@ map_name (EToDoConduitContext *ctxt)
}
static void
-compute_pid (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const char *uid)
-{
- guint32 *pid;
-
- pid = g_hash_table_lookup (ctxt->map->uid_map, uid);
-
- if (pid)
- local->local.ID = *pid;
- else
- local->local.ID = 0;
-}
-
-static void
compute_status (EToDoConduitContext *ctxt, EToDoLocalRecord *local, const char *uid)
{
local->local.archived = FALSE;
@@ -294,7 +281,8 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui
local->comp = comp;
cal_component_get_uid (local->comp, &uid);
- compute_pid (ctxt, local, uid);
+ local->local.ID = e_pilot_map_lookup_pid (ctxt->map, uid);
+
compute_status (ctxt, local, uid);
local->todo = g_new0 (struct ToDo,1);
@@ -350,7 +338,7 @@ local_record_from_comp (EToDoLocalRecord *local, CalComponent *comp, EToDoCondui
static void
local_record_from_uid (EToDoLocalRecord *local,
- char *uid,
+ const char *uid,
EToDoConduitContext *ctxt)
{
CalComponent *comp;
@@ -530,7 +518,7 @@ pre_sync (GnomePilotConduit *conduit,
switch (coc->type) {
case CALOBJ_UPDATED:
- if (g_hash_table_lookup (ctxt->map->uid_map, coc->uid))
+ if (e_pilot_map_lookup_pid (ctxt->map, coc->uid) > 0)
g_hash_table_insert (ctxt->modified, coc->uid, coc);
else
g_hash_table_insert (ctxt->added, coc->uid, coc);
@@ -845,7 +833,7 @@ match (GnomePilotConduitSyncAbs *conduit,
EToDoLocalRecord **local,
EToDoConduitContext *ctxt)
{
- char *uid;
+ const char *uid;
LOG ("match: looking for local copy of %s\n",
print_remote (remote));
@@ -854,7 +842,7 @@ match (GnomePilotConduitSyncAbs *conduit,
g_return_val_if_fail (remote != NULL, -1);
*local = NULL;
- uid = g_hash_table_lookup (ctxt->map->pid_map, &remote->ID);
+ uid = e_pilot_map_lookup_uid (ctxt->map, remote->ID);
if (!uid)
return 0;
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 5851b7f508..ede4147b9f 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,11 @@
+2000-10-23 JP Rosevear <jpr@helixcode.com>
+
+ * e-pilot-map.c (e_pilot_map_lookup_pid): Lookup a pid by uid.
+ (e_pilot_map_lookup_uid): Lookup a uid by pid.
+ Now this is wrapped, we can store archive info internally
+
+ * e-pilot-map.h: New accessor prototypes
+
2000-10-23 Dan Winship <danw@helixcode.com>
* ename/Makefile.am (INCLUDES): Remove unused GNOMELOCALEDIR
diff --git a/e-util/e-pilot-map.c b/e-util/e-pilot-map.c
index 4b364f39bd..3a1b660c60 100644
--- a/e-util/e-pilot-map.c
+++ b/e-util/e-pilot-map.c
@@ -98,7 +98,7 @@ map_write_foreach (gpointer key, gpointer value, gpointer data)
}
gboolean
-e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pilot_id)
+e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pid)
{
return FALSE;
}
@@ -122,6 +122,29 @@ e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archi
g_hash_table_insert (map->uid_map, new_uid, new_pid);
}
+guint32
+e_pilot_map_lookup_pid (EPilotMap *map, const char *uid)
+{
+ guint32 *pid;
+
+ pid = g_hash_table_lookup (map->uid_map, uid);
+
+ if (pid == NULL)
+ return 0;
+
+ return *pid;
+}
+
+const char *
+e_pilot_map_lookup_uid (EPilotMap *map, guint32 pid)
+{
+ const char *uid;
+
+ uid = g_hash_table_lookup (map->pid_map, &pid);
+
+ return uid;
+}
+
int
e_pilot_map_read (const char *filename, EPilotMap **map)
{
diff --git a/e-util/e-pilot-map.h b/e-util/e-pilot-map.h
index e910f43317..8e3d2b71f6 100644
--- a/e-util/e-pilot-map.h
+++ b/e-util/e-pilot-map.h
@@ -36,10 +36,12 @@ struct _EPilotMap
time_t since;
};
-gboolean e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pilot_id);
+gboolean e_pilot_map_pid_is_archived (EPilotMap *map, guint32 pid);
gboolean e_pilot_map_uid_is_archived (EPilotMap *map, const char *uid);
void e_pilot_map_insert (EPilotMap *map, guint32 pid, const char *uid, gboolean archived);
+guint32 e_pilot_map_lookup_pid (EPilotMap *map, const char *uid);
+const char * e_pilot_map_lookup_uid (EPilotMap *map, guint32 pid);
int e_pilot_map_read (const char *filename, EPilotMap **map);
int e_pilot_map_write (const char *filename, EPilotMap *map);