Пример #1
0
static void
enable_folder_tree (GtkWidget *emfb, GtkWidget *emft)
{
	EMFolderView *emfv = (EMFolderView *) emfb;
	CamelURL *selected_curl, *current_curl;
	CamelFolder *selected_folder;
	gchar *uri;

	/* Get the currently displayed folder. */
	uri = mail_tools_folder_to_url (emfv->list->folder);
	current_curl = uri ? camel_url_new (uri, NULL) : NULL;
	g_free (uri);

	/* Get the selected folder in the folder tree. */
	selected_folder = em_folder_tree_get_selected_folder(EM_FOLDER_TREE (emft));
	uri = mail_tools_folder_to_url (selected_folder);

	selected_curl = uri ? camel_url_new (uri, NULL) : NULL;

	if (current_curl && selected_curl && !camel_url_equal (selected_curl, current_curl)) {

		g_signal_emit_by_name (
			emft, "folder-selected", emft, uri,
			selected_folder->full_name, uri, selected_folder->folder_flags);
	}

	gtk_widget_set_sensitive (emft, TRUE);

	camel_url_free (current_curl);
	camel_url_free (selected_curl);
	g_free (uri);
}
void
org_gnome_activesync_commit (EPlugin *epl, EMConfigTargetAccount *target_account)
{
	const gchar *source_url;
	CamelURL *url;

	printf("\n\n\n\n*********************************\n\n\n");
	source_url = e_account_get_string (target_account->MODIFIED_ACCT,
					   E_ACCOUNT_SOURCE_URL);
	if (source_url && source_url[0] != '\0')
		url = camel_url_new (source_url, NULL);
	else
		url = NULL;

	if (url == NULL
	    || strcmp (url->protocol, "eas") != 0) {
		if (url)
			camel_url_free (url);

		return;
	}

	camel_url_free (url);

	return;
}
static void
update_url_account (EAccount *account, e_account_item_t item, const gchar *surl)
{
	CamelURL *url;
	gchar *url_string;
	const gchar *target_url;

	if (!account)
		return;

	target_url = e_account_get_string (account, item);
	if (target_url && target_url[0] != '\0')
		url = camel_url_new (target_url, NULL);
	else
		return;

	camel_url_set_param (url, "owa_url", surl);
	camel_url_set_param (url, "account_uid", e_account_get_string (account, E_ACCOUNT_ID_ADDRESS));
	
	url_string = camel_url_to_string (url, 0);
	e_account_set_string (account, item, url_string);
	g_free (url_string);
	camel_url_free (url);


}
Пример #4
0
static CamelService *
ref_service_for_source (CamelSession *session,
                        const gchar *src)
{
	CamelService *service = NULL;

	/* Source strings are now CamelService UIDs. */
	if (src != NULL)
		service = camel_session_ref_service (session, src);

	/* For backward-compability, also handle CamelService URLs. */
	if (service == NULL && src != NULL) {
		CamelURL *url;

		url = camel_url_new (src, NULL);

		if (service == NULL && url != NULL)
			service = camel_session_ref_service_by_url (
				session, url, CAMEL_PROVIDER_STORE);

		if (service == NULL && url != NULL)
			service = camel_session_ref_service_by_url (
				session, url, CAMEL_PROVIDER_TRANSPORT);

		if (url != NULL)
			camel_url_free (url);
	}

	return service;
}
Пример #5
0
/**
 * kolab_util_backend_get_relative_path_from_uri:
 * @uri: An URI string
 *
 * Extracts the path from the given uri. Leading "/" are removed.
 *
 * Returns: A newly allocated string containing the uri, or NULL.
 */
gchar *
kolab_util_backend_get_relative_path_from_uri (const gchar *uri)
{
	CamelURL *c_url = NULL;
	gchar *tmp = NULL;
	gchar *path = NULL;
	GError *tmp_err = NULL;

	c_url = camel_url_new (uri, &tmp_err);
	if (c_url == NULL) {
		g_warning ("%s()[%u] error: %s", __func__, __LINE__, tmp_err->message);
		g_error_free (tmp_err);
		return NULL;
	}
	tmp = g_strdup (c_url->path);
	camel_url_free (c_url);
	if (tmp[0] == KOLAB_PATH_SEPARATOR) {
		path = g_strdup (tmp+1);
		g_free (tmp);
	}
	else {
		path = tmp;
	}

	return path;
} /* kolab_util_backend_get_relative_path_from_uri () */
Пример #6
0
static char *
format_url(const char *internal_url, const char *account_name)
{
	CamelURL *url;
       	char *pretty_url;

	url = camel_url_new(internal_url, NULL);
	if (account_name) {
		if (url->host && *url->host)
			pretty_url = g_strdup_printf("<b>%s (%s)</b>: %s", account_name, url->protocol, url->host);
		else if (url->path)
			pretty_url = g_strdup_printf("<b>%s (%s)</b>: %s", account_name, url->protocol, url->path);
		else
			pretty_url = g_strdup_printf("<b>%s (%s)</b>", account_name, url->protocol);
	}
	else {
		if (url->host && *url->host)
			pretty_url = g_strdup_printf("<b>%s</b>: %s", url->protocol, url->host);
		else if (url->path)
			pretty_url = g_strdup_printf("<b>%s</b>: %s", url->protocol, url->path);
		else
			pretty_url = g_strdup_printf("<b>%s</b>", url->protocol);
	}
	camel_url_free(url);

        return pretty_url;
}
gboolean
org_gnome_exchange_check_options(EPlugin *epl, EConfigHookPageCheckData *data)
{
    EMConfigTargetAccount *target = (EMConfigTargetAccount *)data->config->target;
    int status = TRUE;

    /* We assume that if the host is set, then the setting is valid.
       The host gets set when the provider validate() call is made */
    /* We do this check for receive page also, so that user can
     * proceed with the account set up only after user is validated,
     * and host name is reset by validate() call
     */
    if (data->pageid == NULL ||
            strcmp (data->pageid, "10.receive") == 0 ||
            strcmp (data->pageid, "20.receive_options") == 0) {
        CamelURL *url;

        const char * target_url = e_account_get_string(target->account,  E_ACCOUNT_SOURCE_URL);
        if (target_url && target_url[0] != '\0')
            url = camel_url_new(target_url, NULL);
        else
            url = NULL;
        /* Note: we only care about exchange url's, we WILL get called on all other url's too. */
        if (url != NULL
                && strcmp(url->protocol, "exchange") == 0
                && (url->host == NULL || url->host[0] == 0))
            status = FALSE;

        if (url)
            camel_url_free(url);
    }

    return status;
}
void
org_gnome_exchange_commit (EPlugin *epl, EConfigHookItemFactoryData *data)
{
    EMConfigTargetAccount *target_account;
    const char *source_url;
    CamelURL *url;

    target_account = (EMConfigTargetAccount *)data->config->target;
    source_url = e_account_get_string (target_account->account,  E_ACCOUNT_SOURCE_URL);
    if (source_url && source_url[0] != '\0')
        url = camel_url_new (source_url, NULL);
    else
        url = NULL;
    if (url == NULL
            || strcmp (url->protocol, "exchange") != 0) {
        if (url)
            camel_url_free (url);

        return;
    }
    if (data->old) {
        camel_url_free(url);
        return;
    }

    camel_url_free (url);
    /* Set oof data in exchange account */
    set_oof_info ();
    destroy_oof_data ();
    return;
}
Пример #9
0
gchar *
camel_ews_utils_get_host_name (CamelSettings *settings)
{
	CamelURL *url;
	gchar *host = NULL, *hosturl;

	g_return_val_if_fail (settings != NULL, NULL);

	hosturl = camel_ews_settings_dup_hosturl (CAMEL_EWS_SETTINGS (settings));

	url = camel_url_new (hosturl, NULL);
	if (url) {
		host = g_strdup (url->host);
		camel_url_free (url);
	}

	if (!host || !*host) {
		g_free (host);
		host = camel_network_settings_dup_host (CAMEL_NETWORK_SETTINGS (settings));
	}

	g_free (hosturl);

	return host;
}
Пример #10
0
static void
exchange_authtype_changed (GtkComboBox *dropdown, EConfig *config)
{
    EMConfigTargetAccount *target = (EMConfigTargetAccount *)config->target;
    int id = gtk_combo_box_get_active(dropdown);
    GtkTreeModel *model;
    GtkTreeIter iter;
    CamelServiceAuthType *authtype;
    CamelURL *url_source, *url_transport;
    const char *source_url, *transport_url;
    char *source_url_string, *transport_url_string;

    source_url = e_account_get_string (target->account,
                                       E_ACCOUNT_SOURCE_URL);
    if (id == -1)
        return;

    url_source = camel_url_new (source_url, NULL);

    transport_url = e_account_get_string (target->account,
                                          E_ACCOUNT_TRANSPORT_URL);
    url_transport = camel_url_new (transport_url, NULL);

    model = gtk_combo_box_get_model(dropdown);
    if (gtk_tree_model_iter_nth_child(model, &iter, NULL, id)) {
        gtk_tree_model_get(model, &iter, 1, &authtype, -1);
        if (authtype) {
            camel_url_set_authmech(url_source, authtype->authproto);
            camel_url_set_authmech(url_transport, authtype->authproto);
        }
        else {
            camel_url_set_authmech(url_source, NULL);
            camel_url_set_authmech(url_transport, NULL);
        }

        source_url_string = camel_url_to_string(url_source, 0);
        transport_url_string = camel_url_to_string(url_transport, 0);
        e_account_set_string(target->account, E_ACCOUNT_SOURCE_URL, source_url_string);
        e_account_set_string(target->account, E_ACCOUNT_TRANSPORT_URL, transport_url_string);
        g_free(source_url_string);
        g_free(transport_url_string);
    }
    camel_url_free(url_source);
    camel_url_free(url_transport);
}
Пример #11
0
static CamelService *
get_service (CamelSession *session, const char *url_string,
	     CamelProviderType type, CamelException *ex)
{
	CamelURL *url;
	CamelProvider *provider;
	CamelService *service;
	CamelException internal_ex;

	url = camel_url_new (url_string, ex);
	if (!url)
		return NULL;

	/* We need to look up the provider so we can then lookup
	   the service in the provider's cache */
	provider = camel_provider_get(url->protocol, ex);
	if (provider && !provider->object_types[type]) {
		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
				      _("No provider available for protocol `%s'"),
				      url->protocol);
		provider = NULL;
	}

	if (!provider) {
		camel_url_free (url);
		return NULL;
	}

	/* If the provider doesn't use paths but the URL contains one,
	 * ignore it.
	 */
	if (url->path && !CAMEL_PROVIDER_ALLOWS (provider, CAMEL_URL_PART_PATH))
		camel_url_set_path (url, NULL);

	/* Now look up the service in the provider's cache */
//	service = camel_object_bag_reserve(provider->service_cache[type], url);
//	if (service == NULL) {
		service = (CamelService *)camel_object_new (provider->object_types[type]);
		camel_exception_init (&internal_ex);
		camel_service_construct (service, session, provider, url, &internal_ex);
		if (camel_exception_is_set (&internal_ex)) {
			camel_exception_xfer (ex, &internal_ex);
			camel_object_unref (service);
			service = NULL;
//			camel_object_bag_abort(provider->service_cache[type], url);
		} else {
//			camel_object_bag_add(provider->service_cache[type], url, service);
		}
//	}

	camel_url_free (url);

	return service;
}
Пример #12
0
static void
owa_editor_entry_changed(GtkWidget *entry, EConfig *config)
{
    const char *uri, *ssl = NULL;
    CamelURL *url, *owaurl = NULL;
    char *url_string;
    EMConfigTargetAccount *target = (EMConfigTargetAccount *)config->target;
    GtkWidget *button = g_object_get_data((GObject *)entry, "authenticate-button");
    int active = FALSE;

    /* NB: we set the button active only if we have a parsable uri entered */

    const char * target_url = e_account_get_string(target->account, E_ACCOUNT_SOURCE_URL);
    if (target_url && target_url[0] != '\0')
        url = camel_url_new(target_url, NULL);
    else url = NULL;
    uri = gtk_entry_get_text((GtkEntry *)entry);
    if (uri && uri[0]) {
        camel_url_set_param(url, "owa_url", uri);
        owaurl = camel_url_new(uri, NULL);
        if (owaurl) {
            active = TRUE;

            /* Reading the owa url and setting use_ssl paramemter */
            if (!strcmp(owaurl->protocol, "https"))
                ssl = "always";
            camel_url_free(owaurl);
        }
    } else {
        camel_url_set_param(url, "owa_url", NULL);
    }

    camel_url_set_param(url, "use_ssl", ssl);
    gtk_widget_set_sensitive(button, active);

    url_string = camel_url_to_string(url, 0);
    e_account_set_string(target->account, E_ACCOUNT_SOURCE_URL, url_string);
    g_free(url_string);
    camel_url_free (url);
}
Пример #13
0
static void
mc_setup_local_store(MailComponent *mc)
{
	MailComponentPrivate *p = mc->priv;
	CamelURL *url;
	char *tmp;
	CamelException ex;
	int i;

	g_mutex_lock(p->lock);
	if (p->local_store != NULL) {
		g_mutex_unlock(p->lock);
		return;
	}

	camel_exception_init(&ex);

	url = camel_url_new("mbox:", NULL);
	tmp = g_build_filename (p->base_directory, "local", NULL);
	camel_url_set_path(url, tmp);
	g_free(tmp);
	tmp = camel_url_to_string(url, 0);
	p->local_store = (CamelStore *)camel_session_get_service(session, tmp, CAMEL_PROVIDER_STORE, &ex);
	g_free(tmp);
	if (p->local_store == NULL)
		goto fail;

	for (i=0;i<sizeof(mc_default_folders)/sizeof(mc_default_folders[0]);i++) {
		/* FIXME: should this uri be account relative? */
		camel_url_set_fragment(url, mc_default_folders[i].name);
		mc_default_folders[i].uri = camel_url_to_string(url, 0);
		mc_default_folders[i].folder = camel_store_get_folder(p->local_store, mc_default_folders[i].name,
								      CAMEL_STORE_FOLDER_CREATE, &ex);
		camel_exception_clear(&ex);
	}

	camel_url_free(url);
	g_mutex_unlock(p->lock);

	g_object_ref(mc);
	camel_object_ref(p->local_store);
	mail_async_event_emit(p->async_event, MAIL_ASYNC_GUI, (MailAsyncFunc)mc_add_local_store, p->local_store, _("On This Computer"), mc);

	return;
fail:
	g_mutex_unlock(p->lock);

	g_warning("Could not setup local store/folder: %s", ex.desc);

	camel_url_free(url);
	camel_exception_clear(&ex);
}
Пример #14
0
gint
main (gint argc,
      gchar **argv)
{
	CamelURL *base_url, *url;
	gchar *url_string;
	gint i;
	GError *error = NULL;

	camel_test_init (argc, argv);

	camel_test_start ("URL parsing");

	camel_test_push ("base URL parsing");
	base_url = camel_url_new (base, &error);
	if (!base_url) {
		camel_test_fail (
			"Could not parse %s: %s\n",
			base, error->message);
	}
	camel_test_pull ();

	camel_test_push ("base URL unparsing");
	url_string = camel_url_to_string (base_url, 0);
	if (strcmp (url_string, base) != 0) {
		camel_test_fail ("URL <%s> unparses to <%s>\n",
				 base, url_string);
	}
	camel_test_pull ();
	g_free (url_string);

	for (i = 0; i < G_N_ELEMENTS (tests); i++) {
		camel_test_push ("<%s> + <%s> = <%s>?", base, tests[i].url_string, tests[i].result);
		url = camel_url_new_with_base (base_url, tests[i].url_string);
		if (!url) {
			camel_test_fail ("could not parse");
			camel_test_pull ();
			continue;
		}

		url_string = camel_url_to_string (url, 0);
		if (strcmp (url_string, tests[i].result) != 0)
			camel_test_fail ("got <%s>!", url_string);
		g_free (url_string);
		camel_test_pull ();
	}

	camel_test_end ();

	return 0;
}
Пример #15
0
char *
mail_tool_do_movemail (const char *source_url, CamelException *ex)
{
#ifndef G_OS_WIN32
	char *dest_path;
	struct stat sb;
	CamelURL *uri;

	uri = camel_url_new(source_url, ex);
	if (uri == NULL)
		return NULL;

	if (strcmp(uri->protocol, "mbox") != 0) {
		/* This is really only an internal error anyway */
		camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_URL_INVALID,
				      _("Trying to movemail a non-mbox source `%s'"),
				      source_url);
		camel_url_free(uri);
		return NULL;
	}

	/* Set up our destination. */
	dest_path = mail_tool_get_local_movemail_path ((unsigned char *)source_url, ex);
	if (dest_path == NULL)
		return NULL;

	/* Movemail from source (source_url) to dest_path */
	camel_movemail (uri->path, dest_path, ex);
	camel_url_free(uri);

	if (g_stat (dest_path, &sb) < 0 || sb.st_size == 0) {
		g_unlink (dest_path); /* Clean up the movemail.foo file. */
		g_free (dest_path);
		return NULL;
	}

	if (camel_exception_is_set (ex)) {
		g_free (dest_path);
		return NULL;
	}

	return dest_path;
#else
	/* Unclear yet whether camel-movemail etc makes any sense on
	 * Win32, at least it is not ported yet.
	 */
	g_warning("%s: Not implemented", __FUNCTION__);
	return NULL;
#endif
}
/*Build/populate CamelFolderInfo structure based on the imap_build_folder_info function*/
static CamelFolderInfo *
groupwise_build_folder_info (CamelGroupwiseStore *gw_store, const gchar *parent_name, const gchar *folder_name)
{
	CamelURL *url;
	const gchar *name;
	CamelFolderInfo *fi;
	CamelGroupwiseStorePrivate *priv = gw_store->priv;

	fi = camel_folder_info_new ();

	fi->unread = -1;
	fi->total = -1;

	if (parent_name) {
		if (strlen (parent_name) > 0)
			fi->full_name = g_strconcat(parent_name, "/", folder_name, NULL);
		else
			fi->full_name = g_strdup (folder_name);
	} else
		fi->full_name = g_strdup (folder_name);

	url = camel_url_new (priv->base_url,NULL);
	g_free (url->path);
	url->path = g_strdup_printf("/%s", fi->full_name);
	fi->uri = camel_url_to_string (url,CAMEL_URL_HIDE_ALL);
	camel_url_free (url);

	name = strrchr (fi->full_name,'/');
	if (name == NULL)
		name = fi->full_name;
	else
		name++;
	if (!strcmp (folder_name, "Sent Items"))
		fi->flags |= CAMEL_FOLDER_TYPE_SENT;
	else if (!strcmp (folder_name, "Mailbox"))
		fi->flags |= CAMEL_FOLDER_TYPE_INBOX;
	else if (!strcmp (folder_name, "Trash"))
		fi->flags |= CAMEL_FOLDER_TYPE_TRASH;
	else if (!strcmp (folder_name, "Junk Mail"))
		fi->flags |= CAMEL_FOLDER_TYPE_JUNK;

	if (groupwise_is_system_folder (folder_name))
		fi->flags |= CAMEL_FOLDER_SYSTEM;

	fi->name = g_strdup (name);
	return fi;
}
Пример #17
0
gchar*
kolab_util_backend_get_protocol_from_uri (const gchar *uri)
{
	CamelURL *c_url = NULL;
	gchar *proto = NULL;
	GError *tmp_err = NULL;

	c_url = camel_url_new (uri, &tmp_err);
	if (c_url == NULL) {
		g_warning ("%s()[%u] error: %s", __func__, __LINE__, tmp_err->message);
		g_error_free (tmp_err);
		return NULL;
	}
	proto = g_strdup (c_url->protocol);
	camel_url_free (c_url);

	return proto;
}
Пример #18
0
static void
impl_handleURI (PortableServer_Servant servant, const char *uri, CORBA_Environment *ev)
{
	if (!strncmp (uri, "mailto:", 7)) {
		if (!em_utils_check_user_can_send_mail(NULL))
			return;

		em_utils_compose_new_message_with_mailto (uri, NULL);
	} else if (!strncmp(uri, "email:", 6)) {
		CamelURL *url = camel_url_new(uri, NULL);

		if (camel_url_get_param(url, "uid") != NULL) {
			char *curi = em_uri_to_camel(uri);

			mail_get_folder(curi, 0, handleuri_got_folder, url, mail_msg_unordered_push);
			g_free(curi);
		} else {
			g_warning("email uri's must include a uid parameter");
			camel_url_free(url);
		}
	}
}
gboolean
org_gnome_activesync_check_options(EPlugin *epl, EConfigHookPageCheckData *data)
{
	EMConfigTargetAccount *target = (EMConfigTargetAccount *)data->config->target;
	gint status = TRUE;

	if (data->pageid == NULL ||
	    strcmp (data->pageid, "10.receive") == 0 ||
	    strcmp (data->pageid, "20.receive_options") == 0) {
		char *url;
		char *key;
		const char *address = e_account_get_string (target->MODIFIED_ACCT,
							    E_ACCOUNT_ID_ADDRESS);
		GConfClient *client = gconf_client_get_default ();
		CamelURL *curl;
		const gchar * target_url = e_account_get_string(target->MODIFIED_ACCT,
								E_ACCOUNT_SOURCE_URL);

		curl = camel_url_new(target_url, NULL);
		if (!curl)
			return FALSE;

		key = g_strdup_printf ("/apps/activesyncd/accounts/%s/serverUri", address);
		url = gconf_client_get_string (client, key, NULL);
		g_object_unref (client);
		g_free (key);
	
			/* Note: we only care about activesync url's, we WILL get called on all other url's too. */
		if ((!url|| !*url)
		    && strcmp(curl->protocol, "eas") == 0) {
			status = FALSE;
		} 		

		g_free (url);
	}

	return status;
}
Пример #20
0
GtkWidget *
org_gnome_imap_headers (EPlugin *epl, EConfigHookItemFactoryData *data)
{
	EMConfigTargetAccount *target_account;
	EAccount *account;
	GtkWidget *vbox;
	CamelURL *url = NULL;
	CamelException ex;
	char *gladefile;
	GladeXML *gladexml;
	GtkCellRenderer *renderer;
	GtkTreeViewColumn *column;
	GtkTreeIter first, iter;
	gboolean use_imap = g_getenv ("USE_IMAP") != NULL;
	
	ui = g_new0 (EPImapFeaturesData, 1);

	target_account = (EMConfigTargetAccount *)data->config->target;
	account = target_account->account;

	if(!g_str_has_prefix (account->source->url, "imap://") && !(use_imap && g_str_has_prefix (account->source->url, "groupwise://")))
		return NULL;

	gladefile = g_build_filename (EVOLUTION_GLADEDIR, "imap-headers.glade", NULL);
	gladexml = glade_xml_new (gladefile, "vbox2", NULL);
	g_free (gladefile);

	vbox = glade_xml_get_widget (gladexml, "vbox2");
	ui->all_headers = glade_xml_get_widget (gladexml, "allHeaders");
	ui->basic_headers = glade_xml_get_widget (gladexml, "basicHeaders");
	ui->mailing_list_headers = glade_xml_get_widget (gladexml, "mailingListHeaders");
	ui->custom_headers_box = glade_xml_get_widget (gladexml, "custHeaderHbox");
	ui->custom_headers_tree = GTK_TREE_VIEW(glade_xml_get_widget (gladexml, "custHeaderTree"));
	ui->add_header = GTK_BUTTON(glade_xml_get_widget (gladexml, "addHeader"));
	ui->remove_header = GTK_BUTTON(glade_xml_get_widget (gladexml, "removeHeader"));
	ui->entry_header = GTK_ENTRY (glade_xml_get_widget (gladexml, "customHeaderEntry"));

	url = camel_url_new (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), &ex);

	ui->store = gtk_tree_store_new (1, G_TYPE_STRING);
	gtk_tree_view_set_model (ui->custom_headers_tree, GTK_TREE_MODEL(ui->store));

	if (url) {
		char *custom_headers;

		custom_headers = g_strdup(camel_url_get_param (url, "imap_custom_headers"));
		if (custom_headers) {
			int i=0;

			ui->custom_headers_array = g_strsplit (custom_headers, " ", -1);
			while (ui->custom_headers_array[i] ) {
				if (strlen(g_strstrip(ui->custom_headers_array[i]))) {
					gtk_tree_store_append (ui->store, &iter, NULL);
					gtk_tree_store_set (ui->store, &iter, 0, ui->custom_headers_array[i], -1);
				}
				i++;
			}
			g_strfreev (ui->custom_headers_array);

		}
		g_free (custom_headers);

		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ui->mailing_list_headers), TRUE);
		if (camel_url_get_param (url, "all_headers")) {
				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ui->all_headers), TRUE);
				gtk_widget_set_sensitive (ui->custom_headers_box, FALSE);
		} else if (camel_url_get_param (url, "basic_headers"))
				gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (ui->basic_headers), TRUE);
		camel_url_free (url);
	}
	renderer = gtk_cell_renderer_text_new ();
	column = gtk_tree_view_column_new_with_attributes (_("Custom Headers"), renderer, "text", 0, NULL);
	gtk_tree_view_append_column (ui->custom_headers_tree , column);

	gtk_widget_set_sensitive (GTK_WIDGET (ui->add_header), FALSE);
	if (gtk_tree_model_get_iter_first (gtk_tree_view_get_model (ui->custom_headers_tree), &first)==FALSE)
		gtk_widget_set_sensitive (GTK_WIDGET (ui->remove_header), FALSE);

	g_signal_connect (ui->all_headers, "toggled", G_CALLBACK (epif_fetch_all_headers_toggled), ui);
	g_signal_connect (ui->add_header, "clicked", G_CALLBACK (epif_add_header), ui);
	g_signal_connect (ui->remove_header, "clicked", G_CALLBACK (epif_remove_header_clicked), ui);
	g_signal_connect (ui->entry_header, "changed", G_CALLBACK (epif_entry_changed), ui);
	g_signal_connect (ui->entry_header, "activate", G_CALLBACK (epif_add_header), ui);

	gtk_notebook_append_page ((GtkNotebook *)(data->parent), vbox, gtk_label_new(_("IMAP Headers")));
	gtk_widget_show_all (vbox);

	return GTK_WIDGET (vbox);
}
Пример #21
0
GtkWidget *
org_gnome_exchange_auth_section (EPlugin *epl, EConfigHookItemFactoryData *data)
{
    EMConfigTargetAccount *target_account;
    const char *source_url;
    char *label_text, *exchange_account_authtype = NULL;
    CamelURL *url;
    GtkWidget *hbox, *button, *auth_label, *vbox, *label_hide;
    GtkComboBox *dropdown;
    GtkTreeIter iter;
    GtkListStore *store;
    int i, active=0, auth_changed_id = 0;
    GList *authtypes, *l, *ll;
    ExchangeAccount *account;

    target_account = (EMConfigTargetAccount *)data->config->target;
    source_url = e_account_get_string (target_account->account,
                                       E_ACCOUNT_SOURCE_URL);
    url = camel_url_new (source_url, NULL);
    if (url == NULL
            || strcmp (url->protocol, "exchange") != 0) {
        if (url)
            camel_url_free (url);

        return NULL;
    }

    if (data->old) {
        camel_url_free(url);
        return data->old;
    }

    account = exchange_operations_get_exchange_account ();
    if (account)
        exchange_account_authtype = exchange_account_get_authtype (account);

    vbox = gtk_vbox_new (FALSE, 6);

    label_text = g_strdup_printf("<b>%s</b>", _("_Authentication Type"));
    auth_label = gtk_label_new_with_mnemonic (label_text);
    g_free (label_text);
    gtk_label_set_justify (GTK_LABEL (auth_label), GTK_JUSTIFY_LEFT);
    gtk_misc_set_alignment (GTK_MISC (auth_label), 0, 0.5);
    gtk_misc_set_padding (GTK_MISC (auth_label), 0, 0);
    gtk_label_set_use_markup (GTK_LABEL (auth_label), TRUE);

    label_hide = gtk_label_new("\n");

    hbox = gtk_hbox_new (FALSE, 6);
    dropdown = (GtkComboBox * )gtk_combo_box_new ();
    gtk_label_set_mnemonic_widget (GTK_LABEL (auth_label), GTK_WIDGET (dropdown));

    button = gtk_button_new_with_mnemonic (_("Ch_eck for Supported Types"));

    authtypes = g_list_prepend (g_list_prepend (NULL, &camel_exchange_password_authtype),
                                &camel_exchange_ntlm_authtype);
    store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);

    for (i=0, l=authtypes; l; l=l->next, i++) {
        CamelServiceAuthType *authtype = l->data;
        int avail = TRUE;

        if (authtypes) {
            for (ll = authtypes; ll; ll = g_list_next(ll))
                if (!strcmp(authtype->authproto,
                            ((CamelServiceAuthType *)ll->data)->authproto))
                    break;
            avail = ll != NULL;
        }
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter, 0, authtype->name, 1,
                            authtype, 2, !avail, -1);

        if (url && url->authmech && !strcmp(url->authmech, authtype->authproto)) {
            active = i;
        }
        else if (url && exchange_account_authtype &&
                 !strcmp (exchange_account_authtype, authtype->authproto)) {
            /* if the url doesn't contain authmech, read the value from
             * exchange account and set the tab selection and
             * also set the authmech back to url
             */
            camel_url_set_authmech (url, exchange_account_authtype);
            active = i;
        }
    }

    gtk_combo_box_set_model (dropdown, (GtkTreeModel *)store);
    gtk_combo_box_set_active (dropdown, -1);

    if (auth_changed_id == 0) {
        GtkCellRenderer *cell = gtk_cell_renderer_text_new();

        gtk_cell_layout_pack_start ((GtkCellLayout *)dropdown, cell, TRUE);
        gtk_cell_layout_set_attributes ((GtkCellLayout *)dropdown, cell,
                                        "text", 0, "strikethrough", 2, NULL);

        auth_changed_id = g_signal_connect (dropdown,
                                            "changed",
                                            G_CALLBACK (exchange_authtype_changed),
                                            data->config);
        g_signal_connect (button,
                          "clicked",
                          G_CALLBACK(exchange_check_authtype),
                          data->config);
    }

    gtk_combo_box_set_active(dropdown, active);

    gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (dropdown), FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);

    gtk_box_pack_start (GTK_BOX (vbox), auth_label, TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
    gtk_box_pack_start (GTK_BOX (vbox), label_hide, TRUE, TRUE, 0);
    gtk_widget_show_all (vbox);

    gtk_box_pack_start (GTK_BOX (data->parent), vbox, TRUE, TRUE, 0);

    if (url)
        camel_url_free(url);
    g_list_free (authtypes);
    g_free (exchange_account_authtype);

    return vbox;
}
Пример #22
0
static gboolean
synch_data (ScalixAccountSynch * sxas,
            CamelFolderInfo * ftree, int type, guint prg_offset)
{
    ScalixAccountSynchPrivate *priv;
    GSList *def;
    GSList *list;
    GSList *iter;
    guint n, i, prg;
    CamelURL *url;
    const char *uri;

    priv = SCALIX_ACCOUNT_SYNCH_GET_PRIVATE (sxas);

    if (priv->synch_data == FALSE) {
        return TRUE;
    }

    uri = e_account_get_string (priv->account, E_ACCOUNT_SOURCE_URL);
	url = camel_url_new (uri, NULL);

    if (url == NULL) {
        return FALSE;
    }

    list = folder_tree_flatten (ftree, type, &def);
    n = g_slist_length (list);

    for (iter = list, i = 1; iter; iter = g_slist_next (iter), i++) {
        ScalixContainer *container;
        CamelFolderInfo *fi;
        char *curi;
        char *msg;

        fi = (CamelFolderInfo *) iter->data;

		curi = url_set_path_and_get_string (url, fi->full_name);

        prg = prg_offset + ((guint) ((((gdouble) i) / ((gdouble) n)) * 30.0));

        msg = g_strdup_printf (_("Sychronizing %s..."), fi->name);
        signal_progress (sxas, prg, msg);
        g_free (msg);

        container = scalix_container_open (curi);
        g_free (curi);

        if (container == NULL) {
            g_debug ("SxAS: Could not open container\n");
            continue;
        }

        g_object_set (container, "online", TRUE, NULL);
        g_object_get (container, "items", &(priv->items), NULL);

        priv->items_done = 0;

        g_signal_connect (container,
                          "object_added",
                          G_CALLBACK (container_object_added_cb), sxas);

        g_signal_connect (container,
                          "object_changed",
                          G_CALLBACK (container_object_changed_cb), sxas);

        g_signal_connect (container,
                          "object_removed",
                          G_CALLBACK (container_object_removed_cb), sxas);

        signal_progress2 (sxas, 0, "");
        scalix_container_sync (container);
        signal_progress2 (sxas, 100, "");
        g_object_unref (container);

    }

	camel_url_free (url);
	return TRUE;
}
Пример #23
0
static void
sync_source_group (EAccount * account,
                   ESourceGroup * group,
                   int folder_type, CamelFolderInfo * ftree)
{
    GSList *fi_list;
    GSList *def;
    GSList *iter;

    fi_list = folder_tree_flatten (ftree, folder_type, &def);

    for (iter = fi_list; iter != NULL; iter = g_slist_next (iter)) {
        ESource *source;
        CamelURL *url;
        CamelFolderInfo *info;
        const char *fuid;
	const char *pssl;
        char *uid;
        xmlNodePtr node;

        info = (CamelFolderInfo *) iter->data;

        url = camel_url_new (info->uri, NULL);
	g_print ("FOLDER_URI: %s\n", info->uri);
        if (url == NULL) {
            camel_url_free (url);
            continue;
        }

        /* the uid part */
        fuid = camel_url_get_param (url, "uid");

        if (fuid == NULL) {
            g_warning ("No Folder UID\n");
            camel_url_free (url);
            continue;
        }

        uid = g_strdup_printf ("%s@%s", fuid, account->uid);


        /* there is no such thing as e_source_set_uid 
         * so we have to cheat here a bit */

        node = xmlNewNode (NULL, "source");
        xmlSetProp (node, "uid", uid);
        xmlSetProp (node, "name", info->name);
        xmlSetProp (node, "relative_uri", info->full_name);

        source = e_source_new_from_xml_node (node);

        xmlFreeNode (node);
        g_free (uid);

        if (source == NULL) {
            g_warning ("Invalid source, skipping");
	    camel_url_free (url);
            /* FIXME free resources */
            continue;
        }

	pssl = camel_url_get_param (url, "use_ssl");
	if (pssl != NULL) {
		e_source_set_property (source, "use_ssl", pssl);
	}

        if (info->flags & CAMEL_FOLDER_IS_DEFAULT) {
            e_source_set_property (source, "default", "TRUE");

            if (folder_type == CAMEL_SCALIX_FOLDER_CONTACT) {
                e_source_set_property (source, "completion", "TRUE");
            }
        }

	camel_url_free (url);
        e_source_group_add_source (group, source, -1);
    }
}
Пример #24
0
/* The worker thread function with all the complex
 * logic in it! Big fat beast! Please watch your
 * children ... */
static void
synch_worker (struct account_synch_msg *m)
{
    ScalixAccountSynch *sxas;
    ScalixAccountSynchPrivate *priv;
    CamelException ex;
    CamelStore *store;
    CamelFolderInfo *ftree;
    CamelFolderInfo *sf;
    CamelSession *cs;
    const char *uri;
    gboolean res;
    char *sversion;
    char *markup;

    sxas = SCALIX_ACCOUNT_SYNCH (m->sxas);
    priv = SCALIX_ACCOUNT_SYNCH_GET_PRIVATE (sxas);

    uri = e_account_get_string (priv->account, E_ACCOUNT_SOURCE_URL);

    g_print ("SxAS: starting synch for %s\n", uri);

    signal_progress (sxas, 1, _("Trying to connect to server"));

    camel_exception_init (&ex);
    cs = scalix_camel_session_get_default ();
    camel_session_set_online (cs, TRUE);

    store = camel_session_get_store (cs, uri, &ex);

    if (store == NULL) {
        signal_error (sxas, _("Authentication failed. Check for correct hostname, username and password."));
        return;
    }

    /* Must be online! */
    camel_offline_store_set_network_state (CAMEL_OFFLINE_STORE (store),
                                           CAMEL_OFFLINE_STORE_NETWORK_AVAIL,
                                           &ex);

    camel_service_connect (CAMEL_SERVICE (store), &ex);

    if (camel_exception_is_set (&ex)) {
        signal_error (sxas, _("Error while trying to connect to server."));
        return;
    }

    /* Always check for minimal required server version  */
    signal_progress (sxas, 10, _("Checking version of Scalix server"));
    g_print ("SxAS: Checking for minimal server version\n");

    sversion = NULL;
    camel_object_get (store, NULL,
                      CAMEL_SCALIX_STORE_SERVER_VERSION, &sversion, NULL);

    res = scalix_check_min_server_version (sversion);

    if (res == FALSE) {
        signal_error (sxas, _("Wrong version of Scalix server detected"));
        return;
    }

    m->sversion = g_strdup (sversion);
    g_print ("SxAS: sversion:%s\n", m->sversion);

    markup = g_markup_printf_escaped (MSG_SVER, sversion);
    signal_info (sxas, markup);
    g_free (markup);

    signal_progress (sxas, 20, _("Getting list of folders"));
    ftree = camel_store_get_folder_info (store,
                                         NULL,
                                         CAMEL_STORE_FOLDER_INFO_RECURSIVE |
                                         CAMEL_SCALIX_STORE_SHOW_SFOLDER, &ex);

    if (ftree == NULL) {
        camel_object_unref (store);
        signal_error (sxas, _("Could not obtain folder listening"));
        return;

    }

    /* Calendar  */
    signal_progress (sxas, 30, _("Loading calendar data..."));
    synch_data (sxas, ftree, CAMEL_SCALIX_FOLDER_CALENDAR, 30);

    m->esg_cals = create_group (priv->account, "Calendar");
    sync_source_group (priv->account,
                       m->esg_cals, CAMEL_SCALIX_FOLDER_CALENDAR, ftree);

    /* Contacts */
    signal_progress (sxas, 60, _("Loading contacts..."));
    synch_data (sxas, ftree, CAMEL_SCALIX_FOLDER_CONTACT, 60);

    m->esg_cnts = create_group (priv->account, "Contacts");
    sync_source_group (priv->account,
                       m->esg_cnts, CAMEL_SCALIX_FOLDER_CONTACT, ftree);

    create_ldap_source (priv->account, m->esg_cnts);

    /* Sent Items and Drafts Folder */
    if (priv->synch_dfolder) {
        char *url_str;
	CamelURL *url;

	url = camel_url_new (uri, NULL);

        signal_progress (sxas, 95, _("Synchronizing additional data"));

        sf = folder_tree_find_special (ftree, CAMEL_SCALIX_FOLDER_SENT);

        if (url && sf) {
	    url_str = url_set_path_and_get_string (url, sf->full_name);

            e_account_set_string (priv->account,
                                  E_ACCOUNT_SENT_FOLDER_URI, url_str);
            g_free (url_str);
        }

        sf = folder_tree_find_special (ftree, CAMEL_SCALIX_FOLDER_DRAFTS);

        if (url && sf) {
	    url_str = url_set_path_and_get_string (url, sf->full_name);
            e_account_set_string (priv->account,
                                  E_ACCOUNT_DRAFTS_FOLDER_URI, url_str);

            g_free (url_str);
        }

        if (url) {
            gboolean save_pw;

            camel_url_set_path (url, NULL);

            if (url->authmech == NULL) {
		    camel_url_set_authmech (url, "PLAIN");
            }

	    url_str = camel_url_to_string (url, 0);
            e_account_set_string (priv->account,
                                  E_ACCOUNT_TRANSPORT_URL, url_str);

            save_pw = e_account_get_bool (priv->account,
                                          E_ACCOUNT_SOURCE_SAVE_PASSWD);

            e_account_set_bool (priv->account,
                                E_ACCOUNT_TRANSPORT_SAVE_PASSWD, save_pw);
        }

        if (url) {
		camel_url_free (url);
        }
    }

    m->success = TRUE;

    g_print ("SxAS: DONE!\n");

    camel_object_unref (store);
    signal_progress (sxas, 100, _("Done loading"));
    signal_info (sxas, _("Initial loading complete. Please click Forward."));
    g_print ("SxAS: Freeing DONE\n");
    return;
}
Пример #25
0
/* used by editor and druid - same code */
GtkWidget *
org_gnome_exchange_owa_url(EPlugin *epl, EConfigHookItemFactoryData *data)
{
    EMConfigTargetAccount *target_account;
    const char *source_url;
    char *owa_url = NULL;
    GtkWidget *owa_entry;
    CamelURL *url;
    int row;
    GtkWidget *hbox, *label, *button;

    target_account = (EMConfigTargetAccount *)data->config->target;
    source_url = e_account_get_string (target_account->account,  E_ACCOUNT_SOURCE_URL);
    if (source_url && source_url[0] != '\0')
        url = camel_url_new(source_url, NULL);
    else
        url = NULL;
    if (url == NULL
            || strcmp(url->protocol, "exchange") != 0) {
        if (url)
            camel_url_free(url);

        if (data->old
                && (label = g_object_get_data((GObject *)data->old, "authenticate-label")))
            gtk_widget_destroy(label);

        /* TODO: we could remove 'owa-url' from the url,
           but that will lose it if we come back.  Maybe a commit callback could do it */

        return NULL;
    }

    if (data->old) {
        camel_url_free(url);
        return data->old;
    }

    owa_url = g_strdup (camel_url_get_param(url, "owa_url"));

    /* if the host is null, then user+other info is dropped silently, force it to be kept */
    if (url->host == NULL) {
        char *uri;

        camel_url_set_host(url, "");
        uri = camel_url_to_string(url, 0);
        e_account_set_string(target_account->account,  E_ACCOUNT_SOURCE_URL, uri);
        g_free(uri);
    }

    row = ((GtkTable *)data->parent)->nrows;

    hbox = gtk_hbox_new (FALSE, 6);
    label = gtk_label_new_with_mnemonic(_("_OWA URL:"));
    gtk_widget_show(label);

    owa_entry = gtk_entry_new();

    if (!owa_url) {
        if (url->host[0] != 0) {
            char *uri;

            /* url has hostname but not owa_url.
             * Account has been created using x-c-s or evo is upgraded to 2.2
             * When invoked from druid, hostname will get set after validation,
             * so this condition will never be true during account creation.
             */
            owa_url = construct_owa_url (url);
            camel_url_set_param (url, "owa_url", owa_url);
            uri = camel_url_to_string(url, 0);
            e_account_set_string(target_account->account,  E_ACCOUNT_SOURCE_URL, uri);
            g_free(uri);
        }
    }
    camel_url_free (url);
    if (owa_url)
        gtk_entry_set_text(GTK_ENTRY (owa_entry), owa_url);
    gtk_label_set_mnemonic_widget((GtkLabel *)label, owa_entry);

    button = gtk_button_new_with_mnemonic (_("A_uthenticate"));
    gtk_widget_set_sensitive (button, owa_url && owa_url[0]);

    gtk_box_pack_start (GTK_BOX (hbox), owa_entry, TRUE, TRUE, 0);
    gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
    gtk_widget_show_all(hbox);

    gtk_table_attach (GTK_TABLE (data->parent), label, 0, 1, row, row+1, 0, 0, 0, 0);
    gtk_table_attach (GTK_TABLE (data->parent), hbox, 1, 2, row, row+1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);

    g_signal_connect (owa_entry, "changed", G_CALLBACK(owa_editor_entry_changed), data->config);
    g_object_set_data((GObject *)owa_entry, "authenticate-button", button);
    g_signal_connect (button, "clicked", G_CALLBACK(owa_authenticate_user), data->config);

    /* Track the authenticate label, so we can destroy it if e-config is to destroy the hbox */
    g_object_set_data((GObject *)hbox, "authenticate-label", label);

    /* check for correctness of the input in the owa_entry */
    owa_editor_entry_changed (owa_entry, data->config);

    g_free (owa_url);
    return hbox;
}
Пример #26
0
static void
owa_authenticate_user(GtkWidget *button, EConfig *config)
{
    EMConfigTargetAccount *target_account = (EMConfigTargetAccount *)config->target;
    E2kAutoconfigResult result;
    CamelURL *url=NULL;
    gboolean remember_password;
    char *url_string, *key;
    const char *source_url, *id_name, *owa_url;
    char *at, *user;
    gboolean valid = FALSE;
    ExchangeParams *exchange_params;

    exchange_params = g_new0 (ExchangeParams, 1);
    exchange_params->host = NULL;
    exchange_params->ad_server = NULL;
    exchange_params->mailbox = NULL;
    exchange_params->owa_path = NULL;
    exchange_params->is_ntlm = TRUE;

    source_url = e_account_get_string (target_account->account, E_ACCOUNT_SOURCE_URL);

    if (source_url && source_url[0] != '\0')
        url = camel_url_new(source_url, NULL);
    if (url && url->user == NULL) {
        id_name = e_account_get_string (target_account->account, E_ACCOUNT_ID_ADDRESS);
        if (id_name) {
            at = strchr(id_name, '@');
            user = g_alloca(at-id_name+1);
            memcpy(user, id_name, at-id_name);
            user[at-id_name] = 0;
            camel_url_set_user (url, user);
        }
    }

    /* validate_user() CALLS GTK!!!

       THIS IS TOTALLY UNNACCEPTABLE!!!!!!!!

       It must use camel_session_ask_password, and it should return an exception for any problem,
       which should then be shown using e-error */

    owa_url = camel_url_get_param (url, "owa_url");
    if (camel_url_get_param (url, "authmech"))
        exchange_params->is_ntlm = TRUE;
    else
        exchange_params->is_ntlm = FALSE;
    camel_url_set_authmech (url, exchange_params->is_ntlm ? "NTLM" : "Basic");

    key = camel_url_to_string (url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS);
    /* Supress the trailing slash */
    key [strlen(key) -1] = 0;

    valid =  e2k_validate_user (owa_url, key, &url->user, exchange_params,
                                &remember_password, &result,
                                GTK_WINDOW (gtk_widget_get_toplevel (button)));
    g_free (key);

    if (!valid && result != E2K_AUTOCONFIG_CANCELLED)
        print_error (owa_url, result);

    camel_url_set_host (url, valid ? exchange_params->host : "");


    if (valid)
        camel_url_set_param (url, "save-passwd", remember_password? "true" : "false");

    camel_url_set_param (url, "ad_server", valid ? exchange_params->ad_server: NULL);
    camel_url_set_param (url, "mailbox", valid ? exchange_params->mailbox : NULL);
    camel_url_set_param (url, "owa_path", valid ? exchange_params->owa_path : NULL);

    g_free (exchange_params->owa_path);
    g_free (exchange_params->mailbox);
    g_free (exchange_params->host);
    g_free (exchange_params->ad_server);
    g_free (exchange_params);

    if (valid) {
        url_string = camel_url_to_string (url, 0);
        e_account_set_string (target_account->account, E_ACCOUNT_SOURCE_URL, url_string);
        e_account_set_string (target_account->account, E_ACCOUNT_TRANSPORT_URL, url_string);
        e_account_set_bool (target_account->account, E_ACCOUNT_SOURCE_SAVE_PASSWD, remember_password);
        g_free (url_string);
    }
    camel_url_free (url);
}
Пример #27
0
/* only used in editor */
GtkWidget *
org_gnome_exchange_settings(EPlugin *epl, EConfigHookItemFactoryData *data)
{
    EMConfigTargetAccount *target_account;
    ExchangeAccount *account = NULL;
    CamelURL *url;
    const char *source_url;
    char *message = NULL, *txt = NULL, *oof_message;
    gboolean oof_state = FALSE;

    GtkVBox *vbox_settings;

    /* OOF fields */
    GtkFrame *frm_oof;
    GtkVBox *vbox_oof;
    GtkLabel *lbl_oof_desc;
    GtkTable *tbl_oof_status;
    GtkLabel *lbl_status;
    GtkRadioButton *radio_iof, *radio_oof;
    GtkScrolledWindow *scrwnd_oof;
    GtkTextView *txtview_oof;

    /* Authentication settings */
    GtkFrame *frm_auth;
    GtkVBox *vbox_auth;
    GtkTable *tbl_auth;
#ifdef HAVE_KRB5
    GtkLabel *lbl_chpass;
    GtkButton *btn_chpass;
#endif
    GtkLabel *lbl_dass;
    GtkButton *btn_dass;

    /* Miscelleneous setting */
    GtkFrame *frm_misc;
    GtkVBox *vbox_misc;
    GtkTable *tbl_misc;
    GtkLabel *lbl_fsize;
    GtkButton *btn_fsize;

    GtkTextBuffer *buffer;
    GtkTextIter start, end;

    target_account = (EMConfigTargetAccount *)data->config->target;
    source_url = e_account_get_string (target_account->account,  E_ACCOUNT_SOURCE_URL);
    url = camel_url_new(source_url, NULL);
    if (url == NULL
            || strcmp(url->protocol, "exchange") != 0) {
        if (url)
            camel_url_free(url);
        return NULL;
    }

    if (data->old) {
        camel_url_free(url);
        return data->old;
    }
    if (url)
        camel_url_free (url);

    account = exchange_operations_get_exchange_account ();

    oof_data = g_new0 (OOFData, 1);

    oof_data->state = FALSE;
    oof_data->message = NULL;
    oof_data->text_view = NULL;

    /* See if oof info found already */

    if (account && !exchange_oof_get (account, &oof_state, &message)) {

        e_error_run (NULL, ERROR_DOMAIN ":state-read-error", NULL);

        return NULL;
    }

    if (message && *message)
        oof_data->message = g_strdup (message);
    else
        oof_data->message = NULL;
    oof_data->state = oof_state;

    /* construct page */

    vbox_settings = (GtkVBox*) g_object_new (GTK_TYPE_VBOX, "homogeneous", FALSE, "spacing", 6, NULL);
    gtk_container_set_border_width (GTK_CONTAINER (vbox_settings), 12);

    frm_oof = (GtkFrame*) g_object_new (GTK_TYPE_FRAME, "label", _("Out Of Office"), NULL);
    gtk_box_pack_start (GTK_BOX (vbox_settings), GTK_WIDGET (frm_oof), FALSE, FALSE, 0);

    vbox_oof = (GtkVBox*) g_object_new (GTK_TYPE_VBOX, NULL, "homogeneous", FALSE, "spacing", 12, NULL);
    gtk_container_set_border_width (GTK_CONTAINER (vbox_oof), 6);
    gtk_container_add (GTK_CONTAINER (frm_oof), GTK_WIDGET (vbox_oof));

    lbl_oof_desc = (GtkLabel*) g_object_new (GTK_TYPE_LABEL, "label", _("The message specified below will be automatically sent to \neach person who sends mail to you while you are out of the office."), "justify", GTK_JUSTIFY_LEFT, NULL);
    gtk_misc_set_alignment (GTK_MISC (lbl_oof_desc), 0, 0.5);
    gtk_box_pack_start (GTK_BOX (vbox_oof), GTK_WIDGET (lbl_oof_desc), FALSE, FALSE, 0);

    tbl_oof_status = (GtkTable*) g_object_new (GTK_TYPE_TABLE, "n-rows", 2, "n-columns", 2, "homogeneous", FALSE, "row-spacing", 6, "column-spacing", 6, NULL);
    txt = g_strdup_printf ("<b>%s</b>", _("Status:"));
    lbl_status = (GtkLabel*) g_object_new (GTK_TYPE_LABEL, "label", txt, "use-markup", TRUE, NULL);
    g_free (txt);
    gtk_misc_set_alignment (GTK_MISC (lbl_status), 0, 0.5);
    gtk_misc_set_padding (GTK_MISC (lbl_status), 0, 0);

    if (oof_data->state) {
        radio_oof = (GtkRadioButton*) g_object_new (GTK_TYPE_RADIO_BUTTON, "label", _("I am out of the office"), NULL);
        radio_iof = (GtkRadioButton*) g_object_new (GTK_TYPE_RADIO_BUTTON, "label", _("I am in the office"), "group", radio_oof, NULL);
    }
    else {
        radio_iof = (GtkRadioButton*) g_object_new (GTK_TYPE_RADIO_BUTTON, "label", _("I am in the office"), NULL);
        radio_oof = (GtkRadioButton*) g_object_new (GTK_TYPE_RADIO_BUTTON, "label", _("I am out of the office"), "group", radio_iof, NULL);
    }
    g_signal_connect (radio_oof, "toggled", G_CALLBACK (toggled_state), NULL);


    gtk_table_attach (tbl_oof_status, GTK_WIDGET (lbl_status), 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
    gtk_table_attach (tbl_oof_status, GTK_WIDGET (radio_iof), 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
    gtk_table_attach (tbl_oof_status, GTK_WIDGET (radio_oof), 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);

    gtk_box_pack_start (GTK_BOX (vbox_oof), GTK_WIDGET (tbl_oof_status), FALSE, FALSE, 0);


    scrwnd_oof = (GtkScrolledWindow*) g_object_new (GTK_TYPE_SCROLLED_WINDOW, "hscrollbar-policy", GTK_POLICY_AUTOMATIC, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, "shadow-type", GTK_SHADOW_IN, NULL);
    gtk_box_pack_start (GTK_BOX (vbox_oof), GTK_WIDGET (scrwnd_oof), FALSE, FALSE, 0);
    txtview_oof = (GtkTextView*) g_object_new (GTK_TYPE_TEXT_VIEW, "justification", GTK_JUSTIFY_LEFT, "wrap-mode", GTK_WRAP_WORD, "editable", TRUE, NULL);
    buffer = gtk_text_view_get_buffer (txtview_oof);
    gtk_text_buffer_get_bounds (buffer, &start, &end);
    oof_message = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
    if (oof_message && *oof_message) {
        /* Will this ever happen? */
        oof_data->message = oof_message;
    }
    if (oof_data->message) {
        /* previuosly set message */
        gtk_text_buffer_set_text (buffer, oof_data->message, -1);
        gtk_text_view_set_buffer (txtview_oof, buffer);

    }
    gtk_text_buffer_set_modified (buffer, FALSE);
    if (!oof_data->state)
        gtk_widget_set_sensitive (GTK_WIDGET (txtview_oof), FALSE);
    oof_data->text_view = GTK_WIDGET (txtview_oof);
    g_signal_connect (buffer, "changed", G_CALLBACK (update_state), NULL);
    gtk_container_add (GTK_CONTAINER (scrwnd_oof), GTK_WIDGET (txtview_oof));

    /* Security settings */
    frm_auth = (GtkFrame*) g_object_new (GTK_TYPE_FRAME, "label", _("Security"), NULL);
    gtk_box_pack_start (GTK_BOX (vbox_settings), GTK_WIDGET (frm_auth), FALSE, FALSE, 0);

    vbox_auth = (GtkVBox*) g_object_new (GTK_TYPE_VBOX, "homogeneous", FALSE, "spacing", 6, NULL);
    gtk_container_set_border_width (GTK_CONTAINER (vbox_auth), 6);
    gtk_container_add (GTK_CONTAINER (frm_auth), GTK_WIDGET (vbox_auth));

    tbl_auth = (GtkTable*) g_object_new (GTK_TYPE_TABLE, "n-rows", 2, "n-columns", 2, "homogeneous", FALSE, "row-spacing", 6, "column-spacing", 6, NULL);

#ifdef HAVE_KRB5
    /* Change Password */
    lbl_chpass = (GtkLabel*) g_object_new (GTK_TYPE_LABEL, "label", _("Change the password for Exchange account"), NULL);
    gtk_misc_set_alignment (GTK_MISC (lbl_chpass), 0, 0.5);
    btn_chpass = (GtkButton*) g_object_new (GTK_TYPE_BUTTON, "label", _("Change Password"), NULL);
    g_signal_connect (GTK_OBJECT (btn_chpass), "clicked", G_CALLBACK (btn_chpass_clicked), NULL);
#endif

    /* Delegation Assistant */
    lbl_dass = (GtkLabel*) g_object_new (GTK_TYPE_LABEL, "label", _("Manage the delegate settings for Exchange account"), NULL);
    gtk_misc_set_alignment (GTK_MISC (lbl_dass), 0, 0.5);
    btn_dass = (GtkButton*) g_object_new (GTK_TYPE_BUTTON, "label", _("Delegation Assistant"), NULL);
    g_signal_connect (btn_dass, "clicked", G_CALLBACK (btn_dass_clicked), NULL);
    /* Add items to the table */
#ifdef HAVE_KRB5
    gtk_table_attach_defaults (tbl_auth, GTK_WIDGET (lbl_chpass), 0, 1, 0, 1);
    gtk_table_attach (tbl_auth, GTK_WIDGET (btn_chpass), 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
#endif
    gtk_table_attach_defaults (tbl_auth, GTK_WIDGET (lbl_dass), 0, 1, 1, 2);
    gtk_table_attach (tbl_auth, GTK_WIDGET (btn_dass), 1, 2, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
    gtk_box_pack_start (GTK_BOX (vbox_auth), GTK_WIDGET (tbl_auth), FALSE, FALSE, 0);

    /* Miscelleneous settings */
    frm_misc = (GtkFrame*) g_object_new (GTK_TYPE_FRAME, "label", _("Miscelleneous"), NULL);
    gtk_box_pack_start (GTK_BOX (vbox_settings), GTK_WIDGET (frm_misc), FALSE, FALSE, 0);

    vbox_misc = (GtkVBox*) g_object_new (GTK_TYPE_VBOX, "homogeneous", FALSE, "spacing", 6, NULL);
    gtk_container_set_border_width (GTK_CONTAINER (vbox_misc), 6);
    gtk_container_add (GTK_CONTAINER (frm_misc), GTK_WIDGET (vbox_misc));

    tbl_misc = (GtkTable*) g_object_new (GTK_TYPE_TABLE, "n-rows", 1, "n-columns", 1, "homogeneous", FALSE, "row-spacing", 6, "column-spacing", 6, NULL);

    /* Folder Size */
    lbl_fsize = (GtkLabel*) g_object_new (GTK_TYPE_LABEL, "label", _("View the size of all Exchange folders"), NULL);
    gtk_misc_set_alignment (GTK_MISC (lbl_fsize), 0, 0.5);
    btn_fsize = (GtkButton*) g_object_new (GTK_TYPE_BUTTON, "label", _("Folders Size"), NULL);
    g_signal_connect (btn_fsize, "clicked", G_CALLBACK (btn_fsize_clicked), NULL);
    gtk_table_attach_defaults (tbl_misc, GTK_WIDGET (lbl_fsize), 0, 1, 0, 1);
    gtk_table_attach (tbl_misc, GTK_WIDGET (btn_fsize), 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
    gtk_box_pack_start (GTK_BOX (vbox_misc), GTK_WIDGET (tbl_misc), FALSE, FALSE, 0);

    gtk_widget_show_all (GTK_WIDGET (vbox_settings));
    gtk_notebook_insert_page (GTK_NOTEBOOK (data->parent), GTK_WIDGET (vbox_settings), gtk_label_new(_("Exchange Settings")), 4);
    return GTK_WIDGET (vbox_settings);

}
Пример #28
0
CamelStore *
e_mail_store_add_by_account (EMailBackend *backend,
                             EAccount *account)
{
	EMailSession *session;
	CamelService *service = NULL;
	CamelProvider *provider;
	CamelURL *url;
	gboolean skip = FALSE, transport_only;
	GError *error = NULL;

	g_return_val_if_fail (E_IS_MAIL_BACKEND (backend), NULL);
	g_return_val_if_fail (E_IS_ACCOUNT (account), NULL);

	session = e_mail_backend_get_session (backend);

	/* check whether it's transport-only accounts */
	transport_only = !account->source || !account->source->url || !*account->source->url;
	if (transport_only)
		goto handle_transport;

	/* Load the service, but don't connect.  Check its provider,
	 * and if this belongs in the folder tree model, add it. */

	provider = camel_provider_get (account->source->url, &error);
	if (provider == NULL) {
	/* In case we do not have a provider here, we handle
	 * the special case of having multiple mail identities
	 * eg. a dummy account having just SMTP server defined */
		goto handle_transport;
	}

	service = camel_session_add_service (
		CAMEL_SESSION (session),
		account->uid, account->source->url,
		CAMEL_PROVIDER_STORE, &error);

	camel_service_set_display_name (service, account->name);

handle_transport:

	if (account->transport) {
		/* While we're at it, add the account's transport to the
		 * CamelSession.  The transport's UID is a kludge for now.
		 * We take the EAccount's UID and tack on "-transport". */
		gchar *transport_uid;
		GError *transport_error = NULL;

		transport_uid = g_strconcat (
			account->uid, "-transport", NULL);

		camel_session_add_service (
			CAMEL_SESSION (session),
			transport_uid, account->transport->url,
			CAMEL_PROVIDER_TRANSPORT, &transport_error);

		g_free (transport_uid);

		if (transport_error) {
			g_warning (
				"%s: Failed to add transport service: %s",
				G_STRFUNC, transport_error->message);
			g_error_free (transport_error);
		}
	}

	if (transport_only)
		return NULL;

	if (!CAMEL_IS_STORE (service))
		goto fail;

	/* Do not add local-delivery files,
	 * but make them ready for later use. */
	url = camel_url_new (account->source->url, NULL);
	if (url != NULL) {
		skip = em_utils_is_local_delivery_mbox_file (url);
		camel_url_free (url);
	}

	if (!skip && (provider->flags & CAMEL_PROVIDER_IS_STORAGE))
		e_mail_store_add (backend, CAMEL_STORE (service));

	return CAMEL_STORE (service);

fail:
	/* FIXME: Show an error dialog. */
	g_warning (
		"Couldn't get service: %s: %s", account->name,
		error ? error->message : "Not a CamelStore");
	if (error)
		g_error_free (error);

	return NULL;
}
Пример #29
0
void
imap_headers_commit (EPlugin *efp, EConfigHookItemFactoryData *data)
{
	EMConfigTargetAccount *target_account;
	EAccount *account;
	gboolean use_imap = g_getenv ("USE_IMAP") != NULL;

	target_account = (EMConfigTargetAccount *)data->config->target;
	account = target_account->account;

	if (g_str_has_prefix (account->source->url, "imap://") ||
			(use_imap && g_str_has_prefix (account->source->url, "groupwise://"))) {
		EAccount *temp = NULL;
		EAccountList *accounts = mail_config_get_accounts ();
		CamelURL *url = NULL;
		CamelException ex;
		GtkTreeModel *model;
		GtkTreeIter iter;
		GString *str;
		gchar *header = NULL;

		str = g_string_new("");

		temp = mail_config_get_account_by_source_url (account->source->url);

		url = camel_url_new (e_account_get_string(account, E_ACCOUNT_SOURCE_URL), &ex);

		model = gtk_tree_view_get_model (ui->custom_headers_tree);
		if (gtk_tree_model_get_iter_first(model, &iter)) {
			do
			{
				header = NULL;
				gtk_tree_model_get (model, &iter, 0, &header, -1);
				str = g_string_append (str, g_strstrip(header));
				str = g_string_append (str, " ");
				g_free (header);
			} while (gtk_tree_model_iter_next(model, &iter));
		}

		header = g_strstrip(g_strdup(str->str));
		camel_url_set_param (url, "imap_custom_headers", header);
		g_free (header);

		if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ui->all_headers))) {
			camel_url_set_param (url, "all_headers", "1");
			camel_url_set_param (url, "basic_headers", NULL);
		} else if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ui->basic_headers))) {
			camel_url_set_param (url, "basic_headers", "1");
			camel_url_set_param (url, "all_headers", NULL);
		} else {
			camel_url_set_param (url, "all_headers", NULL);
			camel_url_set_param (url, "basic_headers", NULL);
		}

		e_account_set_string (temp, E_ACCOUNT_SOURCE_URL, camel_url_to_string (url, 0));
		camel_url_free (url);
		g_string_free (str, TRUE);
		e_account_list_change (accounts, temp);
		e_account_list_save (accounts);
	}
}
Пример #30
0
CamelFolder *
mail_tool_uri_to_folder (const char *uri, guint32 flags, CamelException *ex)
{
	CamelURL *url;
	CamelStore *store = NULL;
	CamelFolder *folder = NULL;
	int offset = 0;
	char *curi = NULL;

	g_return_val_if_fail (uri != NULL, NULL);

	/* TODO: vtrash and vjunk are no longer used for these uri's */
	if (!strncmp (uri, "vtrash:", 7))
		offset = 7;
	else if (!strncmp (uri, "vjunk:", 6))
		offset = 6;
	else if (!strncmp(uri, "email:", 6)) {
		/* FIXME?: the filter:get_folder callback should do this itself? */
		curi = em_uri_to_camel(uri);
		if (uri == NULL) {
			camel_exception_setv(ex, CAMEL_EXCEPTION_SYSTEM, _("Invalid folder: `%s'"), uri);
			return NULL;
		}
		uri = curi;
	}

	url = camel_url_new (uri + offset, ex);
	if (!url) {
		g_free(curi);
		return NULL;
	}

	store = (CamelStore *)camel_session_get_service(session, uri+offset, CAMEL_PROVIDER_STORE, ex);
	if (store) {
		const char *name;

		/* if we have a fragment, then the path is actually used by the store,
		   so the fragment is the path to the folder instead */
		if (url->fragment) {
			name = url->fragment;
		} else {
			if (url->path && *url->path)
				name = url->path + 1;
			else
				name = "";
		}

		if (offset) {
			if (offset == 7)
				folder = camel_store_get_trash (store, ex);
			else if (offset == 6)
				folder = camel_store_get_junk (store, ex);
		} else
			folder = camel_store_get_folder (store, name, flags, ex);
		camel_object_unref (store);
	}

	if (folder)
		mail_note_folder (folder);

	camel_url_free (url);
	g_free(curi);

	return folder;
}