char * evo_cal_source_get_uid(ECal *ecal) { ESource *source = NULL; const char *uid = NULL; source = e_cal_get_source(ecal); if (source) uid = e_source_peek_uid(source); if (uid) return g_strdup(uid); return NULL; }
static void annum_shell_view_user_created_cb (AnnumShellView * self, ECalendarView * calendar_view) { AnnumShellSidebar *annum_sidebar; ECalModel *model; ECal *client; ESource *source; model = e_calendar_view_get_model (calendar_view); client = e_cal_model_get_default_client (model); source = e_cal_get_source (client); annum_sidebar = self->priv->prox_shell_sidebar; annum_shell_sidebar_add_source (annum_sidebar, source); }
static char * auth_func_cb (ECal *ecal, const char *prompt, const char *key, gpointer user_data) { ESource *source; const gchar *auth_domain; const gchar *component_name; source = e_cal_get_source (ecal); auth_domain = e_source_get_property (source, "auth-domain"); component_name = auth_domain ? auth_domain : "Calendar"; return e_passwords_get_password (component_name, key); }
static inline void debug_dump_ecal_list (GSList *ecal_list) { #ifdef CALENDAR_ENABLE_DEBUG GSList *l; dprintf ("Loaded clients:\n"); for (l = ecal_list; l; l = l->next) { ECal *client = l->data; ESource *source = e_cal_get_source (client); dprintf (" %s %s %s\n", e_source_peek_uid (source), e_source_peek_name (source), e_cal_get_uri (client)); } #endif }
static void backend_died_cb (ECal *client, CalendarSourceData *source_data) { ESource *source; const char *display_name; source = e_cal_get_source (client); display_name = e_source_get_display_name (source); g_warning ("The calendar backend for '%s' has crashed.", display_name); g_hash_table_remove (source_data->clients, source); if (source_data->timeout_id != 0) { g_source_remove (source_data->timeout_id); source_data->timeout_id = 0; } source_data->timeout_id = g_timeout_add_seconds (2, backend_restart, source_data); }
/* 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; }
void dates_autoselect_calendars (DatesData *d, ESourceList * cal_list) { GSList *selected_list; if (!cal_list) return; selected_list = gconf_client_get_list (gconf_client_get_default (), CALENDAR_GCONF_SELECTED, GCONF_VALUE_STRING, NULL); if (!selected_list) { /* select all available calendars */ GSList *list = NULL, *groups, *g; groups = e_source_list_peek_groups (cal_list); #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Attempting to autoselect"); #endif for (g = groups; g; g = g->next) { GSList *sources, *s; sources = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); for (s = sources; s; s = s->next) { ESource *source = E_SOURCE (s->data); ECal *ecal; gchar * uid; ecal = dates_load_esource (source, E_CAL_SOURCE_TYPE_EVENT, NULL, d); if (!ecal) { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("No ecal"); #endif continue; } uid = (gchar *)e_source_peek_uid (e_cal_get_source (ecal)); list = g_slist_prepend (list, uid); } } if (list) { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Setting new list"); #endif gconf_client_set_list (gconf_client_get_default (), CALENDAR_GCONF_SELECTED, GCONF_VALUE_STRING, list, NULL); } } else #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Have selected list"); #endif }
/* 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; }
void dates_cal_open_cb (ECal *ecal, ECalendarStatus status, DatesData *d) { gboolean read_only; GError *error = NULL; const char *ecal_name; ESource *source; ESourceGroup *group; GtkTreeIter iter; gchar *primary_uid; GSList *selected_list; gboolean selected; gchar * cal_name; #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Calendar opened, setting up..."); #endif if (status != E_CALENDAR_STATUS_OK) { g_warning ("Error '%d' opening ecal", status); g_object_unref (ecal); if (d->first_load) { GtkWidget *dialog = gtk_message_dialog_new ( GTK_WINDOW (d->main_window), GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Dates failed to open the system calendar. " "You will not be able to view or create " "events; this may be remedied by restarting.")); gtk_dialog_run (GTK_DIALOG (dialog)); } return; } source = e_cal_get_source (ecal); ecal_name = e_source_peek_name (source); if (!e_cal_is_read_only (ecal, &read_only, &error)) { g_warning ("Error querying calendar's read-only status: %s", error->message); g_error_free (error); g_object_unref (ecal); return; } /* * Work around the fact that eds-dbus seems to be returning the wrong * value for e_cal_is_read_only on the calendar itself for the http * backend. But on the events themselves it is fine */ group = e_source_peek_group (source); if (strncmp (e_source_group_peek_base_uri (group), "webcal://", 9) == 0) read_only = TRUE; selected_list = gconf_client_get_list (gconf_client_get_default (), CALENDAR_GCONF_SELECTED, GCONF_VALUE_STRING, NULL); #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("selected_list %p: is in uids %d", selected_list, is_in_uids (selected_list, source)); #endif if (selected_list && is_in_uids (selected_list, source)) { dates_view_add_calendar (d->view, ecal); g_signal_connect (G_OBJECT (ecal), "backend_died", G_CALLBACK (dates_backend_died_cb), d); selected = TRUE; } else { selected = FALSE; } if ((!read_only) && (selected)) { if (!d->dcal) d->dcal = ecal; else { /* Find out if it's the default calendar */ primary_uid = gconf_client_get_string ( gconf_client_get_default (), CALENDAR_GCONF_PRIMARY, NULL); if (primary_uid) { if (strcmp (e_source_peek_uid (source), primary_uid) == 0) d->dcal = ecal; g_free (primary_uid); } } d->cal_loaded = TRUE; if (d->TBNew) { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("*** Setting TBNew button sensitive ***"); #endif gtk_widget_set_sensitive (d->TBNew, TRUE); } } else { #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("*** RO %d, Selected %d ***", read_only, selected); #endif } if (ecal_name && !read_only) cal_name = g_strdup (ecal_name); else if (ecal_name) cal_name = g_strconcat (ecal_name, _(" (Read Only)"), NULL); else if (!read_only) cal_name = g_strdup (_("Unknown")); else cal_name = g_strconcat (_("Unknown"), _(" (Read Only)"), NULL); gtk_list_store_insert_with_values (d->cal_list_store, &iter, G_MAXINT, COL_CALNAME, cal_name, COL_CALPTR, ecal, COL_NOTREADONLY, !read_only, COL_SELECTED, selected, -1); g_free (cal_name); #ifdef DEBUG if (d->debug & DATES_DEBUG_CALENDAR) g_debug ("Calendar added."); #endif dates_platform_cal_open (d); }