Giter Club home page Giter Club logo

mapirs's Introduction

Mapirs

This is a small, windows-only dynamic library that can be used to translate Windows MAPI calls to command line arguments.

It handles calls to the functions defined in the mapi.h header, which is not available directly from Microsoft anymore. You can get it from https://github.com/stephenegriffin/MAPIStubLibrary/blob/master/include/MAPI.h

The main purpose is to enable Tutanota Desktop on Windows to handle requests to send files via mail, like they can be issued via the File Explorer context menu or in programs like MS Office and LibreOffice.

Build

Compile on windows

The project is set up to compile for the x86_64-pc-windows-gnu target by default, so if you're developing on windows, you'll have to override .cargo/config.toml as shown in the "Commands" section below.

Prerequisites

  • Microsoft Visual C++ 2019 build tools
  • cargo

Commands

cargo build --target "x86_64-pc-windows-msvc"

or

cargo build --release --target "x86_64-pc-windows-msvc"

the dll will be placed in ./target/x86_64-pc-windows-msvc/{release,debug}/mapirs.dll

Crosscompile on Linux

The project is set up so "cargo build" will use the x86_64-pc-windows-gnu target. Running tests requires wine to be installed.

Prerequisites

  • package gcc-mingw-w64
  • cargo
  • wine

Commands

cargo build

or

cargo build --release

the dll will be placed in ./target/x86_64-pc-windows-gnu/{release,debug}/mapirs.dll

Notes

  • To get the IntelliJ IDEA Rust Plugin to ignore/check code that is inactive due to attributes like #[cfg(target_os = "windows")], open Ctrl + Shift + A -> Registry... and toggle org.rust.lang.cfg.attributes
  • licenses.html has been generated with https://github.com/EmbarkStudios/cargo-about : cargo-about init and then cargo-about generate about.hbs > licenses.html
  • the CI script uses clippy and rustfmt to check the code, so run cargo clippy and cargo fmt before committing (in that order)

mapirs's People

Contributors

ganthern avatar johnbotris avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapirs's Issues

Check if the tmp directory contains a file with the same name before copying attachments

Due to the way MAPISendMail gets its arguments, there may theoretically be cases where the DLL copies multiple files into the tmp directory that end up having the same name.

Example: Message with two attachment FileDescriptors like

  • path_name = C:\tmp\1234.pdf, file_name = resume.pdf
  • path_name = C:\tmp\1235.pdf, file_name = resume.pdf

Currently, we would copy both files to C:\Users\u\AppData\Temp\tutanota\attach\resume.pdf

Implement MAPISendDocuments

MAPISendMail seems to be the function that's used by all applications that support MAPI for sending files, but it would be easy to implement MAPISendDocuments by generating a Message instance containing the paths and names passed to MAPISendDocuments.

The fact that MAPISendDocuments is still on the Microsoft docs page (https://docs.microsoft.com/en-us/windows/win32/api/mapi/nc-mapi-mapisenddocuments) while MAPISendMail 404's (https://docs.microsoft.com/en-us/windows/win32/api/mapi/nc-mapi-mapisendmail) suggests that there may be some deprecation coming.

Defensively copy file passed to mapirs

Some applications (i.e. Acrobat) will pass in a path to a temp file, which they will then delete once the mapi dll returns, so by the time Tutanota has started up, the file no longer exists. We should make a copy of all files passed in so we can be sure they still exist, like we already do when we need to rename the file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.