View | Details | Raw Unified | Return to bug 412719
Collapse All | Expand All

(-)calendar-window.c (+2 lines)
Lines 388-393 is_appointment (GtkTreeModel *model, Link Here
388
		return (g_ascii_strcasecmp (uri, "file")   == 0 ||
388
		return (g_ascii_strcasecmp (uri, "file")   == 0 ||
389
			g_ascii_strcasecmp (uri, "webcal") == 0 ||
389
			g_ascii_strcasecmp (uri, "webcal") == 0 ||
390
			g_ascii_strcasecmp (uri, "caldav") == 0 ||
390
			g_ascii_strcasecmp (uri, "caldav") == 0 ||
391
			g_ascii_strcasecmp (uri, "exchange")  == 0 ||
392
			g_ascii_strcasecmp (uri, "groupwise") == 0 ||
391
			g_ascii_strcasecmp (uri, "google") == 0);
393
			g_ascii_strcasecmp (uri, "google") == 0);
392
	return FALSE;
394
	return FALSE;
393
}
395
}
(-)calendar-sources.c (-25 / +10 lines)
Lines 311-324 auth_func_cb (ECal *ecal, Link Here
311
	return e_passwords_get_password (component_name, key);
311
	return e_passwords_get_password (component_name, key);
312
}
312
}
313
313
314
/* The clients are just created here but not loaded */
314
static ECal *
315
static ECal *
315
load_esource (ESource        *esource,
316
get_ecal_from_source (ESource        *esource,
316
	      ECalSourceType  source_type,
317
		      ECalSourceType  source_type,
317
	      GSList         *existing_clients)
318
		      GSList         *existing_clients)
318
{
319
{
319
  ECal   *retval;
320
  ECal *retval;
320
  GError *error;
321
322
321
323
  if (existing_clients)
322
  if (existing_clients)
324
    {
323
    {
Lines 348-367 load_esource (ESource *esource, Link Here
348
347
349
  e_cal_set_auth_func (retval, auth_func_cb, NULL);
348
  e_cal_set_auth_func (retval, auth_func_cb, NULL);
350
349
351
  error = NULL;
352
  if (!e_cal_open (retval, TRUE, &error))
353
    {
354
      g_assert (error != NULL);
355
      g_warning ("Cannot open calendar from uri '%s': %s\n",
356
		 e_cal_get_uri (retval), error->message);
357
      g_error_free (error);
358
      g_object_unref (retval);
359
      return NULL;
360
    }
361
362
  dprintf ("        Loaded calendar from uri '%s'\n",
363
	   e_cal_get_uri (retval));
364
365
  return retval;
350
  return retval;
366
}
351
}
367
352
Lines 466-472 backend_died_cb (ECal *client, CalendarS Link Here
466
static void
451
static void
467
calendar_sources_load_esource_list (CalendarSourceData *source_data)
452
calendar_sources_load_esource_list (CalendarSourceData *source_data)
468
{
453
{
469
  GSList  *loaded_clients = NULL;
454
  GSList  *clients = NULL;
470
  GSList  *groups, *l;
455
  GSList  *groups, *l;
471
  gboolean emit_signal = FALSE;
456
  gboolean emit_signal = FALSE;
472
457
Lines 496-511 calendar_sources_load_esource_list (Cale Link Here
496
		   e_source_peek_relative_uri (esource));
481
		   e_source_peek_relative_uri (esource));
497
482
498
	  if (is_source_selected (esource, source_data->selected_sources) &&
483
	  if (is_source_selected (esource, source_data->selected_sources) &&
499
	      (client = load_esource (esource, source_data->source_type, source_data->clients)))
484
	      (client = get_ecal_from_source (esource, source_data->source_type, source_data->clients)))
500
	    {
485
	    {
501
	      loaded_clients = g_slist_prepend (loaded_clients, client);
486
	      clients = g_slist_prepend (clients, client);
502
	    }
487
	    }
503
	}
488
	}
504
    }
489
    }
505
  dprintf ("\n");
490
  dprintf ("\n");
506
491
507
  if (source_data->loaded && 
492
  if (source_data->loaded && 
508
      !compare_ecal_lists (source_data->clients, loaded_clients))
493
      !compare_ecal_lists (source_data->clients, clients))
509
    emit_signal = TRUE;
494
    emit_signal = TRUE;
510
495
511
  for (l = source_data->clients; l; l = l->next)
496
  for (l = source_data->clients; l; l = l->next)
Lines 517-523 calendar_sources_load_esource_list (Cale Link Here
517
      g_object_unref (l->data);
502
      g_object_unref (l->data);
518
    }
503
    }
519
  g_slist_free (source_data->clients);
504
  g_slist_free (source_data->clients);
520
  source_data->clients = g_slist_reverse (loaded_clients);
505
  source_data->clients = g_slist_reverse (clients);
521
506
522
  /* connect to backend_died after we disconnected the previous signal
507
  /* connect to backend_died after we disconnected the previous signal
523
   * handlers. If we do it before, we'll lose some handlers (for clients that
508
   * handlers. If we do it before, we'll lose some handlers (for clients that
(-)calendar-client.c (-9 / +106 lines)
Lines 120-125 static void calendar_client_start_query Link Here
120
static void calendar_client_source_finalize (CalendarClientSource *source);
120
static void calendar_client_source_finalize (CalendarClientSource *source);
121
static void calendar_client_query_finalize  (CalendarClientQuery  *query);
121
static void calendar_client_query_finalize  (CalendarClientQuery  *query);
122
122
123
static void
124
calendar_client_update_appointments (CalendarClient *client);
125
static void
126
calendar_client_update_tasks (CalendarClient *client);
127
123
enum
128
enum
124
{
129
{
125
  PROP_O,
130
  PROP_O,
Lines 269-277 calendar_client_set_timezone (CalendarCl Link Here
269
  for (l = esources; l; l = l->next) {
274
  for (l = esources; l; l = l->next) {
270
    ECal *source = l->data;
275
    ECal *source = l->data;
271
			
276
			
272
    if (e_cal_get_load_state (source) != E_CAL_LOAD_LOADED)
273
      continue;
274
275
    e_cal_set_default_timezone (source, client->priv->zone, NULL);
277
    e_cal_set_default_timezone (source, client->priv->zone, NULL);
276
  }
278
  }
277
}
279
}
Lines 285-290 calendar_client_timezone_changed_cb (GCo Link Here
285
  calendar_client_set_timezone (client);
287
  calendar_client_set_timezone (client);
286
}
288
}
287
289
290
static void
291
cal_opened_cb (ECal                 *ecal,
292
               ECalendarStatus       status,
293
               CalendarClientSource *cl_source)
294
{
295
  ECalSourceType  s_type;
296
  CalendarClient *client = cl_source->client;
297
298
  s_type = e_cal_get_source_type (ecal);
299
300
  if (status == E_CALENDAR_STATUS_BUSY &&
301
      e_cal_get_load_state (ecal) == E_CAL_LOAD_NOT_LOADED)
302
    {
303
      e_cal_open_async (ecal, FALSE);
304
      return;
305
    }
306
  
307
  g_signal_handlers_disconnect_by_func (ecal, cal_opened_cb, cl_source);
308
309
  if (status != E_CALENDAR_STATUS_OK)
310
    {
311
      if (s_type == E_CAL_SOURCE_TYPE_EVENT)
312
        client->priv->appointment_sources = g_slist_remove (client->priv->appointment_sources,
313
                                                            cl_source);
314
      else
315
        client->priv->task_sources = g_slist_remove (client->priv->task_sources,
316
                                                     cl_source);
317
318
      calendar_client_source_finalize (cl_source);
319
      g_free (cl_source);
320
321
      return;
322
    }
323
324
  if (s_type == E_CAL_SOURCE_TYPE_EVENT)
325
    calendar_client_update_appointments (client);
326
  else
327
    calendar_client_update_tasks (client);
328
}
329
330
static void
331
load_calendars (CalendarClient    *client,
332
                CalendarEventType  type) 
333
{
334
  GSList *l, *clients;
335
336
  switch (type)
337
    {
338
      case CALENDAR_EVENT_APPOINTMENT:
339
        clients = client->priv->appointment_sources;
340
        break;
341
      case CALENDAR_EVENT_TASK:
342
        clients = client->priv->task_sources;
343
        break;
344
      default:
345
        g_assert_not_reached ();
346
    }
347
348
  for (l = clients; l != NULL; l = l->next)
349
    {
350
      ECal *ecal;	
351
      CalendarClientSource *cl_source = l->data;
352
353
      ecal = cl_source->source;
354
355
      if (e_cal_get_load_state (ecal) == E_CAL_LOAD_LOADED)
356
        continue;
357
358
      g_signal_connect (G_OBJECT (ecal), "cal_opened",
359
                        G_CALLBACK (cal_opened_cb), cl_source);
360
      e_cal_open_async (ecal, TRUE);
361
    }
362
}
288
363
289
static void
364
static void
290
calendar_client_init (CalendarClient *client)
365
calendar_client_init (CalendarClient *client)
Lines 294-299 calendar_client_init (CalendarClient *cl Link Here
294
  client->priv = CALENDAR_CLIENT_GET_PRIVATE (client);
369
  client->priv = CALENDAR_CLIENT_GET_PRIVATE (client);
295
370
296
  client->priv->calendar_sources = calendar_sources_get ();
371
  client->priv->calendar_sources = calendar_sources_get ();
372
  client->priv->gconf_client = gconf_client_get_default ();
297
373
298
  esources = calendar_sources_get_appointment_sources (client->priv->calendar_sources);
374
  esources = calendar_sources_get_appointment_sources (client->priv->calendar_sources);
299
  client->priv->appointment_sources =
375
  client->priv->appointment_sources =
Lines 302-307 calendar_client_init (CalendarClient *cl Link Here
302
  esources = calendar_sources_get_task_sources (client->priv->calendar_sources);
378
  esources = calendar_sources_get_task_sources (client->priv->calendar_sources);
303
  client->priv->task_sources =
379
  client->priv->task_sources =
304
    calendar_client_update_sources_list (client, NULL, esources, signals [TASKS_CHANGED]);
380
    calendar_client_update_sources_list (client, NULL, esources, signals [TASKS_CHANGED]);
381
 
382
  /* set the timezone before loading the clients */ 
383
  calendar_client_set_timezone (client);
384
  load_calendars (client, CALENDAR_EVENT_APPOINTMENT);
385
  load_calendars (client, CALENDAR_EVENT_TASK);
305
386
306
  g_signal_connect_swapped (client->priv->calendar_sources,
387
  g_signal_connect_swapped (client->priv->calendar_sources,
307
			    "appointment-sources-changed",
388
			    "appointment-sources-changed",
Lines 312-325 calendar_client_init (CalendarClient *cl Link Here
312
			    G_CALLBACK (calendar_client_task_sources_changed),
393
			    G_CALLBACK (calendar_client_task_sources_changed),
313
			    client);
394
			    client);
314
395
315
  client->priv->gconf_client = gconf_client_get_default ();
316
317
  gconf_client_add_dir (client->priv->gconf_client,
396
  gconf_client_add_dir (client->priv->gconf_client,
318
			CALENDAR_CONFIG_PREFIX,
397
			CALENDAR_CONFIG_PREFIX,
319
			GCONF_CLIENT_PRELOAD_NONE,
398
			GCONF_CLIENT_PRELOAD_NONE,
320
			NULL);
399
			NULL);
321
400
322
  calendar_client_set_timezone (client);
323
  client->priv->zone_listener = gconf_client_notify_add (client->priv->gconf_client,
401
  client->priv->zone_listener = gconf_client_notify_add (client->priv->gconf_client,
324
                                                         CALENDAR_CONFIG_TIMEZONE,
402
                                                         CALENDAR_CONFIG_TIMEZONE,
325
                                                         (GConfClientNotifyFunc) calendar_client_timezone_changed_cb,
403
                                                         (GConfClientNotifyFunc) calendar_client_timezone_changed_cb,
Lines 1497-1503 calendar_client_update_appointments (Cal Link Here
1497
			   month_begin, month_end);
1575
			   month_begin, month_end);
1498
1576
1499
  for (l = client->priv->appointment_sources; l; l = l->next)
1577
  for (l = client->priv->appointment_sources; l; l = l->next)
1500
    calendar_client_start_query (client, l->data, query);
1578
    {
1579
      CalendarClientSource *cs = l->data;
1580
                  
1581
      if (e_cal_get_load_state (cs->source) != E_CAL_LOAD_LOADED)  
1582
        continue;
1583
1584
      calendar_client_start_query (client, cs, query);
1585
    }
1501
1586
1502
  g_free (month_begin);
1587
  g_free (month_begin);
1503
  g_free (month_end);
1588
  g_free (month_end);
Lines 1557-1563 calendar_client_update_tasks (CalendarCl Link Here
1557
#endif /* FIX_BROKEN_TASKS_QUERY */
1642
#endif /* FIX_BROKEN_TASKS_QUERY */
1558
1643
1559
  for (l = client->priv->task_sources; l; l = l->next)
1644
  for (l = client->priv->task_sources; l; l = l->next)
1560
    calendar_client_start_query (client, l->data, query);
1645
    {
1646
      CalendarClientSource *cs = l->data;
1647
1648
      if (e_cal_get_load_state (cs->source) != E_CAL_LOAD_LOADED)  
1649
        continue;
1650
1651
      calendar_client_start_query (client, cs, query);
1652
    }
1561
1653
1562
#ifdef FIX_BROKEN_TASKS_QUERY
1654
#ifdef FIX_BROKEN_TASKS_QUERY
1563
  g_free (day_begin);
1655
  g_free (day_begin);
Lines 1571-1578 calendar_client_source_finalize (Calenda Link Here
1571
{
1663
{
1572
  source->client = NULL;
1664
  source->client = NULL;
1573
1665
1574
  if (source->source)
1666
  if (source->source) {
1667
    g_signal_handlers_disconnect_by_func (source->source,
1668
                                          cal_opened_cb, source);
1575
    g_object_unref (source->source);
1669
    g_object_unref (source->source);
1670
  }
1576
  source->source = NULL;
1671
  source->source = NULL;
1577
1672
1578
  calendar_client_query_finalize (&source->completed_query);
1673
  calendar_client_query_finalize (&source->completed_query);
Lines 1661-1666 calendar_client_appointment_sources_chan Link Here
1661
					 esources,
1756
					 esources,
1662
					 signals [APPOINTMENTS_CHANGED]);
1757
					 signals [APPOINTMENTS_CHANGED]);
1663
1758
1759
  load_calendars (client, CALENDAR_EVENT_APPOINTMENT);
1664
  calendar_client_update_appointments (client);
1760
  calendar_client_update_appointments (client);
1665
}
1761
}
1666
1762
Lines 1679-1684 calendar_client_task_sources_changed (Ca Link Here
1679
					 esources,
1775
					 esources,
1680
					 signals [TASKS_CHANGED]);
1776
					 signals [TASKS_CHANGED]);
1681
1777
1778
  load_calendars (client, CALENDAR_EVENT_TASK);
1682
  calendar_client_update_tasks (client);
1779
  calendar_client_update_tasks (client);
1683
}
1780
}
1684
1781

Return to bug 412719