static GSList *open_ebooks(void)
{
	GError *gerr = NULL;
	ESourceList *src_list;
	GSList *list;
	char *default_src = NULL;
	GSList *ebooks = NULL;

	if (e_book_get_addressbooks(&src_list, &gerr) == FALSE) {
		error("Can't list user's address books: %s", gerr->message);
		g_error_free(gerr);
		return NULL;
	}

	list = e_source_list_peek_groups(src_list);
	while (list != NULL) {
		ESourceGroup *group = E_SOURCE_GROUP(list->data);
		GSList *sources = e_source_group_peek_sources(group);

		ebooks = traverse_sources(ebooks, sources, &default_src);

		list = list->next;
	}

	g_free(default_src);
	g_object_unref(src_list);

	return ebooks;
}
static EAddrConduitCfg *
addrconduit_load_configuration (guint32 pilot_id)
{
	EAddrConduitCfg *c;
	GnomePilotConduitManagement *management;
	GnomePilotConduitConfig *config;
	gchar *address, prefix[256];
	g_snprintf (prefix, 255, "/gnome-pilot.d/e-address-conduit/Pilot_%u/",
		    pilot_id);

	c = g_new0 (EAddrConduitCfg,1);
	g_assert (c != NULL);

	c->pilot_id = pilot_id;
	management = gnome_pilot_conduit_management_new ("e_address_conduit", GNOME_PILOT_CONDUIT_MGMT_ID);
	g_object_ref_sink (management);
	config = gnome_pilot_conduit_config_new (management, pilot_id);
	g_object_ref_sink (config);
	if (!gnome_pilot_conduit_config_is_enabled (config, &c->sync_type))
		c->sync_type = GnomePilotConduitSyncTypeNotSet;
	g_object_unref (config);
	g_object_unref (management);

	/* Custom settings */
	gnome_config_push_prefix (prefix);

	if (!e_book_get_addressbooks (&c->source_list, NULL))
		c->source_list = NULL;
	if (c->source_list) {
		c->source = e_pilot_get_sync_source (c->source_list);
		if (!c->source)
			c->source = e_source_list_peek_source_any (c->source_list);
		if (c->source) {
			g_object_ref (c->source);
		} else {
			g_object_unref (c->source_list);
			c->source_list = NULL;
		}
	}

	c->secret = gnome_config_get_bool ("secret=FALSE");
	address = gnome_config_get_string ("default_address=business");
	if (!strcmp (address, "business"))
		c->default_address = E_CONTACT_ADDRESS_WORK;
	else if (!strcmp (address, "home"))
		c->default_address = E_CONTACT_ADDRESS_HOME;
	else if (!strcmp (address, "other"))
		c->default_address = E_CONTACT_ADDRESS_OTHER;
	g_free (address);
	c->last_uri = gnome_config_get_string ("last_uri");

	gnome_config_pop_prefix ();

	return c;
}
Exemple #3
0
void
gevo_addrbooks_model_populate(GtkTreeModel *model)
{
	ESourceList *addressbooks;
	GError *err = NULL;
	GSList *groups, *g;
	GtkTreeIter iter;
	GtkListStore *list;

	g_return_if_fail(model != NULL);
	g_return_if_fail(GTK_IS_LIST_STORE(model));

	list = GTK_LIST_STORE(model);

	if (!e_book_get_addressbooks(&addressbooks, &err))
	{
		purple_debug_error("evolution",
						 "Unable to fetch list of address books.\n");

		gtk_list_store_append(list, &iter);
		gtk_list_store_set(list, &iter,
						   ADDRBOOK_COLUMN_NAME, _("None"),
						   ADDRBOOK_COLUMN_URI,  NULL,
						   -1);

		return;
	}

	groups = e_source_list_peek_groups(addressbooks);

	if (groups == NULL)
	{
		gtk_list_store_append(list, &iter);
		gtk_list_store_set(list, &iter,
						   ADDRBOOK_COLUMN_NAME, _("None"),
						   ADDRBOOK_COLUMN_URI,  NULL,
						   -1);

		return;
	}

	for (g = groups; g != NULL; g = g->next)
	{
		GSList *sources, *s;

		sources = e_source_group_peek_sources(g->data);

		for (s = sources; s != NULL; s = s->next)
		{
			ESource *source = E_SOURCE(s->data);

			g_object_ref(source);

			gtk_list_store_append(list, &iter);
			gtk_list_store_set(list, &iter,
							   ADDRBOOK_COLUMN_NAME, e_source_peek_name(source),
							   ADDRBOOK_COLUMN_URI,  e_source_get_uri(source),
							   -1);
		}
	}

	g_object_unref(addressbooks);
}
Exemple #4
0
/*
 * Search for a buddy in the Evolution contacts.
 *
 * @param buddy The buddy to search for.
 * @param query An optional query. This function takes ownership of @a query,
 *              so callers must e_book_query_ref() it in advance (to obtain a
 *              second reference) if they want to reuse @a query.
 */
EContact *
gevo_search_buddy_in_contacts(PurpleBuddy *buddy, EBookQuery *query)
{
	ESourceList *addressbooks;
	GError *err = NULL;
	EBookQuery *full_query;
	GSList *groups, *g;
	EContact *result;
	EContactField protocol_field = gevo_prpl_get_field(buddy->account, buddy);

	if (protocol_field == 0)
		return NULL;

	if (query != NULL)
	{
		EBookQuery *queries[2];

		queries[0] = query;
		queries[1] = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, buddy->name);
		if (queries[1] == NULL)
		{
			purple_debug_error("evolution", "Error in creating protocol query\n");
			e_book_query_unref(query);
			return NULL;
		}

		full_query = e_book_query_and(2, queries, TRUE);
	}
	else
	{
		full_query = e_book_query_field_test(protocol_field, E_BOOK_QUERY_IS, buddy->name);
		if (full_query == NULL)
		{
			purple_debug_error("evolution", "Error in creating protocol query\n");
			return NULL;
		}
	}

	if (!e_book_get_addressbooks(&addressbooks, &err))
	{
		purple_debug_error("evolution",
						 "Unable to fetch list of address books.\n");
		e_book_query_unref(full_query);
		if (err != NULL)
			g_error_free(err);
		return NULL;
	}

	groups = e_source_list_peek_groups(addressbooks);
	if (groups == NULL)
	{
		g_object_unref(addressbooks);
		e_book_query_unref(full_query);
		return NULL;
	}

	for (g = groups; g != NULL; g = g->next)
	{
		GSList *sources, *s;
		sources = e_source_group_peek_sources(g->data);
		for (s = sources; s != NULL; s = s->next)
		{
			result = gevo_run_query_in_uri(e_source_get_uri(E_SOURCE(s->data)), full_query);
			if (result != NULL) {
			    g_object_unref(addressbooks);
				e_book_query_unref(full_query);
			    return result;
			}
		}
	}

	g_object_unref(addressbooks);
	e_book_query_unref(full_query);
	return NULL;
}
static void
synch_done (struct account_synch_msg *m)
{

    g_print ("SxAS: Emitting finished signal (%d) [%p]\n",
             m->success, g_thread_self ());

    /* Workaround for broken e_source_list and/or gconf */
    if (m->success) {
        ESourceList *slist;
        ESourceGroup *group;
        const char *group_uid;
        gboolean changed;
        ScalixAccountSynchPrivate *priv;

        changed = FALSE;
        slist = NULL;
        e_cal_get_sources (&slist, E_CAL_SOURCE_TYPE_EVENT, NULL);

        group_uid = e_source_group_peek_uid (m->esg_cals);
        group = e_source_list_peek_group_by_uid (slist, group_uid);

        g_print ("Cal: %s %p\n", group_uid, group);

        if (group == NULL) {
            e_source_list_add_group (slist, m->esg_cals, -1);
        } else {
            char *xml;

            xml = e_source_group_to_xml (m->esg_cals);
            g_print ("Xml: %s\n", xml);
            e_source_group_update_from_xml (group, xml, &changed);
            g_free (xml);
        }

        e_source_list_sync (slist, NULL);
        g_object_unref (slist);

        slist = NULL;
        changed = FALSE;
        e_book_get_addressbooks (&slist, NULL);

        group_uid = e_source_group_peek_uid (m->esg_cnts);
        group = e_source_list_peek_group_by_uid (slist, group_uid);
        g_print ("Cnt: %s %p\n", group_uid, group);

        if (group == NULL) {
            e_source_list_add_group (slist, m->esg_cnts, -1);
        } else {
            char *xml;

            xml = e_source_group_to_xml (m->esg_cnts);
            g_print ("Xml: %s\n", xml);
            e_source_group_update_from_xml (group, xml, &changed);
            g_free (xml);
        }

        e_source_list_sync (slist, NULL);
        g_object_unref (slist);

        priv = SCALIX_ACCOUNT_SYNCH_GET_PRIVATE (m->sxas);

        g_print ("SV: %s\n", m->sversion);

        scalix_account_prefs_set_sversion (priv->account, m->sversion, NULL);

    }

    g_signal_emit (m->sxas, sxas_signals[SAS_SIGNAL_FINISHED], 0, m->success);

    g_print ("SxAS: Emitting done\n");

}