Example #1
0
static void
ecal_objects_removed (ECalView *ecalview, GList *uids,
					  DatesNavigatorModel * nav)
{
	ECal *ecal = e_cal_view_get_client (ecalview);
	GtkTreeIter iter;
	GtkListStore * store =
		GTK_LIST_STORE (gtk_tree_model_filter_get_model (
							GTK_TREE_MODEL_FILTER (nav)));

	for (; uids; uids = uids->next)
	{
		gchar *uri_uid;
		
#ifdef HAVE_CID_TYPE
		ECalComponentId *id = uids->data;
		uri_uid = g_strconcat (e_cal_get_uri (ecal), id->uid, NULL);
#else
		uri_uid = g_strconcat (e_cal_get_uri (ecal), uids->data, NULL);
#endif
		if (find_item (store, uri_uid, &iter))
			gtk_list_store_remove (store, &iter);

		g_free (uri_uid);
	}
}
Example #2
0
void
dates_calendar_combo_changed_cb (GtkComboBox *widget, DatesData *d)
{
    ECal *c;
    ECalComponent *comp = d->comp;
    GtkTreeIter iter;
	
    if (!gtk_combo_box_get_active_iter (widget, &iter)) return;
    gtk_tree_model_get (gtk_combo_box_get_model (widget),
			&iter, COL_CALPTR, &c, -1);
	
    if (c != d->cal) {
	/* Move event between calendars */
	const char *uid = NULL;
		
	g_object_ref (comp);
	if (!d->waiting)
	    d->waiting = PENDING_CAL_CHANGE;
	e_cal_component_get_uid (comp, &uid);
	e_cal_remove_object (d->cal, uid, NULL);
		
	/* TODO: Error checking */
	e_cal_create_object (c,
			     e_cal_component_get_icalcomponent (comp),
			     (char **)&uid, NULL);
	g_object_unref (comp);
	d->uri_uid = g_strconcat (e_cal_get_uri (c), uid, NULL);
	d->widgets = contacts_set_widgets_desensitive (d->details_dialog);
	g_idle_add (dates_select_event_idle_cb, d);
    }
}
Example #3
0
static void
check_for_slow_setting (GnomePilotConduit *c, EMemoConduitContext *ctxt)
{
	GnomePilotConduitStandard *conduit = GNOME_PILOT_CONDUIT_STANDARD (c);
	int map_count;
	const char *uri;

	/* If there are no objects or objects but no log */
	map_count = g_hash_table_size (ctxt->map->pid_map);
	if (map_count == 0)
		gnome_pilot_conduit_standard_set_slow (conduit, TRUE);

	/* Or if the URI's don't match */
	uri = e_cal_get_uri (ctxt->client);
	LOG (g_message ( "  Current URI %s (%s)\n", uri, ctxt->cfg->last_uri ? ctxt->cfg->last_uri : "<NONE>" ));
	if (ctxt->cfg->last_uri != NULL && (strcmp (ctxt->cfg->last_uri, uri) != 0)) {
		gnome_pilot_conduit_standard_set_slow (conduit, TRUE);
		e_pilot_map_clear (ctxt->map);
	}

	if (gnome_pilot_conduit_standard_get_slow (conduit)) {
		ctxt->map->write_touched_only = TRUE;
		LOG (g_message ( "    doing slow sync\n" ));
	} else {
		LOG (g_message ( "    doing fast sync\n" ));
	}
}
Example #4
0
static void
ecal_objects_changed (ECalView * cview, GList *objects,
					  DatesNavigatorModel * nav)
{
	ECal *ecal = e_cal_view_get_client (cview);
	GtkListStore * store =
		GTK_LIST_STORE (gtk_tree_model_filter_get_model (
							GTK_TREE_MODEL_FILTER (nav)));

	for (; objects; objects = objects->next)
	{
		const char *uid = icalcomponent_get_uid (objects->data);
		gchar *uri_uid;
		GtkTreeIter iter;
		const gchar * summary;
		gchar * s = NULL;
		gchar time[100];
		gchar * folded = NULL;
		
		if (!uid)
			continue;
			
		uri_uid = g_strconcat (e_cal_get_uri (ecal), uid, NULL);

		if (!find_item (store, uri_uid, &iter))
			gtk_list_store_append (store, &iter);

		summary = icalcomponent_get_summary (objects->data);

		if (summary)
			folded = g_utf8_casefold (summary, -1);
		
		/* use only first 15 chars of the summary */
		if (summary && g_utf8_strlen (summary, -1) > 15)
		{
			s = g_strdup (summary);
			gchar * p = g_utf8_offset_to_pointer (s, 15);
			*p = 0;
			summary = s;
		}
		
		event_time (objects->data, (gchar*)&time, sizeof(time),
					nav->priv->format);
		
		gtk_list_store_set (store, &iter,
							DN_Name, summary,
							DN_Time, time,
							DN_Uid, uri_uid,
							DN_NameFolded, folded,
							-1);
		g_free (uri_uid);
		g_free (s);
		g_free (folded);
	}
}
Example #5
0
static gint
post_sync (GnomePilotConduit *conduit,
	   GnomePilotDBInfo *dbi,
	   EMemoConduitContext *ctxt)
{
	GList *changed;
	gchar *filename, *change_id;
	unsigned char *buf;
	int dlpRetVal, len;

	buf = (unsigned char*)g_malloc (0xffff);

	len = pack_MemoAppInfo (&(ctxt->ai), buf, 0xffff);

	dlpRetVal = dlp_WriteAppBlock (dbi->pilot_socket, dbi->db_handle,
			      (unsigned char *)buf, len);

	g_free (buf);

	if (dlpRetVal < 0) {
		WARN (_("Could not write pilot's Memo application block"));
		WARN ("dlp_WriteAppBlock(...) = %d", dlpRetVal);
		gnome_pilot_conduit_error (conduit,
					   _("Could not write pilot's Memo application block"));
		return -1;
	}


	LOG (g_message ( "post_sync: Memo Conduit v.%s", CONDUIT_VERSION ));

	g_free (ctxt->cfg->last_uri);
	ctxt->cfg->last_uri = g_strdup (e_cal_get_uri (ctxt->client));
	memoconduit_save_configuration (ctxt->cfg);

	filename = map_name (ctxt);
	e_pilot_map_write (filename, ctxt->map);
	g_free (filename);

	/* FIX ME ugly hack - our changes musn't count, this does introduce
	 * a race condition if anyone changes a record elsewhere during sycnc
         */
	change_id = g_strdup_printf ("pilot-sync-evolution-memo-%d", ctxt->cfg->pilot_id);
	if (e_cal_get_changes (ctxt->client, change_id, &changed, NULL))
		e_cal_free_change_list (changed);
	g_free (change_id);

	LOG (g_message ( "---------------------------------------------------------\n" ));

	return 0;
}
Example #6
0
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
}
Example #7
0
static void
dates_new (DatesData *d, icalcomponent *comp, gboolean select)
{
    GError *error = NULL;
    char *uid = NULL;

    if (!d->dcal) {
	/* TODO: Prompt to create a new calendar? */
	g_warning ("No calendars loaded");
	return;
    }
	
    if (e_cal_create_object (d->dcal, comp, (char **)&uid, &error)) {
	if (!select) return;
		
	d->event_type = NEW_EVENT;

	/* Bring up details dialog ASAP */
	if (d->comp) g_object_unref (d->comp);
	d->comp = e_cal_component_new ();
	e_cal_component_set_icalcomponent (d->comp, comp);
	dates_fill_details_dialog (d->view, d);
	dates_platform_details_dlg (d, TRUE);

	/* Disable calendar combo-box */
	gtk_widget_set_sensitive (d->details_calendar_combobox, FALSE);

	/* Select new event */
	d->waiting = PENDING_CREATE;
	d->uri_uid = g_strconcat (e_cal_get_uri (d->dcal), uid, NULL);
	g_idle_add (dates_select_event_idle_cb, d);
    } else {
	g_warning ("Failed to create calendar object: %s",
		   error->message);
	icalcomponent_free (comp);
	g_error_free (error);
    }
}
Example #8
0
static void
backend_died_cb (ECal *client, CalendarSourceData *source_data)
{
  const char *uristr;

  source_data->clients = g_slist_remove (source_data->clients, client);
  if (g_slist_length (source_data->clients) < 1) 
    {
      g_slist_free (source_data->clients);
      source_data->clients = NULL;
    }
  uristr = e_cal_get_uri (client);
  g_warning ("The calendar backend for %s has crashed.", uristr);

  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);
}
Example #9
0
void
org_gnome_accept (EPlugin *ep, ECalPopupTargetSelect *target)
{
	GSList *menus = NULL;
	GList *selected;
	int i = 0;
	static int first = 0;
	const char *uri = NULL;
	ECalendarView *cal_view = E_CALENDAR_VIEW (target->target.widget);

	c_view = cal_view;
	selected = e_calendar_view_get_selected_events (cal_view);
	if (selected) {
		ECalendarViewEvent *event = (ECalendarViewEvent *) selected->data;

		uri = e_cal_get_uri (event->comp_data->client);
	} else
		return;

	if (!uri)
		return;

	if (! g_strrstr (uri, "groupwise://"))
		return ;

	/* for translation*/
	if (!first) {
		popup_items[0].label =  _(popup_items[0].label);
	}

	first++;

	for (i = 0; i < sizeof (popup_items) / sizeof (popup_items[0]); i++)
		menus = g_slist_prepend (menus, &popup_items[i]);

	e_popup_add_items (target->target.popup, menus, NULL, popup_free, NULL);
}
Example #10
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;
}