示例#1
0
/* The clients are just created here but not loaded */
static void
create_client_for_source (ESource            *source,
		          ECalSourceType      source_type,
		          CalendarSourceData *source_data)
{
  ClientData *data;
  ECal *client;

  client = g_hash_table_lookup (source_data->clients, source);
  g_return_if_fail (client == NULL);

  client = e_cal_new (source, source_type);
  if (!client)
    {
      g_warning ("Could not load source '%s'\n",
		 e_source_get_uid (source));
      return;
    }

  data = g_slice_new0 (ClientData);
  data->client = client;  /* takes ownership */
  data->backend_died_id = g_signal_connect (client,
                                            "backend-died",
                                            G_CALLBACK (backend_died_cb),
                                            source_data);

  g_hash_table_insert (source_data->clients, g_object_ref (source), data);
}
示例#2
0
ECal *
evo_cal_source_open_new_with_absolute_uri(const char *name, const char *uri, ECalSourceType type)
{
    ESource *source = NULL;
    ECal *cal = NULL;
    GError *gerror = NULL;

    g_debug("Opening new calendar source uri: %s\n", uri);
        
    source = e_source_new_with_absolute_uri(name, uri); 

    if (!source) {
        g_warning("Unable to open source for calendar (type %u)", type);
        return NULL;
    }

    cal = e_cal_new(source, type);
    if(!cal) {
        g_warning("Failed to create new calendar (type %u)", type);
        return NULL;
    }

    if(!e_cal_open(cal, FALSE, &gerror)) {
        g_warning("Failed to open calendar (type %u): %s", type,
                  gerror && gerror->message ? gerror->message : "None");
        g_object_unref(cal);
        g_clear_error(&gerror);
        return NULL;
    }

    return cal;
}
示例#3
0
static int
start_calendar_server (EMemoConduitContext *ctxt)
{
	g_return_val_if_fail (ctxt != NULL, -2);

	if (ctxt->cfg->source) {
		ctxt->client = e_cal_new (ctxt->cfg->source, E_CAL_SOURCE_TYPE_JOURNAL);
		if (!e_cal_open (ctxt->client, TRUE, NULL))
			return -1;
	} else if (!e_cal_open_default (&ctxt->client, E_CAL_SOURCE_TYPE_JOURNAL, NULL, NULL, NULL)) {
		return -1;
	}

	return 0;
}
示例#4
0
ECal *
evo_cal_source_open_source(const char *uri, ECalSourceType type)
{
	ESourceList *sources = NULL;
	ESource *source = NULL;
    ECal *cal = NULL;
	GError *gerror = NULL;

    g_debug("Opening calendar source uri: %s\n", uri);

	if (strcmp(uri, "default")) {
	  	if (!e_cal_get_sources(&sources, type, &gerror)) {
                    g_warning("Unable to get sources for calendar (type %u): %s",
                              type, gerror && gerror->message ? gerror->message : "None");
			g_clear_error(&gerror);
			return NULL;
		}
		
		source = evo_environment_find_source(sources, uri);
		if (!source) {
	  		g_warning("Unable to find source for calendar (type %u)", type);
			return NULL;
		}
		
		cal = e_cal_new(source, type);
		if(!cal) {
	  		g_warning("Failed to create new calendar (type %u)", type);
			return NULL;
		}
		
		if(!e_cal_open(cal, FALSE, &gerror)) {
	  		g_warning("Failed to open calendar (type %u): %s",
                      type, gerror && gerror->message? gerror->message : "None");
			g_object_unref(cal);
			g_clear_error(&gerror);
			return NULL;
		}
	} else {
		if (!e_cal_open_default (&cal, type, NULL, NULL, &gerror)) {
	  		g_warning("Failed to open default calendar: %s",
                      gerror && gerror->message ? gerror->message : "None");
			g_clear_error(&gerror);
			return NULL;
		}
	}
	
	return cal;
}
示例#5
0
/* The clients are just created here but not loaded */
static ECal *
get_ecal_from_source (ESource        *esource,
		      ECalSourceType  source_type,
		      GSList         *existing_clients)
{
  ECal *retval;

  if (existing_clients)
    {
      GSList *l;

      for (l = existing_clients; l; l = l->next)
	{
	  ECal *client = E_CAL (l->data);

	  if (e_source_equal (esource, e_cal_get_source (client)))
	    {
	      dprintf ("        load_esource: found existing source ... returning that\n");

	      return g_object_ref (client);
	    }
	}
    }

  retval = e_cal_new (esource, source_type);
  if (!retval)
    {
      g_warning ("Could not load source '%s' from '%s'\n",
		 e_source_peek_name (esource),
		 e_source_peek_relative_uri (esource));
      return NULL;
    }

  e_cal_set_auth_func (retval, auth_func_cb, NULL);

  return retval;
}
示例#6
0
/* The following function taken from gnome clock-applet
 * (gnome-panel/applets/clock/calendar-sources.c)
 */
ECal *
dates_load_esource (ESource        *esource,
	      ECalSourceType  source_type,
	      GSList         *existing_clients,
	      DatesData      *d)
{
    ECal   *retval;
    GError *error;


    if (existing_clients)
    {
	GSList *l;

	for (l = existing_clients; l; l = l->next)
	{
	    ECal *client = E_CAL (l->data);

	    if (e_source_equal (esource, e_cal_get_source (client)))
	    {
#ifdef DEBUG
		if (d->debug & DATES_DEBUG_CALENDAR)
		    g_debug ("load_esource: found existing source, returning that");
#endif
		return g_object_ref (client);
	    }
	}
    }

    retval = e_cal_new (esource, source_type);
    if (!retval)
    {
	g_warning ("Could not load source '%s' from '%s'\n",
		   e_source_peek_name (esource),
		   e_source_get_uri (esource));
	return NULL;
    }

    error = NULL;
    if (!e_cal_open (retval, FALSE, &error))
    {
	g_assert (error != NULL);
	g_warning ("Cannot open calendar from uri '%s': %s\n",
		   e_cal_get_uri (retval), error->message);
	g_error_free (error);
	g_object_unref (retval);
	return NULL;
    }
#ifdef DEBUG
    if (d->debug & DATES_DEBUG_CALENDAR)
	g_debug ("Loaded calendar from uri '%s'",
		 e_cal_get_uri (retval));
#endif

    /* 
     * Set the calendar mode to CAL_MODE_REMOTE. This is necessary to get the
     * remote (webcal) calendars to work. It doesn't seem to have any effect
     * on the file backend.
     */
    e_cal_set_mode (retval, CAL_MODE_REMOTE);

    return retval;
}