Пример #1
0
GtkWidget *
e_book_file_dummy (EPlugin *epl,
                   EConfigHookItemFactoryData *data)
{
	EABConfigTargetSource *t = (EABConfigTargetSource *) data->target;
	ESource *source = t->source;
	gchar *uri_text;
	const gchar *relative_uri;

	uri_text = e_source_get_uri (source);
	if (strncmp (uri_text, "file", 4)) {
		g_free (uri_text);

		return NULL;
	}

	relative_uri = e_source_peek_relative_uri (source);
	g_free (uri_text);

	if (relative_uri && *relative_uri) {
		return NULL;
	}

	e_source_set_relative_uri (source, e_source_peek_uid (source));

	return NULL;
}
Пример #2
0
static void
location_clicked (GtkButton * button, ESource * source)
{
    GtkDialog *dialog;
    char *ruri_save;
    const char *ruri;
    int resp;

    dialog = create_store_view_dialog (source);

    if (dialog == NULL)
        return;

    ruri_save = (char *) e_source_peek_relative_uri (source);

    if (ruri_save != NULL) {
        ruri_save = g_strdup (ruri_save);
    }

    resp = gtk_dialog_run (dialog);

    if (resp == GTK_RESPONSE_OK) {
        char *nruri = NULL;

        ruri = e_source_peek_relative_uri (source);

        if (is_toplevel (ruri)) {
            ruri = _("Toplevel");
        } else {
            char *match;

            match = g_strrstr (ruri, "/");
            nruri = g_strndup (ruri, match - ruri);
            ruri = nruri;
        }

        gtk_button_set_label (button, ruri);

        g_free (nruri);

    } else {
        e_source_set_relative_uri (source, ruri_save);
    }

    g_free (ruri_save);
    gtk_widget_destroy (GTK_WIDGET (dialog));
}
Пример #3
0
static void
unsubscribe_dialog_response (GtkDialog *dialog, int response, gpointer data)
{

	if (response == GTK_RESPONSE_OK) {
		GSList *ids, *node_to_be_deleted;
		ExchangeAccount *account = NULL;
		gchar *path = NULL;
		gchar *ruri = NULL;
		const char *source_uid = NULL;
		GConfClient *client;
		ESourceGroup *source_group = NULL;
		ESource *source = NULL;
		ECalPopupTargetSource *target = data;

		client = gconf_client_get_default ();

		account = exchange_operations_get_exchange_account ();

		if (!account)
			return;

		source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (target->selector));
		ruri = (gchar *) e_source_peek_relative_uri (source);
		source_uid = e_source_peek_uid (source);

		path = g_strdup (ruri + strlen (account->account_filename));
		exchange_account_remove_shared_folder (account, path);
		ids = gconf_client_get_list (client,
					     CONF_KEY_SELECTED_CAL_SOURCES,
					     GCONF_VALUE_STRING, NULL);
		if (ids) {
			node_to_be_deleted = g_slist_find_custom (
						ids,
						source_uid,
						(GCompareFunc) strcmp);
			if (node_to_be_deleted) {
				g_free (node_to_be_deleted->data);
				ids = g_slist_delete_link (ids,
						node_to_be_deleted);
				gconf_client_set_list (client,
					CONF_KEY_SELECTED_CAL_SOURCES,
					GCONF_VALUE_STRING, ids, NULL);
			}
			g_slist_foreach (ids, (GFunc) g_free, NULL);
			g_slist_free (ids);
		}

		source_group = e_source_peek_group (source);
		e_source_group_remove_source_by_uid (source_group, source_uid);
		g_free (path);
		gtk_widget_destroy (GTK_WIDGET (dialog));
	}
	if (response == GTK_RESPONSE_CANCEL)
		gtk_widget_destroy (GTK_WIDGET (dialog));
	if (response == GTK_RESPONSE_DELETE_EVENT)
		gtk_widget_destroy (GTK_WIDGET (dialog));
}
Пример #4
0
static void
sn_changed (ESource * source, gpointer data)
{
    const char *name;
    const char *ruri;

    //char       **old_name;
    char **sv;
    char *nruri;
    guint n;
    gulong *sig_id;

    sig_id = (gulong *) data;
    name = e_source_peek_name (source);
    ruri = e_source_peek_relative_uri (source);

    /* Must block signal emission or this will give
     * a nice infinit chain and stack overflow */
    g_signal_handler_block (source, *sig_id);

    if (is_toplevel (ruri)) {
        e_source_set_relative_uri (source, name);
    } else {
        sv = g_strsplit (ruri, "/", -1);
        n = g_strv_length (sv);

        if (n < 2) {
            g_print ("Error during split! (%s)\n", ruri);
            g_strfreev (sv);
            return;
        }

        g_free (sv[n - 1]);
        sv[n - 1] = g_strdup (name);

        nruri = g_strjoinv ("/", sv);
        e_source_set_relative_uri (source, nruri);
        g_free (nruri);
        g_strfreev (sv);
    }

    g_signal_handler_unblock (source, *sig_id);

    g_print ("RURI: %s\n", e_source_peek_relative_uri (source));
}
Пример #5
0
static gboolean is_new_calendar_dialog(ESource *source)
{
    gboolean is_new = FALSE;
    const char *rel_uri = e_source_peek_relative_uri(source);

    // if ESource does not have relative_uri, dialog is for creating new calendar,
    // first time this function is called on given ESource, it's result must be
    // stored in ESource, because relative_uri may be modified and we still want
    // to determine if dialog is for new or existing calendar
    is_new = rel_uri == NULL || strlen(rel_uri) == 0 || g_object_get_data(G_OBJECT(source), "is_new");

    if (is_new)
    {
        g_object_set_data(G_OBJECT(source), "is_new", GUINT_TO_POINTER(1));
    }

    return is_new;
}
Пример #6
0
static void
dump_source (ESource *source)
{
	gchar *uri = e_source_get_uri (source);
	const gchar *color_spec;

	g_print ("\tSource %s\n", e_source_peek_uid (source));
	g_print ("\t\tname: %s\n", e_source_peek_name (source));
	g_print ("\t\trelative_uri: %s\n", e_source_peek_relative_uri (source));
	g_print ("\t\tabsolute_uri: %s\n", uri);

	color_spec = e_source_peek_color_spec (source);
	if (color_spec != NULL)
		g_print ("\t\tcolor: %s\n", color_spec);

	g_print ("\t\tproperties:\n");
	e_source_foreach_property (source, (GHFunc) dump_property, NULL);

	g_free (uri);
}
Пример #7
0
void
org_gnome_exchange_check_subscribed (EPlugin *ep, ECalPopupTargetSource *target)
{
	GSList *menus = NULL;
	int i = 0;
	ESource *source = NULL;
	gchar *ruri = NULL;
	gchar *path = NULL;
	char *sub_folder = NULL;
	const char *base_uri;
	ExchangeAccount *account = NULL;
	ESourceGroup *group;

	account = exchange_operations_get_exchange_account ();

	if (!account)
		return;

	source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (target->selector));
	group = e_source_peek_group (source);
	base_uri = e_source_group_peek_base_uri (group);
	if (!base_uri || strcmp (base_uri, "exchange://"))
		return;

	ruri = (gchar *) e_source_peek_relative_uri (source);
	path = g_strdup (ruri + strlen (account->account_filename) + strlen ("/;"));
	sub_folder = strchr (path, '@');

	if (!sub_folder) {
		g_free (path);
		return;
	}

	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, target);
	g_free (path);
}
Пример #8
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;
}
Пример #9
0
static void
ensure_sources (MemosComponent *component)
{
	GSList *groups;
	ESourceList *source_list;
	ESourceGroup *group;
	ESourceGroup *on_this_computer;
	ESourceGroup *on_the_web;
	ESource *personal_source;
	char *base_uri, *base_uri_proto;
	const gchar *base_dir;

	on_this_computer = NULL;
	on_the_web = NULL;
	personal_source = NULL;

	if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL)) {
		g_warning ("Could not get memo source list from GConf!");
		return;
	}

	base_dir = memos_component_peek_base_directory (component);
	base_uri = g_build_filename (base_dir, "local", NULL);

	base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL);

	groups = e_source_list_peek_groups (source_list);
	if (groups) {
		/* groups are already there, we need to search for things... */
		GSList *g;

		for (g = groups; g; g = g->next) {

			group = E_SOURCE_GROUP (g->data);

			/* compare only file:// part. If user home dir name changes we do not want to create
			   one more group  */

			if (!on_this_computer && !strncmp (base_uri_proto, e_source_group_peek_base_uri (group), 7))
				on_this_computer = group;
			else if (!on_the_web && !strcmp (WEB_BASE_URI, e_source_group_peek_base_uri (group)))
				on_the_web = group;
		}
	}

	if (on_this_computer) {
		/* make sure "Personal" shows up as a source under
		   this group */
		GSList *sources = e_source_group_peek_sources (on_this_computer);
		GSList *s;
		for (s = sources; s; s = s->next) {
			ESource *source = E_SOURCE (s->data);
			const gchar *relative_uri;

			relative_uri = e_source_peek_relative_uri (source);
			if (relative_uri == NULL)
				continue;
			if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
				personal_source = source;
				break;
			}
		}
		/* Make sure we have the correct base uri. This can change when user's
		   homedir name changes */
		if (strcmp (base_uri_proto, e_source_group_peek_base_uri (on_this_computer))) {
		    e_source_group_set_base_uri (on_this_computer, base_uri_proto);

		    /* *sigh* . We shouldn't  need this sync call here as set_base_uri
		       call results in synching to gconf, but that happens in idle loop
		       and too late to prevent user seeing "Can not Open ... because of invalid uri" error.*/
		    e_source_list_sync (source_list,NULL);
		}
	}
	else {
		/* create the local source group */
		group = e_source_group_new (_("On This Computer"), base_uri_proto);
		e_source_list_add_group (source_list, group, -1);

		on_this_computer = group;
	}

	if (!personal_source) {
		GSList *memos_selected;
		/* Create the default Person addressbook */
		ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
		e_source_group_add_source (on_this_computer, source, -1);

		memos_selected = calendar_config_get_memos_selected ();

		if (!calendar_config_get_primary_memos () && !memos_selected) {
			GSList selected;

			calendar_config_set_primary_memos (e_source_peek_uid (source));

			selected.data = (gpointer)e_source_peek_uid (source);
			selected.next = NULL;
			calendar_config_set_memos_selected (&selected);
		}

		if (memos_selected) {
			g_slist_foreach (memos_selected, (GFunc) g_free, NULL);
			g_slist_free (memos_selected);
		}

		e_source_set_color_spec (source, "#BECEDD");
		personal_source = source;
	}

	if (!on_the_web) {
		/* Create the LDAP source group */
		group = e_source_group_new (_("On The Web"), WEB_BASE_URI);
		e_source_list_add_group (source_list, group, -1);

		on_the_web = group;
	}

	component->priv->source_list = source_list;
	g_free (base_uri_proto);
	g_free (base_uri);
}
Пример #10
0
static void
calendar_sources_load_esource_list (CalendarSourceData *source_data)
{
  GSList  *clients = NULL;
  GSList  *groups, *l;
  gboolean emit_signal = FALSE;

  g_return_if_fail (source_data->esource_list != NULL);

  debug_dump_selected_sources (source_data->selected_sources);

  dprintf ("Source groups:\n");
  groups = e_source_list_peek_groups (source_data->esource_list);
  for (l = groups; l; l = l->next)
    {
      GSList *esources, *s;

      dprintf ("  %s\n", e_source_group_peek_uid (l->data));
      dprintf ("    sources:\n");

      esources = e_source_group_peek_sources (l->data);
      for (s = esources; s; s = s->next)
	{
	  ESource *esource = E_SOURCE (s->data);
	  ECal    *client;

	  dprintf ("      type = '%s' uid = '%s', name = '%s', relative uri = '%s': \n",
                   source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task",
		   e_source_peek_uid (esource),
		   e_source_peek_name (esource),
		   e_source_peek_relative_uri (esource));

	  if (is_source_selected (esource, source_data->selected_sources) &&
	      (client = get_ecal_from_source (esource, source_data->source_type, source_data->clients)))
	    {
	      clients = g_slist_prepend (clients, client);
	    }
	}
    }
  dprintf ("\n");

  if (source_data->loaded && 
      !compare_ecal_lists (source_data->clients, clients))
    emit_signal = TRUE;

  for (l = source_data->clients; l; l = l->next)
    {
      g_signal_handlers_disconnect_by_func (G_OBJECT (l->data),
                                            G_CALLBACK (backend_died_cb),
                                            source_data);

      g_object_unref (l->data);
    }
  g_slist_free (source_data->clients);
  source_data->clients = g_slist_reverse (clients);

  /* connect to backend_died after we disconnected the previous signal
   * handlers. If we do it before, we'll lose some handlers (for clients that
   * were already there before) */
  for (l = source_data->clients; l; l = l->next)
    {
      g_signal_connect (G_OBJECT (l->data), "backend_died",
                        G_CALLBACK (backend_died_cb), source_data);
    }

  if (emit_signal) 
    {
      dprintf ("Emitting %s-sources-changed signal\n",
	       source_data->source_type == E_CAL_SOURCE_TYPE_EVENT ? "appointment" : "task");
      g_signal_emit (source_data->sources, source_data->changed_signal, 0);
    }

  debug_dump_ecal_list (source_data->clients);
}
Пример #11
0
static GtkWidget *
sx_config_source_setup_ui (GtkWidget * parent, ESource * source)
{
    GtkWidget *button;
    GtkWidget *label;
    GtkWidget *text;
    GtkWidget *ret;
    char *uri_text;
    const char *uid;
    const char *ruri;
    const char *name;
    gboolean new_source;
    gulong *sig_id;

    uri_text = e_source_get_uri (source);

    if (!g_str_has_prefix (uri_text, "scalix")) {
        g_free (uri_text);
        return NULL;
    }
    g_free (uri_text);

    g_assert (GTK_IS_BOX (parent) || GTK_IS_TABLE (parent));

    /* Label */
    label = gtk_label_new_with_mnemonic (_("_Location:"));
    gtk_widget_show (label);

    gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);

    button = gtk_button_new ();

    g_signal_connect (G_OBJECT (button),
                      "clicked", G_CALLBACK (location_clicked), source);

    gtk_widget_show (button);

    uid = e_source_peek_uid (source);
    ruri = e_source_peek_relative_uri (source);
    name = e_source_peek_name (source);

    /* new source */
    new_source = (ruri == NULL || ruri[0] == '\0' || g_str_equal (ruri, uid));

    if (new_source) {

        if (name == NULL || name[0] == '\0')
            name = "nonameyet";

        e_source_set_relative_uri (source, name);
    }

    if (is_toplevel (ruri)) {
        text = gtk_label_new (_("Toplevel"));
    } else {
        text = gtk_label_new (ruri);
    }

    gtk_widget_show (text);

#if (GTK_CHECK_VERSION(2, 6, 0))
    gtk_label_set_ellipsize (GTK_LABEL (text), PANGO_ELLIPSIZE_START);
#endif
    gtk_container_add (GTK_CONTAINER (button), text);

    sig_id = (gulong *) g_malloc0 (sizeof (gulong));

    *sig_id = g_signal_connect (source,
                                "changed", G_CALLBACK (sn_changed), sig_id);

    /* We do not support renames (yet?!) */
    if (new_source == FALSE) {

        gtk_widget_set_sensitive (button, FALSE);

        /* Nasty nasty hack ey ey ey */
        find_entries_and_set_sensitive (parent, FALSE);

    }

    /* attach it */
    if (!GTK_IS_BOX (parent)) {
        int row;

        row = GTK_TABLE (parent)->nrows;

        gtk_table_attach (GTK_TABLE (parent),
                          label, 0, 1, row, row + 1, GTK_FILL, 0, 0, 0);

        gtk_table_attach (GTK_TABLE (parent),
                          button, 1, 2,
                          row, row + 1, GTK_EXPAND | GTK_FILL, 0, 0, 0);

        /* HACK for to have a return value != NULL */
        ret = button;

    } else {
        GtkWidget *hbox;

        hbox = gtk_hbox_new (FALSE, 6);
        gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 6);
        gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 6);
        gtk_box_pack_start (GTK_BOX (parent), hbox, FALSE, FALSE, 6);
        gtk_widget_show_all (hbox);
        ret = hbox;
    }

    return ret;
}
Пример #12
0
static void
create_memo_sources (EShellBackend *shell_backend,
                     ESourceList *source_list,
                     ESourceGroup **on_this_computer,
                     ESourceGroup **on_the_web,
                     ESource **personal_source)
{
	EShell *shell;
	EShellSettings *shell_settings;
	GSList *groups;
	ESourceGroup *group;

	*on_this_computer = NULL;
	*on_the_web = NULL;
	*personal_source = NULL;

	shell = e_shell_backend_get_shell (shell_backend);
	shell_settings = e_shell_get_shell_settings (shell);

	groups = e_source_list_peek_groups (source_list);
	if (groups) {
		/* groups are already there, we need to search for things... */
		GSList *g;
		gchar *base_dir, *base_uri;

		base_dir = g_build_filename (e_shell_backend_get_data_dir (shell_backend), "local", NULL);
		base_uri = g_filename_to_uri (base_dir, NULL, NULL);

		for (g = groups; g; g = g->next) {
			group = E_SOURCE_GROUP (g->data);

			if (strcmp (base_uri, e_source_group_peek_base_uri (group)) == 0)
				e_source_group_set_base_uri (group, LOCAL_BASE_URI);

			if (!*on_this_computer && !strcmp (LOCAL_BASE_URI, e_source_group_peek_base_uri (group)))
				*on_this_computer = g_object_ref (group);
			else if (!*on_the_web && !strcmp (WEBCAL_BASE_URI, e_source_group_peek_base_uri (group)))
				*on_the_web = g_object_ref (group);
		}

		g_free (base_dir);
		g_free (base_uri);
	}

	if (*on_this_computer) {
		/* make sure "Personal" shows up as a source under
		 * this group */
		GSList *sources = e_source_group_peek_sources (*on_this_computer);
		GSList *s;
		for (s = sources; s; s = s->next) {
			ESource *source = E_SOURCE (s->data);
			const gchar *relative_uri;

			relative_uri = e_source_peek_relative_uri (source);
			if (relative_uri == NULL)
				continue;
			if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) {
				*personal_source = g_object_ref (source);
				break;
			}
		}
	} else {
		/* create the local source group */
		group = e_source_group_new (_("On This Computer"), LOCAL_BASE_URI);
		e_source_list_add_group (source_list, group, -1);

		*on_this_computer = group;
	}

	if (!*personal_source) {
		GSList *selected;
		gchar *primary_memo_list;

		/* Create the default Person memo list */
		ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI);
		e_source_group_add_source (*on_this_computer, source, -1);

		primary_memo_list = e_shell_settings_get_string (
			shell_settings, "cal-primary-memo-list");

		selected = e_memo_shell_backend_get_selected_memo_lists (
			E_MEMO_SHELL_BACKEND (shell_backend));

		if (primary_memo_list == NULL && selected == NULL) {
			GSList link;

			e_shell_settings_set_string (
				shell_settings, "cal-primary-memo-list",
				e_source_peek_uid (source));

			link.data = (gpointer) e_source_peek_uid (source);
			link.next = NULL;

			e_memo_shell_backend_set_selected_memo_lists (
				E_MEMO_SHELL_BACKEND (shell_backend), &link);
		}

		g_slist_foreach (selected, (GFunc) g_free, NULL);
		g_slist_free (selected);

		e_source_set_color_spec (source, "#BECEDD");
		*personal_source = source;
	}

	if (!*on_the_web) {
		/* Create the Webcal source group */
		group = e_source_group_new (_("On The Web"), WEBCAL_BASE_URI);
		e_source_list_add_group (source_list, group, -1);

		*on_the_web = group;
	}
}