예제 #1
0
int main()
{
    int res = EXIT_SUCCESS;
    ews::set_up();

    try
    {
        const auto env = ews::test::environment();
        auto service = ews::service(env.server_uri, env.domain, env.username,
                                    env.password);

        auto search_expression =
            ews::is_equal_to(ews::item_property_path::has_attachments, true);
        ews::distinguished_folder_id drafts = ews::standard_folder::drafts;
        auto ids = service.find_item(drafts, search_expression);

        if (ids.empty())
        {
            std::cout << "No messages with attachment found!\n";
        }
        else
        {
            // Get and save attachments of first message we just found. We
            // assume these are PNG images

            auto msg = service.get_message(ids[0]);

            auto i = 0;
            auto attachments = msg.get_attachments();
            for (const auto& attachment : attachments)
            {
                auto target_path = "test" + std::to_string(i++) + ".png";
                const auto bytes_written =
                    service.get_attachment(attachment.id())
                        .write_content_to_file(target_path);
                std::cout << bytes_written << std::endl;
            }
        }
    }
    catch (std::exception& exc)
    {
        std::cout << exc.what() << std::endl;
        res = EXIT_FAILURE;
    }

    ews::tear_down();
    return res;
}
예제 #2
0
gs_zstencil_t device_zstencil_create(gs_device_t device, uint32_t width,
		uint32_t height, enum gs_zstencil_format format)
{
	struct gs_zstencil_buffer *zs;

	zs = bzalloc(sizeof(struct gs_zstencil_buffer));
	zs->format     = convert_zstencil_format(format);
	zs->attachment = get_attachment(format);
	zs->device     = device;

	if (!gl_init_zsbuffer(zs, width, height)) {
		blog(LOG_ERROR, "device_zstencil_create (GL) failed");
		gs_zstencil_destroy(zs);
		return NULL;
	}

	return zs;
}