How gpgtools/gpgservices works
Project type and purpose
• Type: Native macOS application bundle that installs a Services-menu extension.
• Purpose: Let users encrypt/decrypt/sign/verify files or text via the macOS Services menu, wrapping calls to GnuPG/MacGPG2.
File structure
• Dependencies/
– Zxcvbn library (password‐strength scoring).
– ZipKit library (zip/unzip support).
• Source/
– ServiceWorker, ServiceWrappedOperation, ZipOperation core classes.
– UI controllers: KeyChooserWindowController, RecipientWindowController, InProgressWindowController, VerificationResultsWindow, SimpleTextWindow, etc.
• Resources/
• Top-level
– Makefile + Xcode project (GPGServices.xcodeproj)
– Version.config, Info.plist
README for additional insights
• External requirements: MacGPG2 + Libmacgpg + GnuPG.
• Build uses Makefile & Xcode.
• MacOS Services integration.
Main components & interactions
a. OS Integration Layer
– macOS Services menu dispatch → ServiceWorker (implements NSUserInterfaceItem-Validation & NSServiceRequest).
b. Core Service Layer
– ServiceWorkerDelegate & ServiceWrappedOperation: wrap user request into an asynchronous operation.
– ZipOperation: compress/decompress attachments if requested.
– GKPasswordStrengthIndicator uses Zxcvbn lib to score user‐entered passphrase.
– ServiceWrappedOperation → invokes Libmacgpg/MacGPG2 command‐line tool or links against Libmacgpg to perform crypto.
c. UI Layer
– KeyChooserWindowController: prompt for which key to use.
– RecipientWindowController: prompt for recipients.
– InProgressWindowController: show progress via WorkerProgressViewItem.
– VerificationResultsWindow: display signature verification results.
– SimpleTextWindow: input/output text.
d. External Dependencies
– Zxcvbn (password strength)
– ZipKit (archive operations)
– Libmacgpg/GnuPG (actual crypto engine)
Architectural patterns & design principles
• Separation of concerns:
– UI controllers only handle user interaction & window management.
– Core service classes handle background work & OS communication.
– Dependencies layered in their own subdirectories.
• Asynchronous operations via NSOperation subclasses.
• Plugin/extension pattern: code installs as a Services provider.
• Clear component labels (class names, libraries, frameworks).