aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnu.org>1999-07-29 12:25:08 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-07-29 12:25:08 +0800
commitcabedf4da95562f8372a543840748ea43dff2a91 (patch)
tree9d15220864e12083fa4747a775400446cd0502d3 /calendar/gui
parent094deb7bca96f1dcf97952b93a7c4745cd799ebc (diff)
downloadgsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.tar.gz
gsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.tar.zst
gsoc2013-evolution-cabedf4da95562f8372a543840748ea43dff2a91.zip
Make the code not take arguments (sync_cal_to_pilot): Nice event update
1999-07-28 Miguel de Icaza <miguel@gnu.org> * calendar-pilot-sync.c: Make the code not take arguments (sync_cal_to_pilot): Nice event update information * calendar.c (calendar_new): Add Event UID hash table. (calendar_add_object): Add events to the hash table here. (calendar_remove_object): Remove events here. (calendar_object_find_event): Use the hash table here. * main.c (save_calendar_cmd): The object is already destroyed by gnome_dialog_run. * calendar-pilot-sync.c (sync_object_to_pilot): Do not turn archived bit on. svn path=/trunk/; revision=1041
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/calendar-pilot-sync.c36
-rw-r--r--calendar/gui/calendar.c23
-rw-r--r--calendar/gui/calendar.h2
-rw-r--r--calendar/gui/corba-cal.c2
-rw-r--r--calendar/gui/eventedit.c9
-rw-r--r--calendar/gui/main.c1
6 files changed, 33 insertions, 40 deletions
diff --git a/calendar/gui/calendar-pilot-sync.c b/calendar/gui/calendar-pilot-sync.c
index bbacd312eb..d0bd03ed75 100644
--- a/calendar/gui/calendar-pilot-sync.c
+++ b/calendar/gui/calendar-pilot-sync.c
@@ -47,9 +47,9 @@ int only_pilot_to_desktop = 0;
const struct poptOption calendar_sync_options [] = {
{ "pilot", 0, POPT_ARG_STRING, &pilot_port, 0,
N_("Specifies the port on which the Pilot is"), N_("PORT") },
- { "debug-attrs", 0, POPT_ARG_INT, &debug_attrs, 0,
+ { "debug-attrs", 0, POPT_ARG_NONE, &debug_attrs, 0,
N_("If you want to debug the attributes on records"), NULL },
- { "only-desktop", 0, POPT_ARG_INT, &only_desktop_to_pilot, 0,
+ { "only-desktop", 0, POPT_ARG_NONE, &only_desktop_to_pilot, 0,
N_("Only syncs from desktop to pilot"), NULL },
{ "only-pilot", 0, POPT_ARG_INT, &only_pilot_to_desktop, 0,
N_("Only syncs from pilot to desktop"), NULL },
@@ -331,7 +331,11 @@ sync_object_to_pilot (GNOME_Calendar_Repository repo, iCalObject *obj, int pilot
if (rec_len > 0)
unpack_Appointment (a, buffer, rec_len);
- }
+ } else {
+ attr = 0;
+ cat = 0;
+ }
+
/* a contains the appointment either cleared or with the data from the Pilot */
a->begin = *localtime (&obj->dtstart);
a->end = *localtime (&obj->dtend);
@@ -432,20 +436,14 @@ sync_object_to_pilot (GNOME_Calendar_Repository repo, iCalObject *obj, int pilot
attr &= ~dlpRecAttrSecret;
/*
- * Mark as archived. FIXME: is this the case?
- */
- attr |= dlpRecAttrArchived;
-
- /*
* Send the appointment to the pilot
*/
rec_len = pack_Appointment (a, buffer, sizeof (buffer));
attr &= ~dlpRecAttrDirty;
- printf ("Status=%d\n",
- dlp_WriteRecord (
+ dlp_WriteRecord (
pilot_fd, db, attr,
- obj->pilot_id, cat, buffer, rec_len, &new_id));
+ obj->pilot_id, cat, buffer, rec_len, &new_id);
GNOME_Calendar_Repository_update_pilot_id (repo, obj->uid, new_id, ICAL_PILOT_SYNC_NONE, &ev);
free_Appointment (a);
@@ -456,10 +454,15 @@ static void
sync_cal_to_pilot (GNOME_Calendar_Repository repo, Calendar *cal, int pilot_fd)
{
GList *l;
-
- for (l = cal->events; l; l = l->next){
+ int c = g_list_length (cal->events);
+ int i;
+
+ printf ("\n");
+ for (i = 0, l = cal->events; l; l = l->next, i++){
iCalObject *obj = l->data;
+ printf ("Syncing desktop to pilot: %d/%d\r", i + 1, c);
+ fflush (stdout);
if (obj->pilot_status != ICAL_PILOT_SYNC_MOD){
g_warning ("Strange, we were supposed to get only a dirty object");
continue;
@@ -467,6 +470,7 @@ sync_cal_to_pilot (GNOME_Calendar_Repository repo, Calendar *cal, int pilot_fd)
sync_object_to_pilot (repo, obj, pilot_fd);
}
+ printf ("\n");
}
static void
@@ -533,7 +537,7 @@ sync_pilot (GNOME_Calendar_Repository repo, int pilot_fd)
/* If the object was deleted, remove it from the database */
if (attr & dlpRecAttrDeleted){
- printf ("Deleteing\n");
+ printf ("Deleting\n");
delete_record (repo, id);
free_Appointment (&a);
continue;
@@ -591,9 +595,9 @@ main (int argc, char *argv [])
repository = locate_calendar_server ();
printf ("Done\n");
- printf ("Syncing...\n");
+ printf ("<Syncing>\n");
sync_pilot (repository, link);
- printf ("Done Syncing\n");
+ printf ("</Syncing>\n");
GNOME_Calendar_Repository_done (repository, &ev);
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index 30e4e0168c..339995cb92 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -38,6 +38,8 @@ calendar_new (char *title)
cal->title = g_strdup (title);
+ cal->event_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
calendar_init_alarms (cal);
return cal;
@@ -93,9 +95,14 @@ ical_object_try_alarms (iCalObject *obj)
void
calendar_add_object (Calendar *cal, iCalObject *obj)
{
+ g_return_if_fail (cal != NULL);
+ g_return_if_fail (obj != NULL);
+ g_return_if_fail (obj->uid != NULL);
+
obj->new = 0;
switch (obj->type){
case ICAL_EVENT:
+ g_hash_table_insert (cal->event_hash, obj->uid, obj);
cal->events = g_list_prepend (cal->events, obj);
ical_object_try_alarms (obj);
#ifdef DEBUGGING_MAIL_ALARM
@@ -133,6 +140,7 @@ calendar_remove_object (Calendar *cal, iCalObject *obj)
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_remove (cal->events, obj);
+ g_hash_table_remove (cal->event_hash, obj->uid);
break;
case ICAL_TODO:
@@ -161,6 +169,8 @@ calendar_destroy (Calendar *cal)
g_list_foreach (cal->journal, (GFunc) ical_object_destroy, NULL);
g_list_free (cal->journal);
+ g_hash_table_destroy (cal->event_hash);
+
if (cal->title)
g_free (cal->title);
if (cal->filename)
@@ -169,17 +179,6 @@ calendar_destroy (Calendar *cal)
g_free (cal);
}
-static char *
-ice (time_t t)
-{
- static char buffer [100];
- struct tm *tm;
-
- tm = localtime (&t);
- sprintf (buffer, "%d/%d/%d", tm->tm_mday, tm->tm_mon, tm->tm_year);
- return buffer;
-}
-
void
calendar_iterate_on_objects (GList *objects, time_t start, time_t end, calendarfn cb, void *closure)
{
@@ -544,7 +543,7 @@ calendar_object_find_event (Calendar *cal, const char *uid)
g_return_val_if_fail (cal != NULL, NULL);
g_return_val_if_fail (uid != NULL, NULL);
- return calendar_object_find_in_list (cal, cal->events, uid);
+ return g_hash_table_lookup (cal->event_hash, uid);
}
iCalObject *
diff --git a/calendar/gui/calendar.h b/calendar/gui/calendar.h
index aa25fba67c..4a9d4bcff2 100644
--- a/calendar/gui/calendar.h
+++ b/calendar/gui/calendar.h
@@ -17,6 +17,8 @@ typedef struct {
GList *todo;
GList *journal;
+ GHashTable *event_hash;
+
/* Time at which the calendar was created */
time_t created;
diff --git a/calendar/gui/corba-cal.c b/calendar/gui/corba-cal.c
index 8f92057d42..f322b41db8 100644
--- a/calendar/gui/corba-cal.c
+++ b/calendar/gui/corba-cal.c
@@ -81,7 +81,6 @@ cal_repo_get_object_by_pilot_id (PortableServer_Servant servant,
CORBA_char *ret;
obj = calendar_object_find_by_pilot (gcal->cal, pilot_id);
- printf ("Looking for [%d]\n", pilot_id);
if (obj == NULL){
CORBA_exception_set (ev,
CORBA_USER_EXCEPTION,
@@ -149,7 +148,6 @@ cal_repo_update_object (PortableServer_Servant servant,
obj = calendar_object_find_event (gcal->cal, uid);
if (obj != NULL){
- printf ("ELIMINATING: %s -> %s\n", obj->uid, new_object->uid);
calendar_remove_object (gcal->cal, obj);
}
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index 8a36b94638..027c59839d 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -60,15 +60,6 @@ event_editor_class_init (EventEditorClass *class)
}
static GtkWidget *
-adjust (GtkWidget *w, gfloat x, gfloat y, gfloat xs, gfloat ys)
-{
- GtkWidget *a = gtk_alignment_new (x, y, xs, ys);
-
- gtk_container_add (GTK_CONTAINER (a), w);
- return a;
-}
-
-static GtkWidget *
make_spin_button (int val, int low, int high)
{
GtkAdjustment *adj;
diff --git a/calendar/gui/main.c b/calendar/gui/main.c
index 7a1888898b..3a49dfaa9a 100644
--- a/calendar/gui/main.c
+++ b/calendar/gui/main.c
@@ -440,7 +440,6 @@ save_calendar_cmd (GtkWidget *widget, void *data)
g_free (str);
gnome_dialog_set_default (GNOME_DIALOG (box), 1);
b = gnome_dialog_run (GNOME_DIALOG (box));
- gtk_object_destroy (GTK_OBJECT (box));
if (b != 0)
return;