├── .gitignore
├── .gitmodules
├── .travis.yml
├── COPYING
├── Doxyfile
├── Makefile
├── README.md
├── plugin_tests
└── various_tests.html
└── webpgPlugin
├── CMakeLists.txt
├── Factory.cpp
├── Mac
├── bundle_template
│ ├── Info.plist
│ ├── InfoPlist.strings
│ └── Localized.r
└── projectDef.cmake
├── PluginConfig.cmake
├── Win
├── WiX
│ └── webpgPluginInstaller.wxs
└── projectDef.cmake
├── X11
└── projectDef.cmake
├── webpgPlugin.cpp
├── webpgPlugin.h
├── webpgPluginAPI.cpp
└── webpgPluginAPI.h
/.gitignore:
--------------------------------------------------------------------------------
1 | build/
2 | *.swp
3 | *.patch
4 | *~
5 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "firebreath"]
2 | path = firebreath
3 | url = git://github.com/firebreath/FireBreath.git
4 | [submodule "webpgPlugin/libwebpg"]
5 | path = webpgPlugin/libwebpg
6 | url = git://github.com/kylehuff/libwebpg.git
7 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | install: make get-deps
2 | test: make build
3 | script: make build
4 | language: cpp
5 | compiler:
6 | - gcc
7 | - clang
8 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | License
2 |
3 | webpg-npapi is Free Software and available under the GNU General Public License (GNU GPL).
4 |
5 | Copyright (C) 2010-2011 Kyle L. Huff, CURE|THE|ITCH [http://www.curetheitch.com]
6 |
7 | webpg-npapi is free software; you can redistribute it and/or
8 | modify it under the terms of the GNU General Public License as
9 | published by the Free Software Foundation; either version 2 of
10 | the License, or (at your option) any later version.
11 |
12 | webpg-npapi is distributed in the hope that it will be useful,
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 | General Public License for more details.
16 |
17 | You should have received a copy of the GNU General Public License
18 | along with this program; if not, write to the Free Software
19 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 | 02110-1301, USA
21 |
22 |
23 | Copyright Statements
24 | Here is a list with collected copyright notices. For details see the description of each individual package.
25 |
26 |
27 | FireBreath is
28 |
29 | Copyright 2009, 2010, 2011 Richard Bateman, Firebreath development team
30 |
31 | FireBreath is licensed under a dual license structure, which means that you
32 | can use it either under the New BSD license or under the LGPL v 1.2 license.
33 |
34 | FireBreath is distributed in the hope that it will be useful, but WITHOUT
35 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
36 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
37 | License for more details.
38 |
39 |
40 | GnuPG is
41 |
42 | Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
43 | 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
44 |
45 | GnuPG is free software; you can redistribute it and/or modify it
46 | under the terms of the GNU General Public License as published by
47 | the Free Software Foundation; either version 3 of the License, or
48 | (at your option) any later version.
49 |
50 | GnuPG is distributed in the hope that it will be useful, but WITHOUT
51 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
52 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
53 | License for more details.
54 |
55 | You should have received a copy of the GNU General Public License
56 | along with this program; if not, see http://www.gnu.org/licenses/gpl-3.0.txt.
57 |
58 | See the files AUTHORS and THANKS for credits, further legal
59 | information and bug reporting addresses pertaining to GnuPG.
60 |
61 |
62 | GPGME is
63 |
64 | Copyright (C) 2000 Werner Koch (dd9jn)
65 | Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2008,
66 | 2009 g10 Code GmbH
67 |
68 | GPGME is free software; you can redistribute it and/or modify it
69 | under the terms of the GNU Lesser General Public License as
70 | published by the Free Software Foundation; either version 2.1 of
71 | the License, or (at your option) any later version.
72 |
73 | GPGME is distributed in the hope that it will be useful, but
74 | WITHOUT ANY WARRANTY; without even the implied warranty of
75 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
76 | Lesser General Public License for more details.
77 |
78 | You should have received a copy of the GNU Lesser General Public
79 | License along with this program; if not, see http://www.gnu.org/licenses/lgpl.txt.
80 |
81 | See the files AUTHORS and THANKS for credits, further legal
82 | information and bug reporting addresses pertaining to GPGME.
83 |
84 |
85 | LIBGPG-ERROR is
86 |
87 | Copyright (C) 2003, 2004 g10 Code GmbH
88 |
89 | libgpg-error is free software; you can redistribute it and/or
90 | modify it under the terms of the GNU Lesser General Public License
91 | as published by the Free Software Foundation; either version 2.1 of
92 | the License, or (at your option) any later version.
93 |
94 | libgpg-error is distributed in the hope that it will be useful, but
95 | WITHOUT ANY WARRANTY; without even the implied warranty of
96 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
97 | Lesser General Public License for more details.
98 |
99 | You should have received a copy of the GNU Lesser General Public
100 | License along with this program; if not, see http://www.gnu.org/licenses/lgpl.txt.
101 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | SYS := $(shell gcc -dumpmachine)
2 | ifneq (, $(findstring linux, $(SYS)))
3 | OS = LINUX
4 | else ifneq (, $(findstring darwin, $(SYS)))
5 | OS = DARWIN
6 | else
7 | # Remaining should be all Windows (cygwin & mingw)
8 | OS = WINDOWS
9 | VS_VERSION := $(shell read -p "Enter your version of visual studio (i.e. 2008, 2010, 2012): " VS_VER_INPUT;\
10 | echo "$$VS_VER_INPUT";)
11 | endif
12 |
13 | all: get-deps build
14 | .PHONY: all
15 |
16 | get-deps:
17 | git submodule update --init
18 | git submodule update --recursive
19 | .PHONY: get-deps
20 |
21 | build:
22 | @echo "Preparing build for $(OS)"
23 | ifeq ($(OS), WINDOWS)
24 | cmd \/c .\\firebreath\\prep$(VS_VERSION).cmd\ webpgPlugin\ build
25 | else ifeq ($(OS), DARWIN)
26 | ./firebreath/prepmac.sh webpgPlugin build
27 | else
28 | ./firebreath/prepmake.sh webpgPlugin build
29 | endif
30 | ifeq ($(OS), WINDOWS)
31 | cmake --build build --config MinSizeRel
32 | else ifeq ($(OS), DARWIN)
33 | cmake --build build --target webpg --config MinSizeRel
34 | else
35 | cmake --build build --target webpg --config MinSizeRel -- --no-print-directory
36 | endif
37 | .PHONY: build
38 |
39 | clean:
40 | ifeq ($(OS), WINDOWS)
41 | rmdir /S /Q build
42 | rmdir /S /Q CMakeFiles
43 | else
44 | rm -rf ./build
45 | rm -rf ./CMakeFiles
46 | endif
47 | .PHONY: clean
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Description
2 | ===========
3 | webpg-npapi is an [NPAPI](https://developer.mozilla.org/en-US/docs/Plugins) plugin project that provides GnuPG related Public/Private Key operations for use in major browsers.
4 |
5 | This is a [FireBreath](http://www.firebreath.org/display/documentation/FireBreath+Home) NPAPI plugin project, and this repository includes a submodule of FireBreath 1.5
6 |
7 | Documentation
8 | =============
9 | Documentation and Class reference can be found here: http://webpg.org/docs/webpg-npapi/
10 |
11 | Prerequisites
12 | =============
13 | In order for this plugin to work, you must have a working [GnuPG](http://www.gnupg.org/) installation.
14 |
15 | Linux
16 | -----
17 |
18 | On Debian-based systems you can install GNUPG2 by running the command
19 |
20 | ```
21 | sudo apt-get install gnupg2
22 | ```
23 |
24 | Mac OSX
25 | -------
26 |
27 | The easiest way to install on OS X is to use the [GPGTools Installer](https://www.gpgtools.org/).
28 |
29 |
30 | Building Dependencies
31 | =====================
32 | * [cmake](http://www.cmake.org/)
33 |
34 |
35 | Prep Build Environment
36 | ======================
37 | From the root of this repository, type one of the following - depending on your OS:
38 |
39 | Linux
40 | -----
41 |
42 | ```
43 | ./firebreath/prepmake.sh . build
44 | ```
45 |
46 |
47 | Mac OSX
48 | -------
49 |
50 | ### Universal Build ###
51 |
52 | ```
53 | firebreath/prepmac.sh . build
54 | ```
55 |
56 | ### i386 Build ###
57 |
58 | ```
59 | firebreath/prepmac.sh . build -DCMAKE_OSX_ARCHITECTURES=i386 -DCMAKE_BUILD_TYPE=MinSizeRel
60 | ```
61 |
62 | ### x86_64 Build ###
63 |
64 | ```
65 | firebreath/prepmac.sh . build -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_BUILD_TYPE=MinSizeRel
66 | ```
67 |
68 |
69 | MS Windows
70 | ----------
71 |
72 | ### For visual studio 2008 ###
73 |
74 | ```
75 | firebreath\prep2008.cmd . build
76 | ```
77 |
78 | ### For visual studio 2009 ###
79 |
80 | ```
81 | firebreath\prep2009.cmd . build
82 | ```
83 |
84 | ### For visual studio 2010 ###
85 |
86 | ```
87 | firebreath\prep2010.cmd . build
88 | ```
89 |
90 |
91 | Build the WebPG Plugin
92 | ======================
93 |
94 | ```
95 | cd ./build
96 | ```
97 |
98 | Linux
99 | -----
100 |
101 | ```
102 | make webpgPlugin
103 | ```
104 |
105 | Mac OSX
106 | -------
107 |
108 | ```
109 | xcodebuild -target webpgPlugin
110 | ```
111 |
112 | MS Windows
113 | ----------
114 |
115 | ```
116 | cmake --build . --config MinSizeRel --target webpgPlugin
117 | ```
118 |
119 |
120 | Move Copy the plugin file
121 | =========================
122 |
123 | Linux
124 | -----
125 |
126 | The compiled so file can be found at:
127 |
128 |
129 | ```
130 | build/bin/webpgPlugin/npwebpgPlugin.so
131 | ```
132 |
133 |
134 | Mac OSX
135 | -------
136 |
137 | The compiled .plugin file can be found at:
138 |
139 | ```
140 | build/projects/webpgPlugin/MinSizeRel/webpgPlugin.plugin
141 | ```
142 |
143 | MS Windows
144 | ----------
145 |
146 | The compiled .dll file can be found at:
147 |
148 | ```
149 | build\bin\webpgPlugin\MinSizeRel\npwebpgPlugin.dll
150 | ```
151 |
152 |
153 | [](https://bitdeli.com/free "Bitdeli Badge")
154 |
155 |
--------------------------------------------------------------------------------
/plugin_tests/various_tests.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Test page for the WebPG NPAPI Plugin
4 |
5 |
45 |
46 |
47 | Plugin valid:
48 | Unknown
49 | Plugin version:
50 | Unknown
51 | Public Key List:
52 | Not available or empty
53 | Private Key List:
54 | Not available or empty
55 |
56 |
57 |
--------------------------------------------------------------------------------
/webpgPlugin/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | #/**********************************************************\
2 | #
3 | # Auto-generated CMakeLists.txt for the webpg-plugin project
4 | #
5 | #\**********************************************************/
6 |
7 | # Written to work with cmake 2.6
8 | cmake_minimum_required (VERSION 2.6)
9 | set (CMAKE_BACKWARDS_COMPATIBILITY 2.6)
10 |
11 | Project(${PLUGIN_NAME})
12 |
13 | file (GLOB GENERAL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
14 | [^.]*.cpp
15 | [^.]*.h
16 | [^.]*.cmake
17 | )
18 |
19 | file (GLOB LIBWEBPG RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
20 | libwebpg/*.cpp
21 | libwebpg/*.cc
22 | libwebpg/*.h
23 | libwebpg/*.cmake
24 | )
25 |
26 | include_directories(${PLUGIN_INCLUDE_DIRS}
27 | -I ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libcurl/${ARCH_DIR}/include
28 | -I ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libgpgme/${ARCH_DIR}/include
29 | -I ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libgpg-error/${ARCH_DIR}/include
30 | -I ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libmimetic/${ARCH_DIR}/include
31 | )
32 |
33 | # Generated files are stored in ${GENERATED} by the project configuration
34 | SET_SOURCE_FILES_PROPERTIES(
35 | ${GENERATED}
36 | PROPERTIES
37 | GENERATED 1
38 | )
39 |
40 | SOURCE_GROUP(Generated FILES
41 | ${GENERATED}
42 | )
43 |
44 | SET( SOURCES
45 | ${GENERAL}
46 | ${LIBWEBPG}
47 | ${GENERATED}
48 | )
49 |
50 | add_definitions(
51 | -D_FILE_OFFSET_BITS=64
52 | -DCURL_STATICLIB
53 | -DH_LIBWEBPG
54 | )
55 |
56 | # This will include Win/projectDef.cmake, X11/projectDef.cmake, Mac/projectDef
57 | # depending on the platform
58 | include_platform()
59 |
--------------------------------------------------------------------------------
/webpgPlugin/Factory.cpp:
--------------------------------------------------------------------------------
1 | /**********************************************************\
2 |
3 | Auto-generated Factory.cpp
4 |
5 | This file contains the auto-generated factory methods
6 | for the webpgPlugin project
7 |
8 | \**********************************************************/
9 |
10 | #include "FactoryBase.h"
11 | #include "webpgPlugin.h"
12 | #include
13 |
14 | class PluginFactory : public FB::FactoryBase
15 | {
16 | public:
17 | ///////////////////////////////////////////////////////////////////////////////
18 | /// @fn FB::PluginCorePtr createPlugin(const std::string& mimetype)
19 | ///
20 | /// @brief Creates a plugin object matching the provided mimetype
21 | /// If mimetype is empty, returns the default plugin
22 | ///////////////////////////////////////////////////////////////////////////////
23 | FB::PluginCorePtr createPlugin(const std::string& mimetype)
24 | {
25 | return boost::make_shared();
26 | }
27 |
28 | ///////////////////////////////////////////////////////////////////////////////
29 | /// @see FB::FactoryBase::globalPluginInitialize
30 | ///////////////////////////////////////////////////////////////////////////////
31 | void globalPluginInitialize()
32 | {
33 | webpgPlugin::StaticInitialize();
34 | }
35 |
36 | ///////////////////////////////////////////////////////////////////////////////
37 | /// @see FB::FactoryBase::globalPluginDeinitialize
38 | ///////////////////////////////////////////////////////////////////////////////
39 | void globalPluginDeinitialize()
40 | {
41 | webpgPlugin::StaticDeinitialize();
42 | }
43 |
44 | void getLoggingMethods(FB::Log::LogMethodList& outMethods)
45 | {
46 | // The next line will enable logging to the console (think: printf).
47 | outMethods.push_back(std::make_pair(FB::Log::LogMethod_Console, std::string()));
48 |
49 | // The next line will enable logging to a logfile.
50 | //outMethods.push_back(std::make_pair(FB::Log::LogMethod_File, "/tmp/baz.log"));
51 | }
52 | };
53 |
54 | ///////////////////////////////////////////////////////////////////////////////
55 | /// @fn getFactoryInstance()
56 | ///
57 | /// @brief Returns the factory instance for this plugin module
58 | ///////////////////////////////////////////////////////////////////////////////
59 | FB::FactoryBasePtr getFactoryInstance()
60 | {
61 | static boost::shared_ptr factory = boost::make_shared();
62 | return factory;
63 | }
64 |
65 |
--------------------------------------------------------------------------------
/webpgPlugin/Mac/bundle_template/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleExecutable
8 | ${FBSTRING_PluginFileName}
9 | CFBundleGetInfoString
10 | ${PLUGIN_NAME} ${FBSTRING_PLUGIN_VERSION}, ${FBSTRING_LegalCopyright}
11 | CFBundleIdentifier
12 | com.${FBTYPELIB_NAME}.${FBSTRING_PluginName}
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundlePackageType
16 | BRPL
17 | CFBundleShortVersionString
18 | ${FBSTRING_PLUGIN_VERSION}
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | ${FBSTRING_PLUGIN_VERSION}
23 | CFPlugInDynamicRegisterFunction
24 |
25 | CFPlugInDynamicRegistration
26 | NO
27 | CFPlugInFactories
28 |
29 | 00000000-0000-0000-0000-000000000000
30 | MyFactoryFunction
31 |
32 | CFPlugInTypes
33 |
34 | 00000000-0000-0000-0000-000000000000
35 |
36 | 00000000-0000-0000-0000-000000000000
37 |
38 |
39 | CFPlugInUnloadFunction
40 |
41 | WebPluginName
42 | ${FBSTRING_ProductName}
43 | WebPluginDescription
44 | ${FBSTRING_FileDescription}
45 | WebPluginMIMETypes
46 |
47 | @foreach (FBSTRING_MIMEType CUR_MIMETYPE FBSTRING_FileDescription CUR_DESC)
48 | ${CUR_MIMETYPE}
49 |
50 | WebPluginExtensions
51 |
52 |
53 |
54 | WebPluginTypeDescription
55 | ${CUR_DESC}
56 |
57 | @endforeach
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/webpgPlugin/Mac/bundle_template/InfoPlist.strings:
--------------------------------------------------------------------------------
1 | /* Localized versions of Info.plist keys */
2 |
3 | CFBundleName = "np${PLUGIN_NAME}-v${FBSTRING_PLUGIN_VERSION}.plugin";
4 | NSHumanReadableCopyright = "${FBSTRING_LegalCopyright}";
5 |
--------------------------------------------------------------------------------
/webpgPlugin/Mac/bundle_template/Localized.r:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | resource 'STR#' (126)
4 | { {
5 | "${FBSTRING_LegalCopyright}",
6 | "${FBSTRING_ProductName}"
7 | } };
8 |
9 | resource 'STR#' (127)
10 | { {
11 | "",
12 | } };
13 |
14 | resource 'STR#' (128)
15 | { {
16 | @foreach (FBSTRING_MIMEType CUR_MIMETYPE FBSTRING_FileExtents CUR_EXTENT)
17 | "${CUR_MIMETYPE}",
18 | "${CUR_EXTENT}",
19 | @endforeach
20 | } };
21 |
--------------------------------------------------------------------------------
/webpgPlugin/Mac/projectDef.cmake:
--------------------------------------------------------------------------------
1 | #/**********************************************************\
2 | # Auto-generated Mac project definition file for the
3 | # webpg-plugin project
4 | #\**********************************************************/
5 |
6 | # Mac template platform definition CMake file
7 | # Included from ../CMakeLists.txt
8 |
9 | # remember that the current source dir is the project root; this file is in Mac/
10 | file (GLOB PLATFORM RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
11 | Mac/[^.]*.cpp
12 | Mac/[^.]*.h
13 | Mac/[^.]*.cmake
14 | )
15 |
16 | # use this to add preprocessor definitions
17 | add_definitions(
18 | )
19 |
20 | IF(EXTENSIONIZE)
21 | add_definitions(-D_EXTENSIONIZE)
22 | ENDIF(EXTENSIONIZE)
23 |
24 | SOURCE_GROUP(Mac FILES ${PLATFORM})
25 |
26 | set (SOURCES
27 | ${SOURCES}
28 | ${PLATFORM}
29 | )
30 |
31 | set(PLIST "Mac/bundle_template/Info.plist")
32 | set(STRINGS "Mac/bundle_template/InfoPlist.strings")
33 | set(LOCALIZED "Mac/bundle_template/Localized.r")
34 |
35 | add_mac_plugin(${PROJECT_NAME} ${PLIST} ${STRINGS} ${LOCALIZED} SOURCES)
36 |
37 | set_target_properties(${PROJECT_NAME} PROPERTIES
38 | OUTPUT_NAME ${FBSTRING_PluginFileName}
39 | )
40 |
41 | add_library(gpgme STATIC IMPORTED)
42 | set_property(TARGET gpgme PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libgpgme/${ARCH_DIR}/libgpgme-pthread.a)
43 | add_library(gpg-error STATIC IMPORTED)
44 | set_property(TARGET gpg-error PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libgpg-error/${ARCH_DIR}/libgpg-error.a)
45 | add_library(assuan STATIC IMPORTED)
46 | set_property(TARGET assuan PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libassuan/${ARCH_DIR}/libassuan.a)
47 | add_library(curl STATIC IMPORTED)
48 | set_property(TARGET curl PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libcurl/${ARCH_DIR}/libcurl.a)
49 | add_library(cyassl STATIC IMPORTED)
50 | set_property(TARGET cyassl PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libcurl/${ARCH_DIR}/libcyassl.a)
51 | add_library(zlib STATIC IMPORTED)
52 | set_property(TARGET zlib PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libcurl/${ARCH_DIR}/libz.a)
53 | add_library(mimetic STATIC IMPORTED)
54 | set_property(TARGET mimetic PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libmimetic/${ARCH_DIR}/libmimetic.a)
55 |
56 | # add library dependencies here; leave ${PLUGIN_INTERNAL_DEPS} there unless you know what you're doing!
57 | target_link_libraries(${PROJECT_NAME}
58 | ${PLUGIN_INTERNAL_DEPS}
59 | gpgme
60 | gpg-error
61 | assuan
62 | cyassl
63 | zlib
64 | curl
65 | mimetic
66 | )
67 |
--------------------------------------------------------------------------------
/webpgPlugin/PluginConfig.cmake:
--------------------------------------------------------------------------------
1 | #/**********************************************************\
2 | #
3 | # Auto-Generated Plugin Configuration file
4 | # for webpg-plugin
5 | #
6 | #\**********************************************************/
7 |
8 | set(PLUGIN_NAME "webpg")
9 | set(PLUGIN_PREFIX "WEBPG")
10 | set(COMPANY_NAME "CURETHEITCH")
11 | set(CMAKE_BUILD_TYPE MinSizeRel)
12 |
13 | # ActiveX constants:
14 | set(FBTYPELIB_NAME webpgPluginLib)
15 | set(FBTYPELIB_DESC "webpgPlugin 1.0 Type Library")
16 | set(IFBControl_DESC "webpgPlugin Control Interface")
17 | set(FBControl_DESC "webpgPlugin Control Class")
18 | set(IFBComJavascriptObject_DESC "webpgPlugin IComJavascriptObject Interface")
19 | set(FBComJavascriptObject_DESC "webpgPlugin ComJavascriptObject Class")
20 | set(IFBComEventSource_DESC "webpgPlugin IFBComEventSource Interface")
21 | set(AXVERSION_NUM "1")
22 |
23 | # NOTE: THESE GUIDS *MUST* BE UNIQUE TO YOUR PLUGIN/ACTIVEX CONTROL! YES, ALL OF THEM!
24 | set(FBTYPELIB_GUID 9956ffdf-143c-5b7b-89c6-8a53bccb9969)
25 | set(IFBControl_GUID eef357f7-e5d4-59ff-870d-205a046a3227)
26 | set(FBControl_GUID b9c848b5-3ffb-5847-a6d6-4f9478a7a76f)
27 | set(IFBComJavascriptObject_GUID db5b6071-e2b3-596a-abf0-5c62fa84908b)
28 | set(FBComJavascriptObject_GUID 43b488b4-8132-58e9-87ee-79f96eaa01f2)
29 | set(IFBComEventSource_GUID 7e55f947-88bb-5929-bd9d-7395de30fd0f)
30 |
31 | # these are the pieces that are relevant to using it from Javascript
32 | set(ACTIVEX_PROGID "CURETHEITCH.webpg-npapi")
33 | set(MOZILLA_PLUGINID "curetheitch.com/webpg-npapi")
34 |
35 | # enable pre-compiled headers
36 | set(FB_USE_PCH TRUE)
37 |
38 | # Sets the plugin in "extension only mode"
39 | # See note at http://webpg.org/docs/webpg-npapi/classwebpg_plugin_a_p_i_af99142391c5049c827cbe035812954f4.html
40 | set(EXTENSIONIZE TRUE)
41 |
42 | # Force building 32bit on 64bit
43 | # TRUE: Build 32bit on 64bit
44 | # FALSE: Build matching architecture
45 | set(FORCE32 FALSE)
46 |
47 | MESSAGE(STATUS "${CMAKE_SYSTEM_PROCESSOR} / ${CMAKE_SYSTEM_NAME}")
48 |
49 | IF(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" OR CMAKE_SYSTEM_NAME MATCHES "Windows" OR FORCE32 OR CMAKE_SYSTEM_PROCESSOR MATCHES "armv7")
50 | # Currently maps *BSD to FreeBSD; may require more finite definition to make a
51 | # distinction between FreeBSD and openBSD, etc.
52 | IF(CMAKE_SYSTEM_NAME MATCHES "BSD")
53 | set(ARCH_DIR "FreeBSD_x86-gcc")
54 | ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7")
55 | set(ARCH_DIR "Linux_armv7-gcc")
56 | ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
57 | set(ARCH_DIR "Linux_x86-gcc")
58 | ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
59 | set(ARCH_DIR "WINNT_x86-msvc")
60 | ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
61 | set(ARCH_DIR "Darwin_x86_64-gcc")
62 | ENDIF(CMAKE_SYSTEM_NAME MATCHES "BSD")
63 | ELSE ()
64 | IF(CMAKE_SYSTEM_NAME MATCHES "BSD")
65 | set(ARCH_DIR "FreeBSD_x86_64-gcc")
66 | ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Linux")
67 | set(ARCH_DIR "Linux_x86_64-gcc")
68 | ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Windows")
69 | set(ARCH_DIR "WINNT_x86-msvc")
70 | ELSEIF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
71 | set(ARCH_DIR "Darwin_x86_64-gcc")
72 | ENDIF(CMAKE_SYSTEM_NAME MATCHES "BSD")
73 | ENDIF()
74 |
75 | message("Target architecture: ${ARCH_DIR}")
76 |
77 | IF(EXTENSIONIZE)
78 | message("Setting _EXTENSIONIZE")
79 | set(PLUGIN_EXTENTIONIZE_NAME "-ext")
80 | ELSE ()
81 | set(PLUGIN_EXTENTIONIZE_NAME "")
82 | ENDIF(EXTENSIONIZE)
83 |
84 | # strings
85 | set(FBSTRING_CompanyName "CURE|THE|ITCH")
86 | set(FBSTRING_FileDescription "A browser agnostic NPAPI interface to GnuPG")
87 | set(FBSTRING_PLUGIN_VERSION "0.8.0")
88 | set(FBSTRING_LegalCopyright "Copyright 2011-2013 CURE|THE|ITCH")
89 | set(FBSTRING_PluginFileName "np${PLUGIN_NAME}${PLUGIN_EXTENTIONIZE_NAME}-v${FBSTRING_PLUGIN_VERSION}-${ARCH_DIR}")
90 | set(FBSTRING_ProductName "WebPG")
91 | set(FBSTRING_FileExtents "")
92 | set(FBSTRING_PluginName "WebPG")
93 | set(FBSTRING_PluginDescription "A browser agnostic NPAPI interface to GnuPG")
94 | set(FBSTRING_MIMEType "application/x-webpg")
95 |
96 | # Uncomment this next line if you're not planning on your plugin doing
97 | # any drawing:
98 | set (FB_GUI_DISABLED 1)
99 |
100 | # Mac plugin settings. If your plugin does not draw, set these all to 0
101 | set(FBMAC_USE_QUICKDRAW 0)
102 | set(FBMAC_USE_CARBON 0)
103 | set(FBMAC_USE_COCOA 0)
104 | set(FBMAC_USE_COREGRAPHICS 0)
105 | set(FBMAC_USE_COREANIMATION 0)
106 | set(FBMAC_USE_INVALIDATINGCOREANIMATION 0)
107 |
108 | # If you want to register per-machine on Windows, uncomment this line
109 | #set (FB_ATLREG_MACHINEWIDE 1)
110 |
111 | add_boost_library(regex)
112 | add_firebreath_library(jsoncpp)
113 |
--------------------------------------------------------------------------------
/webpgPlugin/Win/WiX/webpgPluginInstaller.wxs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
34 |
35 |
36 |
43 |
44 |
45 |
46 |
47 |
54 |
55 |
56 |
57 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/webpgPlugin/Win/projectDef.cmake:
--------------------------------------------------------------------------------
1 | #/**********************************************************\
2 | # Auto-generated Windows project definition file for the
3 | # webpg-plugin project
4 | #\**********************************************************/
5 |
6 | # Windows template platform definition CMake file
7 | # Included from ../CMakeLists.txt
8 |
9 | # remember that the current source dir is the project root; this file is in Win/
10 | file (GLOB PLATFORM RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
11 | Win/[^.]*.cpp
12 | Win/[^.]*.h
13 | Win/[^.]*.cmake
14 | )
15 |
16 | # use this to add preprocessor definitions
17 | add_definitions(
18 | /D "_ATL_STATIC_REGISTRY"
19 | /D "HAVE_W32_SYSTEM"
20 | /D "_FILE_OFFSET_BITS=64"
21 | )
22 |
23 | IF(EXTENSIONIZE)
24 | add_definitions(/D "_EXTENSIONIZE")
25 | ENDIF(EXTENSIONIZE)
26 |
27 | SOURCE_GROUP(Win FILES ${PLATFORM})
28 |
29 | set (SOURCES
30 | ${SOURCES}
31 | ${PLATFORM}
32 | )
33 |
34 | add_windows_plugin(${PROJECT_NAME} SOURCES)
35 |
36 | set_target_properties(${PROJECT_NAME} PROPERTIES
37 | OUTPUT_NAME ${FBSTRING_PluginFileName}
38 | )
39 |
40 | # This is an example of how to add a build step to sign the plugin DLL before
41 | # the WiX installer builds. The first filename (certificate.pfx) should be
42 | # the path to your pfx file. If it requires a passphrase, the passphrase
43 | # should be located inside the second file. If you don't need a passphrase
44 | # then set the second filename to "". If you don't want signtool to timestamp
45 | # your DLL then make the last parameter "".
46 | #
47 | # Note that this will not attempt to sign if the certificate isn't there --
48 | # that's so that you can have development machines without the cert and it'll
49 | # still work. Your cert should only be on the build machine and shouldn't be in
50 | # source control!
51 | # -- uncomment lines below this to enable signing --
52 | firebreath_sign_plugin(${PROJECT_NAME}
53 | "${CMAKE_CURRENT_SOURCE_DIR}/sign/certificate.pfx"
54 | "${CMAKE_CURRENT_SOURCE_DIR}/sign/passphrase.txt"
55 | "http://timestamp.verisign.com/scripts/timestamp.dll")
56 |
57 | add_library(gpgme STATIC IMPORTED)
58 | set_property(TARGET gpgme PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libgpgme/${ARCH_DIR}/libgpgme.lib)
59 | add_library(gpg-error STATIC IMPORTED)
60 | set_property(TARGET gpg-error PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libgpg-error/${ARCH_DIR}/libgpg-error.lib)
61 | add_library(assuan STATIC IMPORTED)
62 | set_property(TARGET assuan PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libassuan/${ARCH_DIR}/libassuan.lib)
63 | add_library(curl STATIC IMPORTED)
64 | set_property(TARGET curl PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libcurl/${ARCH_DIR}/libcurl.a)
65 | add_library(mimetic STATIC IMPORTED)
66 | set_property(TARGET mimetic PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libmimetic/${ARCH_DIR}/libmimetic.lib)
67 |
68 | # add library dependencies here; leave ${PLUGIN_INTERNAL_DEPS} there unless you know what you're doing!
69 | target_link_libraries(${PROJECT_NAME}
70 | ${PLUGIN_INTERNAL_DEPS}
71 | gpgme
72 | assuan
73 | gpg-error
74 | mimetic
75 | curl
76 | )
77 |
78 | #set(WIX_HEAT_FLAGS
79 | # -gg # Generate GUIDs
80 | # -srd # Suppress Root Dir
81 | # -cg PluginDLLGroup # Set the Component group name
82 | # -dr INSTALLDIR # Set the directory ID to put the files in
83 | # )
84 |
85 | #add_wix_installer( ${PLUGIN_NAME}
86 | # ${CMAKE_CURRENT_SOURCE_DIR}/Win/WiX/webpgPluginInstaller.wxs
87 | # PluginDLLGroup
88 | # ${FB_BIN_DIR}/${PLUGIN_NAME}/${CMAKE_CFG_INTDIR}/
89 | # ${FB_BIN_DIR}/${PLUGIN_NAME}/${CMAKE_CFG_INTDIR}/${FBSTRING_PluginFileName}.dll
90 | # ${PROJECT_NAME}
91 | # )
92 |
93 | # This is an example of how to add a build step to sign the WiX installer
94 | # -- uncomment lines below this to enable signing --
95 | #firebreath_sign_file("${PLUGIN_NAME}_WiXInstall"
96 | # "${FB_BIN_DIR}/${PLUGIN_NAME}/${CMAKE_CFG_INTDIR}/${PLUGIN_NAME}.msi"
97 | # "${CMAKE_CURRENT_SOURCE_DIR}/sign/certificate.pfx"
98 | # "${CMAKE_CURRENT_SOURCE_DIR}/sign/passphrase.txt"
99 | # "http://timestamp.verisign.com/scripts/timestamp.dll")
100 |
--------------------------------------------------------------------------------
/webpgPlugin/X11/projectDef.cmake:
--------------------------------------------------------------------------------
1 | #/**********************************************************\
2 | # Auto-generated X11 project definition file for the
3 | # webpg-plugin project
4 | #\**********************************************************/
5 |
6 | # X11 template platform definition CMake file
7 | # Included from ../CMakeLists.txt
8 |
9 | # remember that the current source dir is the project root; this file is in X11/
10 | file (GLOB PLATFORM RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
11 | X11/[^.]*.cpp
12 | X11/[^.]*.h
13 | X11/[^.]*.cmake
14 | )
15 |
16 | SOURCE_GROUP(X11 FILES ${PLATFORM})
17 |
18 | # use this to add preprocessor definitions
19 | add_definitions(
20 | "-D_WIN32_WINNT=0x0501"
21 | "-D_WIN32_WINDOWS"
22 | )
23 |
24 | IF(EXTENSIONIZE)
25 | add_definitions(-D_EXTENSIONIZE)
26 | ENDIF(EXTENSIONIZE)
27 |
28 | set (SOURCES
29 | ${SOURCES}
30 | ${PLATFORM}
31 | )
32 |
33 | add_x11_plugin(${PROJECT_NAME} SOURCES)
34 |
35 | IF(FORCE32)
36 | set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
37 | ENDIF(FORCE32)
38 |
39 | set_target_properties(${PROJECT_NAME} PROPERTIES
40 | OUTPUT_NAME ${FBSTRING_PluginFileName}
41 | )
42 |
43 | add_library(gpgme STATIC IMPORTED)
44 | set_property(TARGET gpgme PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libgpgme/${ARCH_DIR}/libgpgme-pthread.a)
45 | add_library(gpg-error STATIC IMPORTED)
46 | set_property(TARGET gpg-error PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libgpg-error/${ARCH_DIR}/libgpg-error.a)
47 | add_library(assuan STATIC IMPORTED)
48 | set_property(TARGET assuan PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libassuan/${ARCH_DIR}/libassuan.a)
49 | add_library(curl STATIC IMPORTED)
50 | set_property(TARGET curl PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libcurl/${ARCH_DIR}/libcurl.a)
51 | add_library(mimetic STATIC IMPORTED)
52 | set_property(TARGET mimetic PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/libwebpg/libs/libmimetic/${ARCH_DIR}/libmimetic.a)
53 |
54 | target_link_libraries(${PROJECT_NAME}
55 | ${PLUGIN_INTERNAL_DEPS}
56 | gpgme
57 | assuan
58 | gpg-error
59 | curl
60 | mimetic
61 | )
62 |
63 | IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
64 | target_link_libraries(${PROJECT_NAME}
65 | rt
66 | )
67 | ENDIF()
68 |
--------------------------------------------------------------------------------
/webpgPlugin/webpgPlugin.cpp:
--------------------------------------------------------------------------------
1 | /**********************************************************\
2 |
3 | Auto-generated webpgPlugin.cpp
4 |
5 | This file contains the auto-generated main plugin object
6 | implementation for the webpg-plugin project
7 |
8 | \**********************************************************/
9 |
10 | #include "webpgPluginAPI.h"
11 |
12 | #include "webpgPlugin.h"
13 |
14 | ///////////////////////////////////////////////////////////////////////////////
15 | /// @fn webpgPlugin::StaticInitialize()
16 | ///
17 | /// @brief Called from PluginFactory::globalPluginInitialize()
18 | ///
19 | /// @see FB::FactoryBase::globalPluginInitialize
20 | ///////////////////////////////////////////////////////////////////////////////
21 | void webpgPlugin::StaticInitialize()
22 | {
23 | // Place one-time initialization stuff here; As of FireBreath 1.4 this should only
24 | // be called once per process
25 | }
26 |
27 | ///////////////////////////////////////////////////////////////////////////////
28 | /// @fn webpgPlugin::StaticInitialize()
29 | ///
30 | /// @brief Called from PluginFactory::globalPluginDeinitialize()
31 | ///
32 | /// @see FB::FactoryBase::globalPluginDeinitialize
33 | ///////////////////////////////////////////////////////////////////////////////
34 | void webpgPlugin::StaticDeinitialize()
35 | {
36 | // Place one-time deinitialization stuff here. As of FireBreath 1.4 this should
37 | // always be called just before the plugin library is unloaded
38 | }
39 |
40 | ///////////////////////////////////////////////////////////////////////////////
41 | /// @brief webpgPlugin constructor. Note that your API is not available
42 | /// at this point, nor the window. For best results wait to use
43 | /// the JSAPI object until the onPluginReady method is called
44 | ///////////////////////////////////////////////////////////////////////////////
45 | webpgPlugin::webpgPlugin()
46 | {
47 | }
48 |
49 | ///////////////////////////////////////////////////////////////////////////////
50 | /// @brief webpgPlugin destructor.
51 | ///////////////////////////////////////////////////////////////////////////////
52 | webpgPlugin::~webpgPlugin()
53 | {
54 | // This is optional, but if you reset m_api (the shared_ptr to your JSAPI
55 | // root object) and tell the host to free the retained JSAPI objects then
56 | // unless you are holding another shared_ptr reference to your JSAPI object
57 | // they will be released here.
58 | releaseRootJSAPI();
59 | m_host->freeRetainedObjects();
60 | }
61 |
62 | void webpgPlugin::onPluginReady()
63 | {
64 | // When this is called, the BrowserHost is attached, the JSAPI object is
65 | // created, and we are ready to interact with the page and such. The
66 | // PluginWindow may or may not have already fire the AttachedEvent at
67 | // this point.
68 | }
69 |
70 | void webpgPlugin::shutdown()
71 | {
72 | // This will be called when it is time for the plugin to shut down;
73 | // any threads or anything else that may hold a shared_ptr to this
74 | // object should be released here so that this object can be safely
75 | // destroyed. This is the last point that shared_from_this and weak_ptr
76 | // references to this object will be valid
77 | }
78 |
79 | ///////////////////////////////////////////////////////////////////////////////
80 | /// @brief Creates an instance of the JSAPI object that provides your main
81 | /// Javascript interface.
82 | ///
83 | /// Note that m_host is your BrowserHost and shared_ptr returns a
84 | /// FB::PluginCorePtr, which can be used to provide a
85 | /// boost::weak_ptr for your JSAPI class.
86 | ///
87 | /// Be very careful where you hold a shared_ptr to your plugin class from,
88 | /// as it could prevent your plugin class from getting destroyed properly.
89 | ///////////////////////////////////////////////////////////////////////////////
90 | FB::JSAPIPtr webpgPlugin::createJSAPI()
91 | {
92 | // m_host is the BrowserHost
93 | return boost::make_shared(FB::ptr_cast(shared_from_this()), m_host);
94 | }
95 |
96 | bool webpgPlugin::onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow *)
97 | {
98 | //printf("Mouse down at: %d, %d\n", evt->m_x, evt->m_y);
99 | return false;
100 | }
101 |
102 | bool webpgPlugin::onMouseUp(FB::MouseUpEvent *evt, FB::PluginWindow *)
103 | {
104 | //printf("Mouse up at: %d, %d\n", evt->m_x, evt->m_y);
105 | return false;
106 | }
107 |
108 | bool webpgPlugin::onMouseMove(FB::MouseMoveEvent *evt, FB::PluginWindow *)
109 | {
110 | //printf("Mouse move at: %d, %d\n", evt->m_x, evt->m_y);
111 | return false;
112 | }
113 | bool webpgPlugin::onWindowAttached(FB::AttachedEvent *evt, FB::PluginWindow *)
114 | {
115 | // The window is attached; act appropriately
116 | return false;
117 | }
118 |
119 | bool webpgPlugin::onWindowDetached(FB::DetachedEvent *evt, FB::PluginWindow *)
120 | {
121 | // The window is about to be detached; act appropriately
122 | return false;
123 | }
124 |
125 |
--------------------------------------------------------------------------------
/webpgPlugin/webpgPlugin.h:
--------------------------------------------------------------------------------
1 | /**********************************************************\
2 |
3 | Auto-generated webpgPlugin.h
4 |
5 | This file contains the auto-generated main plugin object
6 | implementation for the webpg-plugin project
7 |
8 | \**********************************************************/
9 | #ifndef H_webpgPluginPLUGIN
10 | #define H_webpgPluginPLUGIN
11 |
12 | #include "PluginWindow.h"
13 | #include "PluginEvents/MouseEvents.h"
14 | #include "PluginEvents/AttachedEvent.h"
15 |
16 | #include "PluginCore.h"
17 |
18 |
19 | FB_FORWARD_PTR(webpgPlugin)
20 | class webpgPlugin : public FB::PluginCore
21 | {
22 | public:
23 | static void StaticInitialize();
24 | static void StaticDeinitialize();
25 |
26 | public:
27 | webpgPlugin();
28 | virtual ~webpgPlugin();
29 |
30 | public:
31 | void onPluginReady();
32 | void shutdown();
33 | virtual FB::JSAPIPtr createJSAPI();
34 | // If you want your plugin to always be windowless, set this to true
35 | // If you want your plugin to be optionally windowless based on the
36 | // value of the "windowless" param tag, remove this method or return
37 | // FB::PluginCore::isWindowless()
38 | virtual bool isWindowless() { return true; }
39 | std::string getPluginPath() { return m_filesystemPath; }
40 | FB::variant getPluginParams() { return m_params; }
41 |
42 | BEGIN_PLUGIN_EVENT_MAP()
43 | EVENTTYPE_CASE(FB::MouseDownEvent, onMouseDown, FB::PluginWindow)
44 | EVENTTYPE_CASE(FB::MouseUpEvent, onMouseUp, FB::PluginWindow)
45 | EVENTTYPE_CASE(FB::MouseMoveEvent, onMouseMove, FB::PluginWindow)
46 | EVENTTYPE_CASE(FB::MouseMoveEvent, onMouseMove, FB::PluginWindow)
47 | EVENTTYPE_CASE(FB::AttachedEvent, onWindowAttached, FB::PluginWindow)
48 | EVENTTYPE_CASE(FB::DetachedEvent, onWindowDetached, FB::PluginWindow)
49 | END_PLUGIN_EVENT_MAP()
50 |
51 | /** BEGIN EVENTDEF -- DON'T CHANGE THIS LINE **/
52 | virtual bool onMouseDown(FB::MouseDownEvent *evt, FB::PluginWindow *);
53 | virtual bool onMouseUp(FB::MouseUpEvent *evt, FB::PluginWindow *);
54 | virtual bool onMouseMove(FB::MouseMoveEvent *evt, FB::PluginWindow *);
55 | virtual bool onWindowAttached(FB::AttachedEvent *evt, FB::PluginWindow *);
56 | virtual bool onWindowDetached(FB::DetachedEvent *evt, FB::PluginWindow *);
57 | /** END EVENTDEF -- DON'T CHANGE THIS LINE **/
58 | };
59 |
60 | #endif
61 |
--------------------------------------------------------------------------------
/webpgPlugin/webpgPluginAPI.cpp:
--------------------------------------------------------------------------------
1 | /**********************************************************\
2 | Original Author: Kyle L. Huff (kylehuff)
3 |
4 | Created: Jan 14, 2011
5 | License: GNU General Public License, version 2
6 | http://www.gnu.org/licenses/gpl-2.0.html
7 |
8 | Copyright 2011 Kyle L. Huff, CURETHEITCH development team
9 | \**********************************************************/
10 |
11 | #include "JSObject.h"
12 | #include "variant_list.h"
13 | #include "DOM/Document.h"
14 | #include "DOM/Window.h"
15 | #include "global/config.h"
16 |
17 | #include "webpgPluginAPI.h"
18 | #include
19 |
20 | #ifdef HAVE_W32_SYSTEM
21 | #define __func__ __FUNCTION__
22 | #endif
23 |
24 | using namespace std;
25 |
26 | ///////////////////////////////////////////////////////////////////////////////
27 | /// @fn webpgPluginAPI::webpgPluginAPI(const webpgPluginPtr& plugin,
28 | /// const FB::BrowserHostPtr host)
29 | ///
30 | /// @brief Constructor for the JSAPI object. Registers methods, properties,
31 | /// and events that are accessible to Javascript.
32 | ///
33 | /// @see FB::JSAPIAuto::registerMethod
34 | /// @see FB::JSAPIAuto::registerProperty
35 | /// @see FB::JSAPIAuto::registerEvent
36 | ///
37 | /// @note if _EXTENSIONIZE is ture/nonnull, the plugin will only register the
38 | /// provided methods if the plugin was loaded from a page at URL
39 | /// "chrome://" (Mozilla products), "chrome-extension://" (Google
40 | /// Chrome/Chromium), "widget://" (Opera) or "safari-extension://" to
41 | /// prevent the plugin from being loaded by a public web page.
42 | /// This flag is set at compile time, and cannot be modified during
43 | /// operation.
44 | ///////////////////////////////////////////////////////////////////////////////
45 | webpgPluginAPI::webpgPluginAPI(const webpgPluginPtr& plugin,
46 | const FB::BrowserHostPtr& host)
47 | : m_plugin(plugin), m_host(host)
48 | {
49 | static bool allow_op = true;
50 | #ifdef _EXTENSIONIZE
51 | std::string location = m_host->getDOMWindow()->getLocation();
52 | size_t firefox_ext = location.find("chrome://");
53 | size_t chrome_ext = location.find("chrome-extension://");
54 | size_t opera_ext = location.find("widget://");
55 | size_t safari_ext = location.find("safari-extension://");
56 | if (chrome_ext != std::string::npos ||
57 | firefox_ext != std::string::npos ||
58 | opera_ext != std::string::npos ||
59 | safari_ext != std::string::npos)
60 | allow_op = true;
61 | else
62 | allow_op = false;
63 | #endif
64 |
65 | if (allow_op == true) {
66 | registerMethod("getPublicKeyList",
67 | make_method(this, &webpgPluginAPI::getPublicKeyList)
68 | );
69 | registerMethod("getPrivateKeyList",
70 | make_method(this, &webpgPluginAPI::getPrivateKeyList)
71 | );
72 | registerMethod("getNamedKey",
73 | make_method(this, &webpgPluginAPI::getNamedKey)
74 | );
75 | registerMethod("getExternalKey",
76 | make_method(this, &webpgPluginAPI::getExternalKey)
77 | );
78 | registerMethod("gpgSetPreference",
79 | make_method(this, &webpgPluginAPI::gpgSetPreference)
80 | );
81 | registerMethod("gpgGetPreference",
82 | make_method(this, &webpgPluginAPI::gpgGetPreference)
83 | );
84 | registerMethod("gpgSetGroup",
85 | make_method(this, &webpgPluginAPI::gpgSetGroup)
86 | );
87 | registerMethod("gpgSetHomeDir",
88 | make_method(this, &webpgPluginAPI::gpgSetHomeDir)
89 | );
90 | registerMethod("gpgGetHomeDir",
91 | make_method(this, &webpgPluginAPI::gpgGetHomeDir)
92 | );
93 | registerMethod("gpgSetBinary",
94 | make_method(this, &webpgPluginAPI::gpgSetBinary)
95 | );
96 | registerMethod("gpgGetBinary",
97 | make_method(this, &webpgPluginAPI::gpgGetBinary)
98 | );
99 | registerMethod("gpgSetGPGConf",
100 | make_method(this, &webpgPluginAPI::gpgSetGPGConf)
101 | );
102 | registerMethod("gpgGetGPGConf",
103 | make_method(this, &webpgPluginAPI::gpgGetGPGConf));
104 | registerMethod("gpgEncrypt",
105 | make_method(this, &webpgPluginAPI::gpgEncrypt)
106 | );
107 | registerMethod("gpgSymmetricEncrypt",
108 | make_method(this, &webpgPluginAPI::gpgSymmetricEncrypt)
109 | );
110 | registerMethod("gpgDecrypt",
111 | make_method(this, &webpgPluginAPI::gpgDecrypt)
112 | );
113 | registerMethod("gpgVerify",
114 | make_method(this, &webpgPluginAPI::gpgVerify)
115 | );
116 | registerMethod("gpgSignText",
117 | make_method(this, &webpgPluginAPI::gpgSignText)
118 | );
119 | registerMethod("gpgSignUID",
120 | make_method(this, &webpgPluginAPI::gpgSignUID)
121 | );
122 | registerMethod("gpgDeleteUIDSign",
123 | make_method(this, &webpgPluginAPI::gpgDeleteUIDSign)
124 | );
125 | registerMethod("gpgEnableKey",
126 | make_method(this, &webpgPluginAPI::gpgEnableKey)
127 | );
128 | registerMethod("gpgDisableKey",
129 | make_method(this, &webpgPluginAPI::gpgDisableKey)
130 | );
131 | registerMethod("gpgGenKey",
132 | make_method(this, &webpgPluginAPI::gpgGenKey)
133 | );
134 | registerMethod("gpgGenSubKey",
135 | make_method(this, &webpgPluginAPI::gpgGenSubKey)
136 | );
137 | registerMethod("gpgImportKey",
138 | make_method(this, &webpgPluginAPI::gpgImportKey)
139 | );
140 | registerMethod("gpgImportExternalKey",
141 | make_method(this, &webpgPluginAPI::gpgImportExternalKey)
142 | );
143 | registerMethod("gpgDeletePublicKey",
144 | make_method(this, &webpgPluginAPI::gpgDeletePublicKey)
145 | );
146 | registerMethod("gpgDeletePrivateKey",
147 | make_method(this, &webpgPluginAPI::gpgDeletePrivateKey)
148 | );
149 | registerMethod("gpgDeletePrivateSubKey",
150 | make_method(this, &webpgPluginAPI::gpgDeletePrivateSubKey)
151 | );
152 | registerMethod("gpgSetKeyTrust",
153 | make_method(this, &webpgPluginAPI::gpgSetKeyTrust)
154 | );
155 | registerMethod("gpgAddUID",
156 | make_method(this, &webpgPluginAPI::gpgAddUID)
157 | );
158 | registerMethod("gpgDeleteUID",
159 | make_method(this, &webpgPluginAPI::gpgDeleteUID)
160 | );
161 | registerMethod("gpgSetPrimaryUID",
162 | make_method(this, &webpgPluginAPI::gpgSetPrimaryUID)
163 | );
164 | registerMethod("gpgSetSubkeyExpire",
165 | make_method(this, &webpgPluginAPI::gpgSetSubkeyExpire)
166 | );
167 | registerMethod("gpgSetPubkeyExpire",
168 | make_method(this, &webpgPluginAPI::gpgSetPubkeyExpire)
169 | );
170 | registerMethod("gpgExportPublicKey",
171 | make_method(this, &webpgPluginAPI::gpgExportPublicKey)
172 | );
173 | registerMethod("gpgPublishPublicKey",
174 | make_method(this, &webpgPluginAPI::gpgPublishPublicKey)
175 | );
176 | registerMethod("gpgRevokeKey",
177 | make_method(this, &webpgPluginAPI::gpgRevokeKey));
178 | registerMethod("gpgRevokeUID",
179 | make_method(this, &webpgPluginAPI::gpgRevokeUID)
180 | );
181 | registerMethod("gpgRevokeSignature",
182 | make_method(this, &webpgPluginAPI::gpgRevokeSignature)
183 | );
184 | registerMethod("gpgChangePassphrase",
185 | make_method(this, &webpgPluginAPI::gpgChangePassphrase)
186 | );
187 | registerMethod("gpgShowPhoto",
188 | make_method(this, &webpgPluginAPI::gpgShowPhoto));
189 | registerMethod("gpgAddPhoto",
190 | make_method(this, &webpgPluginAPI::gpgAddPhoto)
191 | );
192 | registerMethod("gpgGetPhotoInfo",
193 | make_method(this, &webpgPluginAPI::gpgGetPhotoInfo)
194 | );
195 |
196 | registerMethod("setTempGPGOption",
197 | make_method(this, &webpgPluginAPI::setTempGPGOption)
198 | );
199 | registerMethod("restoreGPGConfig",
200 | make_method(this, &webpgPluginAPI::restoreGPGConfig)
201 | );
202 | registerMethod("getTemporaryPath",
203 | make_method(this, &webpgPluginAPI::getTemporaryPath)
204 | );
205 |
206 | registerMethod("sendMessage",
207 | make_method(this, &webpgPluginAPI::sendMessage)
208 | );
209 |
210 | registerMethod("setStringMode",
211 | make_method(this, &webpgPluginAPI::setStringMode)
212 | );
213 |
214 | // gpgAuth related methods
215 | #ifdef WITH_GPGAUTH
216 | // registerMethod("getDomainKey",
217 | // make_method(this, &webpg::getNamedKey));
218 | // registerMethod("verifyDomainKey",
219 | // make_method(this, &webpg::verifyDomainKey));
220 | #endif
221 |
222 | registerEvent("onkeygenprogress");
223 | registerEvent("onkeygencomplete");
224 | registerEvent("onstatusprogress");
225 | }
226 |
227 | // Read-only properties
228 | registerProperty("version",
229 | make_property(this,
230 | &webpgPluginAPI::version)
231 | );
232 |
233 | registerMethod("get_webpg_status",
234 | make_method(this,
235 | &webpgPluginAPI::get_webpg_status)
236 | );
237 |
238 | registerProperty("webpg_status",
239 | make_property(this,
240 | &webpgPluginAPI::webpg_status)
241 | );
242 |
243 | registerProperty("openpgp_detected",
244 | make_property(this,
245 | &webpgPluginAPI::openpgp_detected)
246 | );
247 |
248 | registerProperty("gpgconf_detected",
249 | make_property(this,
250 | &webpgPluginAPI::gpgconf_detected)
251 | );
252 |
253 | m_webpgAPI = boost::make_shared();
254 |
255 | webpgPluginAPI::init();
256 | }
257 |
258 | ///////////////////////////////////////////////////////////////////////////////
259 | /// @fn webpgPluginAPI::~webpgPluginAPI()
260 | ///
261 | /// @brief Destructor. Remember that this object will not be released until
262 | /// the browser is done with it; this will almost definitely be after
263 | /// the plugin is released.
264 | ///////////////////////////////////////////////////////////////////////////////
265 | webpgPluginAPI::~webpgPluginAPI()
266 | {
267 | }
268 |
269 | ///////////////////////////////////////////////////////////////////////////////
270 | /// @fn webpgPluginPtr getPlugin()
271 | ///
272 | /// @brief Gets a reference to the plugin that was passed in when the object
273 | /// was created. If the plugin has already been released then this
274 | /// will throw a FB::script_error that will be translated into a
275 | /// javascript exception in the page.
276 | ///////////////////////////////////////////////////////////////////////////////
277 | webpgPluginPtr webpgPluginAPI::getPlugin()
278 | {
279 | webpgPluginPtr plugin(m_plugin.lock());
280 | if (!plugin) {
281 | throw FB::script_error("The plugin is invalid");
282 | }
283 | return plugin;
284 | }
285 |
286 | ///////////////////////////////////////////////////////////////////////////////
287 | /// @fn void init()
288 | ///
289 | /// @brief Initializes the webpgPlugin and sets the status variables.
290 | ///////////////////////////////////////////////////////////////////////////////
291 | void webpgPluginAPI::init()
292 | {
293 | FB::VariantMap response;
294 | FB::VariantMap plugin_info;
295 | Json::Value sm = m_webpgAPI->get_webpg_status();
296 | response = FB::jsonValueToVariant(sm).convert_cast();
297 |
298 | plugin_info["source_url"] = m_host->getDOMWindow()->getLocation();
299 | plugin_info["path"] = getPlugin()->getPluginPath();
300 | plugin_info["params"] = getPlugin()->getPluginParams();
301 | plugin_info["version"] = FBSTRING_PLUGIN_VERSION;
302 | response["plugin"] = plugin_info;
303 |
304 | #ifdef _EXTENSIONIZE
305 | response["extensionize"] = true;
306 | std::string location = m_host->getDOMWindow()->getLocation();
307 | size_t firefox_ext = location.find("chrome://");
308 | size_t chrome_ext = location.find("chrome-extension://");
309 | size_t opera_ext = location.find("widget://");
310 | size_t safari_ext = location.find("safari-extension://");
311 | response["extension"] =
312 | (chrome_ext != std::string::npos) ? "chrome" :
313 | (firefox_ext != std::string::npos) ? "firefox" :
314 | (opera_ext != std::string::npos) ? "opera" :
315 | (safari_ext != std::string::npos) ? "safari" : "unknown";
316 | #endif
317 |
318 | webpgPluginAPI::webpg_status_map = response;
319 | };
320 |
321 | void webpgPluginAPI::getKeyListThreadCaller(
322 | const std::string& name,
323 | bool secret_only,
324 | bool fast,
325 | webpgPluginAPI* api
326 | ) {
327 | if (api->threaded_js_callback != NULL)
328 | api->m_webpgAPI->getKeyListWorker(
329 | name.c_str(),
330 | secret_only,
331 | fast,
332 | api,
333 | &webpgPluginAPI::javascript_cb
334 | );
335 | else
336 | api->m_webpgAPI->getKeyListWorker(
337 | name.c_str(),
338 | secret_only,
339 | fast,
340 | api,
341 | &webpgPluginAPI::keylist_progress_cb
342 | );
343 | };
344 |
345 | ///////////////////////////////////////////////////////////////////////////////
346 | /// @fn FB::variant getPublicKeyList()
347 | ///
348 | /// @brief Calls m_webpgAPI->getKeyList() without specifying a search
349 | /// string, and the secret_only paramter as false, which returns only
350 | /// Public Keys from the keyring.
351 | ///////////////////////////////////////////////////////////////////////////////
352 | /*
353 | This method executes webpg->getKeyList with an empty string and
354 | secret_only=false which returns all Public Keys in the keyring.
355 | */
356 | FB::variant webpgPluginAPI::getPublicKeyList(
357 | const boost::optional fast=false,
358 | const boost::optional async=false,
359 | const boost::optional& callback=NULL
360 | ) {
361 | Json::Value json_value;
362 | bool fastListMode = (fast==true);
363 |
364 | if (callback != NULL)
365 | if (async == true)
366 | threaded_js_callback = *callback;
367 | else
368 | js_callback = *callback;
369 |
370 | if (async == true) {
371 | boost::thread keylist_thread(
372 | boost::bind(
373 | &webpgPluginAPI::getKeyListThreadCaller,
374 | "",
375 | false,
376 | fastListMode,
377 | this
378 | )
379 | );
380 | json_value["status"] = "queued";
381 | } else {
382 | // Retrieve the public keylist
383 | json_value = m_webpgAPI->getPublicKeyList(fastListMode);
384 | }
385 |
386 | if (async == false && callback != NULL) {
387 | js_callback->InvokeAsync("",
388 | FB::variant_list_of(
389 | FB::jsonToVariantValue(json_value.toStyledString())
390 | )
391 | );
392 | return NULL;
393 | }
394 |
395 | // Retrieve a reference to the DOM Window
396 | FB::DOM::WindowPtr window = m_host->getDOMWindow();
397 |
398 | if (!STRINGMODE) {
399 | // Check if the DOM Window has an in-built JSON Parser
400 | if (window && window->getJSObject()->HasProperty("JSON")) {
401 | // Create a writer that will convert the object to a string
402 | Json::FastWriter writer;
403 |
404 | // Create a reference to the browswer JSON object
405 | FB::JSObjectPtr obj = window->getProperty("JSON");
406 |
407 | return obj->Invoke("parse", FB::variant_list_of(writer.write(json_value)));
408 | } else {
409 | FB::variant keylist = FB::jsonValueToVariant(json_value);
410 | // No browser JSON parser detected, falling back to return of FB::variant
411 | return keylist;
412 | }
413 | } else {
414 | Json::FastWriter writer;
415 | return writer.write(json_value);
416 | }
417 | }
418 |
419 | ///////////////////////////////////////////////////////////////////////////////
420 | /// @fn FB::variant getPrivateKeyList()
421 | ///
422 | /// @brief Calls m_webpgAPI->getKeyList() without specifying a search
423 | /// string, and the secret_only paramter as true, which returns only
424 | /// Private Keys from the keyring.
425 | ///////////////////////////////////////////////////////////////////////////////
426 | /*
427 | This method executes webpg->getKeyList with an empty string and
428 | secret_only=true which returns all Public Keys in the keyring.
429 | */
430 | FB::variant webpgPluginAPI::getPrivateKeyList(
431 | const boost::optionalfast=false,
432 | const boost::optional async=false,
433 | const boost::optional& callback=NULL
434 | ) {
435 | Json::Value json_value;
436 | bool fastListMode = (fast==true);
437 |
438 | if (callback != NULL)
439 | if (async == true)
440 | threaded_js_callback = *callback;
441 | else
442 | js_callback = *callback;
443 |
444 | if (async == true) {
445 | boost::thread keylist_thread(
446 | boost::bind(
447 | &webpgPluginAPI::getKeyListThreadCaller,
448 | "",
449 | true,
450 | fastListMode,
451 | this
452 | )
453 | );
454 | json_value["status"] = "queued";
455 | } else {
456 | // Retrieve the public keylist
457 | json_value = m_webpgAPI->getPrivateKeyList(fastListMode);
458 | }
459 |
460 | if (async == false && callback != NULL) {
461 | js_callback->InvokeAsync("",
462 | FB::variant_list_of(
463 | FB::jsonToVariantValue(json_value.toStyledString())
464 | )
465 | );
466 | return NULL;
467 | }
468 |
469 | // Retrieve a reference to the DOM Window
470 | FB::DOM::WindowPtr window = m_host->getDOMWindow();
471 |
472 | if (!STRINGMODE) {
473 | // Check if the DOM Window has an in-built JSON Parser
474 | if (window && window->getJSObject()->HasProperty("JSON")) {
475 | // Create a writer that will convert the object to a string
476 | Json::FastWriter writer;
477 |
478 | // Create a reference to the browswer JSON object
479 | FB::JSObjectPtr obj = window->getProperty("JSON");
480 |
481 | return obj->Invoke("parse", FB::variant_list_of(
482 | writer.write(json_value))
483 | );
484 | } else {
485 | FB::variant keylist = FB::jsonValueToVariant(json_value);
486 | // No browser JSON parser detected, falling back to return of FB::variant
487 | return keylist;
488 | }
489 | } else {
490 | Json::FastWriter writer;
491 | return writer.write(json_value);
492 | }
493 | }
494 |
495 | ///////////////////////////////////////////////////////////////////////////////
496 | /// @fn FB::variant webpgPluginAPI::getNamedKey(const std::string& name)
497 | ///
498 | /// @brief Calls m_webpgAPI->getNamedKey() with a search string and the
499 | /// secret_only paramter as false, which returns only Public Keys from
500 | /// the keyring.
501 | ///////////////////////////////////////////////////////////////////////////////
502 | /*
503 | This method just calls m_webpgAPI->getKeyList with a name/email
504 | as the parameter
505 | */
506 | FB::variant webpgPluginAPI::getNamedKey(
507 | const std::string& name,
508 | const boost::optional fast=false,
509 | const boost::optional async=false,
510 | const boost::optional& callback=NULL
511 | ) {
512 | Json::Value json_value;
513 | bool fastListMode = (fast==true);
514 |
515 | if (callback != NULL)
516 | if (async == true)
517 | threaded_js_callback = *callback;
518 | else
519 | js_callback = *callback;
520 |
521 | if (async == true) {
522 | boost::thread keylist_thread(
523 | boost::bind(
524 | &webpgPluginAPI::getKeyListThreadCaller,
525 | name,
526 | false,
527 | fastListMode,
528 | this
529 | )
530 | );
531 | json_value["status"] = "queued";
532 | } else {
533 | // Retrieve the public keylist
534 | json_value = m_webpgAPI->getNamedKey(name, false);
535 | }
536 |
537 | if (async == false && callback != NULL) {
538 | js_callback->InvokeAsync("",
539 | FB::variant_list_of(
540 | FB::jsonToVariantValue(json_value.toStyledString())
541 | )
542 | );
543 | return NULL;
544 | }
545 |
546 | // Retrieve a reference to the DOM Window
547 | FB::DOM::WindowPtr window = m_host->getDOMWindow();
548 |
549 | // Check if the DOM Window has an in-built JSON Parser
550 | if (window && window->getJSObject()->HasProperty("JSON")) {
551 | // Create a writer that will convert the object to a string
552 | Json::FastWriter writer;
553 |
554 | // Create a reference to the browswer JSON object
555 | FB::JSObjectPtr obj = window->getProperty("JSON");
556 |
557 | return obj->Invoke("parse", FB::variant_list_of(writer.write(json_value)));
558 | } else {
559 | FB::variant keylist = FB::jsonValueToVariant(json_value);
560 | // No browser JSON parser detected, falling back to return of FB::variant
561 | return keylist;
562 | }
563 | }
564 |
565 | ///////////////////////////////////////////////////////////////////////////////
566 | /// @fn FB::variant getExternalKey(const std::string& name)
567 | ///
568 | /// @brief Calls m_webpgAPI->getKeyList() after setting the context to
569 | /// external mode with a search string and the secret_only paramter as
570 | /// false, which returns only Public Keys
571 | ///////////////////////////////////////////////////////////////////////////////
572 | /*
573 | This method just calls m_webpgAPI->getKeyList with a name/email
574 | as the parameter
575 | */
576 | FB::variant webpgPluginAPI::getExternalKey(
577 | const std::string& name,
578 | const boost::optional& callback=NULL
579 | ) {
580 | // Retrieve the public keylist
581 | Json::Value json_value = m_webpgAPI->getExternalKey(name);
582 |
583 | if (callback != NULL) {
584 | js_callback = *callback;
585 | js_callback->InvokeAsync("",
586 | FB::variant_list_of(
587 | FB::jsonToVariantValue(json_value.toStyledString())
588 | )
589 | );
590 | return NULL;
591 | }
592 |
593 | // Retrieve a reference to the DOM Window
594 | FB::DOM::WindowPtr window = m_host->getDOMWindow();
595 |
596 | // Check if the DOM Window has an in-built JSON Parser
597 | if (window && window->getJSObject()->HasProperty("JSON")) {
598 | // Create a writer that will convert the object to a string
599 | Json::FastWriter writer;
600 |
601 | // Create a reference to the browswer JSON object
602 | FB::JSObjectPtr obj = window->getProperty("JSON");
603 |
604 | return obj->Invoke("parse", FB::variant_list_of(writer.write(json_value)));
605 | } else {
606 | FB::variant keylist = FB::jsonValueToVariant(json_value);
607 | // No browser JSON parser detected, falling back to return of FB::variant
608 | return keylist;
609 | }
610 | }
611 |
612 | ///////////////////////////////////////////////////////////////////////////////
613 | /// @fn FB::variant gpgSetPreference(
614 | /// const std::string& preference,
615 | /// const std::string& pref_value)
616 | ///
617 | /// @brief Attempts to set the specified gpgconf preference with the value
618 | /// of pref_value.
619 | ///
620 | /// @param preference The preference to set.
621 | /// @param pref_value The value to assign to the specified preference.
622 | ///////////////////////////////////////////////////////////////////////////////
623 | FB::variant webpgPluginAPI::gpgSetPreference(
624 | const std::string& preference,
625 | const std::string& pref_value="blank",
626 | const boost::optional& callback=NULL
627 | ) {
628 | Json::Value json_value = m_webpgAPI->gpgSetPreference(
629 | preference,
630 | pref_value
631 | );
632 |
633 | if (callback != NULL) {
634 | js_callback = *callback;
635 | js_callback->InvokeAsync("",
636 | FB::variant_list_of(
637 | FB::jsonToVariantValue(json_value.toStyledString())
638 | )
639 | );
640 | return NULL;
641 | }
642 |
643 | return FB::jsonValueToVariant(json_value);
644 | }
645 |
646 | ///////////////////////////////////////////////////////////////////////////////
647 | /// @fn FB::variant gpgGetPreference(const std::string& preference)
648 | ///
649 | /// @brief Attempts to set the specified gpgconf preference with the value
650 | /// of pref_value.
651 | ///
652 | /// @param preference The preference to set.
653 | /// @param pref_value The value to assign to the specified preference.
654 | ///////////////////////////////////////////////////////////////////////////////
655 | FB::variant webpgPluginAPI::gpgGetPreference(
656 | const std::string& preference,
657 | const boost::optional& callback=NULL
658 | ) {
659 | Json::Value json_value = m_webpgAPI->gpgGetPreference(preference);
660 |
661 | if (callback != NULL) {
662 | js_callback = *callback;
663 | js_callback->InvokeAsync("",
664 | FB::variant_list_of(
665 | FB::jsonToVariantValue(json_value.toStyledString())
666 | )
667 | );
668 | return NULL;
669 | }
670 |
671 | return FB::jsonValueToVariant(json_value);
672 | }
673 |
674 | ///////////////////////////////////////////////////////////////////////////////
675 | /// @fn FB::variant gpgSetGroup(
676 | /// const std::string& group,
677 | /// const std::string& group_value)
678 | ///
679 | /// @brief Attempts to define or clear the specified group preference with
680 | /// the value of group_value.
681 | ///
682 | /// @param group The group to set.
683 | /// @param group_value The value to assign to the specified group.
684 | ///////////////////////////////////////////////////////////////////////////////
685 | FB::variant webpgPluginAPI::gpgSetGroup(
686 | const std::string& group,
687 | const std::string& group_value="",
688 | const boost::optional& callback=NULL
689 | ) {
690 | Json::Value json_value = m_webpgAPI->gpgSetGroup(group, group_value);
691 |
692 | if (callback != NULL) {
693 | js_callback = *callback;
694 | js_callback->InvokeAsync("",
695 | FB::variant_list_of(
696 | FB::jsonToVariantValue(json_value.toStyledString())
697 | )
698 | );
699 | return NULL;
700 | }
701 |
702 | return FB::jsonValueToVariant(json_value);
703 | }
704 |
705 | ///////////////////////////////////////////////////////////////////////////////
706 | /// @fn FB::variant gpgSetHomeDir(const std::string& gnupg_path)
707 | ///
708 | /// @brief Sets the GNUPGHOME static variable to the path specified in
709 | /// gnupg_path. This should be called prior to initializing the
710 | /// gpgme context.
711 | ///////////////////////////////////////////////////////////////////////////////
712 | FB::variant webpgPluginAPI::gpgSetHomeDir(
713 | const std::string& gnupg_path,
714 | const boost::optional& callback=NULL
715 | ) {
716 | Json::Value json_value = m_webpgAPI->gpgSetHomeDir(gnupg_path);
717 | return FB::jsonValueToVariant(json_value);
718 | }
719 |
720 | FB::variant webpgPluginAPI::gpgGetHomeDir(
721 | const boost::optional& callback=NULL
722 | ) {
723 | Json::Value json_value = m_webpgAPI->gpgGetHomeDir();
724 |
725 | if (callback != NULL) {
726 | js_callback = *callback;
727 | js_callback->InvokeAsync("",
728 | FB::variant_list_of(
729 | FB::jsonToVariantValue(json_value.toStyledString())
730 | )
731 | );
732 | return NULL;
733 | }
734 |
735 | return FB::jsonValueToVariant(json_value);
736 | }
737 |
738 | ///////////////////////////////////////////////////////////////////////////////
739 | /// @fn FB::variant gpgSetBinary(const std::string& gnupg_exec)
740 | ///
741 | /// @brief Sets the GNUPGBIN static variable to the path specified in
742 | /// gnupg_exec. This should be called prior to initializing the
743 | /// gpgme context.
744 | ///////////////////////////////////////////////////////////////////////////////
745 | FB::variant webpgPluginAPI::gpgSetBinary(
746 | const std::string& gnupg_exec,
747 | const boost::optional& callback=NULL
748 | ) {
749 | Json::Value json_value = m_webpgAPI->gpgSetBinary(gnupg_exec);
750 |
751 | if (callback != NULL) {
752 | js_callback = *callback;
753 | js_callback->InvokeAsync("",
754 | FB::variant_list_of(
755 | FB::jsonToVariantValue(json_value.toStyledString())
756 | )
757 | );
758 | return NULL;
759 | }
760 |
761 | return FB::jsonValueToVariant(json_value);
762 | }
763 |
764 | FB::variant webpgPluginAPI::gpgGetBinary(
765 | const boost::optional& callback=NULL
766 | ) {
767 | Json::Value json_value = m_webpgAPI->gpgGetBinary();
768 |
769 | if (callback != NULL) {
770 | js_callback = *callback;
771 | js_callback->InvokeAsync("",
772 | FB::variant_list_of(
773 | FB::jsonToVariantValue(json_value.toStyledString())
774 | )
775 | );
776 | return NULL;
777 | }
778 |
779 | return FB::jsonValueToVariant(json_value);
780 | }
781 |
782 | ///////////////////////////////////////////////////////////////////////////////
783 | /// @fn FB::variant gpgSetGPGConf(const std::string& gpgconf_exec)
784 | ///
785 | /// @brief Sets the GPGCONF static variable to the path specified in
786 | /// gpgconf_exec.
787 | ///////////////////////////////////////////////////////////////////////////////
788 | FB::variant webpgPluginAPI::gpgSetGPGConf(
789 | const std::string& gpgconf_exec,
790 | const boost::optional& callback=NULL
791 | ) {
792 | Json::Value json_value = m_webpgAPI->gpgSetGPGConf(gpgconf_exec);
793 |
794 | if (callback != NULL) {
795 | js_callback = *callback;
796 | js_callback->InvokeAsync("",
797 | FB::variant_list_of(
798 | FB::jsonToVariantValue(json_value.toStyledString())
799 | )
800 | );
801 | return NULL;
802 | }
803 |
804 | return FB::jsonValueToVariant(json_value);
805 | }
806 |
807 | FB::variant webpgPluginAPI::gpgGetGPGConf(
808 | const boost::optional& callback=NULL
809 | ) {
810 | Json::Value json_value = m_webpgAPI->gpgGetGPGConf();
811 |
812 | if (callback != NULL) {
813 | js_callback = *callback;
814 | js_callback->InvokeAsync("",
815 | FB::variant_list_of(
816 | FB::jsonToVariantValue(json_value.toStyledString())
817 | )
818 | );
819 | return NULL;
820 | }
821 |
822 | return FB::jsonValueToVariant(json_value);
823 | }
824 |
825 | FB::variant webpgPluginAPI::gpgEncrypt(
826 | const std::string& data,
827 | const FB::VariantList& enc_to_keyids,
828 | const boost::optional& sign,
829 | const boost::optional& opt_signers,
830 | const boost::optional& callback=NULL
831 | ) {
832 | Json::Value json_value = m_webpgAPI->gpgEncrypt(
833 | data,
834 | variantToJsonValue(enc_to_keyids),
835 | sign,
836 | variantToJsonValue(opt_signers)
837 | );
838 |
839 | if (callback != NULL) {
840 | js_callback = *callback;
841 | js_callback->InvokeAsync("",
842 | FB::variant_list_of(
843 | FB::jsonToVariantValue(json_value.toStyledString())
844 | )
845 | );
846 | return NULL;
847 | }
848 |
849 | return FB::jsonValueToVariant(json_value);
850 | }
851 |
852 | FB::variant webpgPluginAPI::gpgSymmetricEncrypt(
853 | const std::string& data,
854 | const boost::optional& sign,
855 | const boost::optional& opt_signers,
856 | const boost::optional& callback=NULL
857 | ) {
858 | Json::Value json_value = m_webpgAPI->gpgSymmetricEncrypt(
859 | data,
860 | sign,
861 | FB::variantToJsonValue(opt_signers)
862 | );
863 |
864 | if (callback != NULL) {
865 | js_callback = *callback;
866 | js_callback->InvokeAsync("",
867 | FB::variant_list_of(
868 | FB::jsonToVariantValue(json_value.toStyledString())
869 | )
870 | );
871 | return NULL;
872 | }
873 |
874 | return FB::jsonValueToVariant(json_value);
875 | }
876 |
877 | FB::variant webpgPluginAPI::gpgDecryptVerify(
878 | const std::string& data,
879 | const std::string& plaintext,
880 | int use_agent,
881 | const boost::optional& callback=NULL
882 | ) {
883 | Json::Value json_value = m_webpgAPI->gpgDecryptVerify(
884 | data,
885 | plaintext,
886 | use_agent
887 | );
888 |
889 | if (callback != NULL) {
890 | js_callback = *callback;
891 | js_callback->InvokeAsync("",
892 | FB::variant_list_of(
893 | FB::jsonToVariantValue(json_value.toStyledString())
894 | )
895 | );
896 | return NULL;
897 | }
898 |
899 | return FB::jsonValueToVariant(json_value);
900 | }
901 |
902 | ///////////////////////////////////////////////////////////////////////////////
903 | /// @fn FB::variant webpgPluginAPI::gpgDecrypt(const std::string& data)
904 | ///
905 | /// @brief Calls m_webpgAPI->gpgDecryptVerify() with the use_agent flag
906 | /// specifying to not disable the gpg-agent.
907 | ///
908 | /// @param data The data to decyrpt.
909 | ///////////////////////////////////////////////////////////////////////////////
910 | FB::variant webpgPluginAPI::gpgDecrypt(
911 | const std::string& data,
912 | const boost::optional& callback=NULL
913 | ) {
914 | Json::Value json_value = m_webpgAPI->gpgDecrypt(data);
915 |
916 | if (callback != NULL) {
917 | js_callback = *callback;
918 | js_callback->InvokeAsync("",
919 | FB::variant_list_of(
920 | FB::jsonToVariantValue(json_value.toStyledString())
921 | )
922 | );
923 | return NULL;
924 | }
925 |
926 | return FB::jsonValueToVariant(json_value);
927 | }
928 |
929 | FB::variant webpgPluginAPI::gpgVerify(
930 | const std::string& data,
931 | const boost::optional& plaintext,
932 | const boost::optional& callback=NULL
933 | ) {
934 | Json::Value json_value = m_webpgAPI->gpgVerify(data, plaintext);
935 |
936 | if (callback != NULL) {
937 | js_callback = *callback;
938 | js_callback->InvokeAsync("",
939 | FB::variant_list_of(
940 | FB::jsonToVariantValue(json_value.toStyledString())
941 | )
942 | );
943 | return NULL;
944 | }
945 |
946 | return FB::jsonValueToVariant(json_value);
947 | }
948 |
949 | ///////////////////////////////////////////////////////////////////////////////
950 | /// @fn FB::variant gpgSignText(
951 | /// const std::string& plain_text,
952 | /// FB::VariantList& signers,
953 | /// int sign_mode)
954 | ///
955 | /// @brief Signs the text specified in plain_text with the key ids specified
956 | /// in signers, with the signature mode specified in sign_mode.
957 | ///////////////////////////////////////////////////////////////////////////////
958 | FB::variant webpgPluginAPI::gpgSignText(
959 | const std::string& plain_text,
960 | const FB::VariantList& signers,
961 | const boost::optional& opt_sign_mode,
962 | const boost::optional& callback=NULL
963 | ) {
964 | Json::Value json_value = m_webpgAPI->gpgSignText(
965 | plain_text,
966 | FB::variantToJsonValue(signers),
967 | opt_sign_mode
968 | );
969 |
970 | if (callback != NULL) {
971 | js_callback = *callback;
972 | js_callback->InvokeAsync("",
973 | FB::variant_list_of(
974 | FB::jsonToVariantValue(json_value.toStyledString())
975 | )
976 | );
977 | return NULL;
978 | }
979 |
980 | return FB::jsonValueToVariant(json_value);
981 | }
982 |
983 | ///////////////////////////////////////////////////////////////////////////////
984 | /// @fn FB::variant webpgPluginAPI::gpgSignUID(
985 | /// const std::string& keyid,
986 | /// long sign_uid,
987 | /// const std::string& with_keyid,
988 | /// long local_only,
989 | /// long trust_sign,
990 | /// long trust_level)
991 | ///
992 | /// @brief Signs the UID index of the specified keyid using the signing key
993 | /// with_keyid.
994 | ///
995 | /// @param keyid The ID of the key with the desired UID to sign.
996 | /// @param sign_uid The 0 based index of the UID.
997 | /// @param with_keyid The ID of the key to create the signature with.
998 | /// @param local_only Specifies if the signature is local only (non exportable).
999 | /// @param trust_sign Specifies if this is a trust signature.
1000 | /// @param trust_level The level of trust to assign.
1001 | ///////////////////////////////////////////////////////////////////////////////
1002 | FB::variant webpgPluginAPI::gpgSignUID(
1003 | const std::string& keyid,
1004 | long uid,
1005 | const std::string& with_keyid,
1006 | long local_only,
1007 | long trust_sign,
1008 | long trust_level,
1009 | const boost::optional& notation_name=NULL,
1010 | const boost::optional& notation_value=NULL,
1011 | const boost::optional& callback=NULL
1012 | ) {
1013 | Json::Value json_value = m_webpgAPI->gpgSignUID(
1014 | keyid,
1015 | uid,
1016 | with_keyid,
1017 | local_only,
1018 | trust_sign,
1019 | trust_level,
1020 | notation_name,
1021 | notation_value
1022 | );
1023 |
1024 | if (callback != NULL) {
1025 | js_callback = *callback;
1026 | js_callback->InvokeAsync("",
1027 | FB::variant_list_of(
1028 | FB::jsonToVariantValue(json_value.toStyledString())
1029 | )
1030 | );
1031 | return NULL;
1032 | }
1033 |
1034 | return FB::jsonValueToVariant(json_value);
1035 | }
1036 |
1037 | ///////////////////////////////////////////////////////////////////////////////
1038 | /// @fn FB::variant webpgPluginAPI::gpgDeleteUIDSign(const std::string& keyid, long uid, long signature)
1039 | ///
1040 | /// @brief Deletes the Signature signature on the uid of keyid.
1041 | ///
1042 | /// @param keyid The ID of the key containing the UID to delete the signature from.
1043 | /// @param uid The index of the UID containing the signature to delete.
1044 | /// @param signature The signature index of the signature to delete.
1045 | ///////////////////////////////////////////////////////////////////////////////
1046 | FB::variant webpgPluginAPI::gpgDeleteUIDSign(
1047 | const std::string& keyid,
1048 | long sign_uid,
1049 | long signature,
1050 | const boost::optional& callback=NULL
1051 | ) {
1052 | Json::Value json_value = m_webpgAPI->gpgDeleteUIDSign(
1053 | keyid,
1054 | sign_uid,
1055 | signature
1056 | );
1057 |
1058 | if (callback != NULL) {
1059 | js_callback = *callback;
1060 | js_callback->InvokeAsync("",
1061 | FB::variant_list_of(
1062 | FB::jsonToVariantValue(json_value.toStyledString())
1063 | )
1064 | );
1065 | return NULL;
1066 | }
1067 |
1068 | return FB::jsonValueToVariant(json_value);
1069 | }
1070 |
1071 | ///////////////////////////////////////////////////////////////////////////////
1072 | /// @fn FB::variant webpgPluginAPI::gpgEnableKey(const std::string& keyid)
1073 | ///
1074 | /// @brief Sets the key specified with keyid as enabled in gpupg.
1075 | ///
1076 | /// @param keyid The ID of the key to enable.
1077 | ///////////////////////////////////////////////////////////////////////////////
1078 | FB::variant webpgPluginAPI::gpgEnableKey(
1079 | const std::string& keyid,
1080 | const boost::optional& callback=NULL
1081 | ) {
1082 | Json::Value json_value = m_webpgAPI->gpgEnableKey(keyid);
1083 |
1084 | if (callback != NULL) {
1085 | js_callback = *callback;
1086 | js_callback->InvokeAsync("",
1087 | FB::variant_list_of(
1088 | FB::jsonToVariantValue(json_value.toStyledString())
1089 | )
1090 | );
1091 | return NULL;
1092 | }
1093 |
1094 | return FB::jsonValueToVariant(json_value);
1095 | }
1096 |
1097 | ///////////////////////////////////////////////////////////////////////////////
1098 | /// @fn FB::variant webpgPluginAPI::gpgDisableKey(const std::string& keyid)
1099 | ///
1100 | /// @brief Sets the key specified with keyid as disabled in gpupg.
1101 | ///
1102 | /// @param keyid The ID of the key to disable.
1103 | ///////////////////////////////////////////////////////////////////////////////
1104 | FB::variant webpgPluginAPI::gpgDisableKey(
1105 | const std::string& keyid,
1106 | const boost::optional& callback=NULL
1107 | ) {
1108 | Json::Value json_value = m_webpgAPI->gpgDisableKey(keyid);
1109 |
1110 | if (callback != NULL) {
1111 | js_callback = *callback;
1112 | js_callback->InvokeAsync("",
1113 | FB::variant_list_of(
1114 | FB::jsonToVariantValue(json_value.toStyledString())
1115 | )
1116 | );
1117 | return NULL;
1118 | }
1119 |
1120 | return FB::jsonValueToVariant(json_value);
1121 | }
1122 |
1123 | ///////////////////////////////////////////////////////////////////////////////
1124 | /// @fn std::string webpgPluginAPI::gpgGenKey(const std::string& key_type,
1125 | /// const std::string& key_length,
1126 | /// const std::string& subkey_type,
1127 | /// const std::string& subkey_length,
1128 | /// const std::string& name_real,
1129 | /// const std::string& name_comment,
1130 | /// const std::string& name_email,
1131 | /// const std::string& expire_date,
1132 | /// const std::string& passphrase)
1133 | ///
1134 | /// @brief Queues a threaded gpg genkey operation.
1135 | ///
1136 | /// @param key_type The key type to genereate.
1137 | /// @param key_length The size of the key to generate.
1138 | /// @param subkey_type The subkey type to generate.
1139 | /// @param subkey_length The size of the subkey to genereate.
1140 | /// @param name_real The name to assign the UID.
1141 | /// @param name_comment The comment to assign to the UID.
1142 | /// @param name_email The email address to assign to the UID.
1143 | /// @param expire_date The expiration date to assign to the generated key.
1144 | /// @param passphrase The passphrase to assign the to the key.
1145 | ///////////////////////////////////////////////////////////////////////////////
1146 | std::string webpgPluginAPI::gpgGenKey(
1147 | const std::string& key_type,
1148 | const std::string& key_length,
1149 | const std::string& subkey_type,
1150 | const std::string& subkey_length,
1151 | const std::string& name_real,
1152 | const std::string& name_comment,
1153 | const std::string& name_email,
1154 | const std::string& expire_date,
1155 | const std::string& passphrase
1156 | ) {
1157 |
1158 | genKeyParams params;
1159 |
1160 | params.key_type = key_type;
1161 | params.key_length = key_length;
1162 | params.subkey_type = subkey_type;
1163 | params.subkey_length = subkey_length;
1164 | params.name_real = name_real;
1165 | params.name_comment = name_comment;
1166 | params.name_email = name_email;
1167 | params.expire_date = expire_date;
1168 | params.passphrase = passphrase;
1169 |
1170 | boost::thread genkey_thread(
1171 | boost::bind(
1172 | &webpgPluginAPI::genKeyThreadCaller,
1173 | this, params
1174 | )
1175 | );
1176 |
1177 | return "queued";
1178 | }
1179 |
1180 | ///////////////////////////////////////////////////////////////////////////////
1181 | /// @fn std::string gpgGenSubKey(const std::string& keyid,
1182 | /// const std::string& subkey_type,
1183 | /// const std::string& subkey_length,
1184 | /// const std::string& subkey_expire,
1185 | /// bool sign_flag,
1186 | /// bool enc_flag,
1187 | /// bool auth_flag)
1188 | ///
1189 | /// @brief Queues a threaded gpg gensubkey operation.
1190 | ///
1191 | /// @param keyid The key to generate the subkey on.
1192 | /// @param subkey_type The subkey type to generate.
1193 | /// @param subkey_length The size of the subkey to genereate.
1194 | /// @param subkey_expire The expiration date to assign to the generated subkey.
1195 | /// @param sign_flag Set the sign capabilities flag.
1196 | /// @param enc_flag Set the encrypt capabilities flag.
1197 | /// @param auth_flag Set the auth capabilities flag.
1198 | ///////////////////////////////////////////////////////////////////////////////
1199 | std::string webpgPluginAPI::gpgGenSubKey(
1200 | const std::string& keyid,
1201 | const std::string& subkey_type,
1202 | const std::string& subkey_length,
1203 | const std::string& subkey_expire,
1204 | bool sign_flag,
1205 | bool enc_flag,
1206 | bool auth_flag
1207 | ) {
1208 |
1209 | genSubKeyParams params;
1210 |
1211 | params.keyid = keyid;
1212 | params.subkey_type = subkey_type;
1213 | params.subkey_length = subkey_length;
1214 | params.subkey_expire = subkey_expire;
1215 | params.sign_flag = sign_flag;
1216 | params.enc_flag = enc_flag;
1217 | params.auth_flag = auth_flag;
1218 |
1219 | boost::thread genkey_thread(
1220 | boost::bind(
1221 | &webpgPluginAPI::genSubKeyThreadCaller,
1222 | this, params
1223 | )
1224 | );
1225 |
1226 | return "queued";
1227 | }
1228 |
1229 | ///////////////////////////////////////////////////////////////////////////////
1230 | /// @fn void keygen_progress_cb(void *self,
1231 | /// const char *what,
1232 | /// int type,
1233 | /// int current,
1234 | /// int total)
1235 | ///
1236 | /// @brief Called by the long-running, asymmetric gpg genkey method to
1237 | /// display the key generation status.
1238 | ///
1239 | /// @param self A reference to webpgPluginAPI, since the method is called
1240 | /// outside of the class.
1241 | /// @param what The current action status from gpg genkey.
1242 | /// @param type The type of of action.
1243 | /// @param current ?
1244 | /// @param total ?
1245 | ///////////////////////////////////////////////////////////////////////////////
1246 | void webpgPluginAPI::keygen_progress_cb(
1247 | void *self,
1248 | const char *what,
1249 | int type,
1250 | int current,
1251 | int total
1252 | ) {
1253 | if (!strcmp (what, "primegen") && !current && !total
1254 | && (type == '.' || type == '+' || type == '!'
1255 | || type == '^' || type == '<' || type == '>')) {
1256 | webpgPluginAPI* API = (webpgPluginAPI*) self;
1257 | API->FireEvent("onkeygenprogress", FB::variant_list_of(type));
1258 | }
1259 | if (!strcmp (what, "complete")) {
1260 | webpgPluginAPI* API = (webpgPluginAPI*) self;
1261 | API->FireEvent("onkeygencomplete", FB::variant_list_of("complete"));
1262 | }
1263 | }
1264 |
1265 | void webpgPluginAPI::keylist_progress_cb(void *self, const char* msg_value) {
1266 | if (msg_value != NULL) {
1267 | webpgPluginAPI* API = (webpgPluginAPI*) self;
1268 | API->FireEvent("onstatusprogress", FB::variant_list_of(msg_value));
1269 | }
1270 | }
1271 |
1272 | void webpgPluginAPI::javascript_cb(void *self, const char* msg_value) {
1273 | if (msg_value != NULL) {
1274 | webpgPluginAPI* API = (webpgPluginAPI*) self;
1275 | if (API->threaded_js_callback != NULL)
1276 | API->threaded_js_callback->InvokeAsync("", FB::variant_list_of(msg_value));
1277 | }
1278 | }
1279 |
1280 | ///////////////////////////////////////////////////////////////////////////////
1281 | /// @fn void threaded_gpgGenKey(genKeyParams params)
1282 | ///
1283 | /// @brief Calls gpgGenKeyWorker() with the specified parameters.
1284 | ///
1285 | /// @param params The parameters used to generete the key.
1286 | ///////////////////////////////////////////////////////////////////////////////
1287 | void webpgPluginAPI::threaded_gpgGenKey(genKeyParams params)
1288 | {
1289 | m_webpgAPI->gpgGenKeyWorker(params, this, &webpgPluginAPI::keygen_progress_cb);
1290 | }
1291 |
1292 | ///////////////////////////////////////////////////////////////////////////////
1293 | /// @fn void threaded_gpgGenSubKey(genKeyParams params)
1294 | ///
1295 | /// @brief Calls m_webpgAPI->gpgGenSubKeyWorker() with the specified parameters.
1296 | ///
1297 | /// @param params The parameters used to generete the subkey.
1298 | ///////////////////////////////////////////////////////////////////////////////
1299 | void webpgPluginAPI::threaded_gpgGenSubKey(genSubKeyParams params)
1300 | {
1301 | m_webpgAPI->gpgGenSubKeyWorker(params, this, &webpgPluginAPI::keygen_progress_cb);
1302 | }
1303 |
1304 | ///////////////////////////////////////////////////////////////////////////////
1305 | /// @fn FB::variant gpgImportKey(const std::string& ascii_key)
1306 | ///
1307 | /// @brief Imports the ASCII encoded key ascii_key
1308 | ///
1309 | /// @param ascii_key An armored, ascii encoded PGP Key block.
1310 | ///////////////////////////////////////////////////////////////////////////////
1311 | FB::variant webpgPluginAPI::gpgImportKey(
1312 | const std::string& ascii_key,
1313 | const boost::optional& callback=NULL
1314 | ) {
1315 | Json::Value json_value = m_webpgAPI->gpgImportKey(ascii_key);
1316 |
1317 | if (callback != NULL) {
1318 | js_callback = *callback;
1319 | js_callback->InvokeAsync("",
1320 | FB::variant_list_of(
1321 | FB::jsonToVariantValue(json_value.toStyledString())
1322 | )
1323 | );
1324 | return NULL;
1325 | }
1326 |
1327 | return FB::jsonValueToVariant(json_value);
1328 | }
1329 |
1330 | ///////////////////////////////////////////////////////////////////////////////
1331 | /// @fn FB::variant gpgImportExternalKey(const std::string& ascii_key)
1332 | ///
1333 | /// @brief Imports the ASCII encoded key ascii_key
1334 | ///
1335 | /// @param ascii_key An armored, ascii encoded PGP Key block.
1336 | ///////////////////////////////////////////////////////////////////////////////
1337 | FB::variant webpgPluginAPI::gpgImportExternalKey(
1338 | const std::string& keyid,
1339 | const boost::optional& callback=NULL
1340 | ) {
1341 | Json::Value json_value = m_webpgAPI->gpgImportExternalKey(keyid);
1342 |
1343 | if (callback != NULL) {
1344 | js_callback = *callback;
1345 | js_callback->InvokeAsync("",
1346 | FB::variant_list_of(
1347 | FB::jsonToVariantValue(json_value.toStyledString())
1348 | )
1349 | );
1350 | return NULL;
1351 | }
1352 |
1353 | return FB::jsonValueToVariant(json_value);
1354 | }
1355 |
1356 | ///////////////////////////////////////////////////////////////////////////////
1357 | /// @fn FB::variant gpgDeletePublicKey(const std::string& keyid)
1358 | ///
1359 | /// @brief Deletes key specified in keyid from the Public keyring.
1360 | ///
1361 | /// @param keyid The ID of the key to delete from the Public keyring.
1362 | ///////////////////////////////////////////////////////////////////////////////
1363 | FB::variant webpgPluginAPI::gpgDeletePublicKey(
1364 | const std::string& keyid,
1365 | const boost::optional& callback=NULL
1366 | ) {
1367 | Json::Value json_value = m_webpgAPI->gpgDeletePublicKey(keyid);
1368 |
1369 | if (callback != NULL) {
1370 | js_callback = *callback;
1371 | js_callback->InvokeAsync("",
1372 | FB::variant_list_of(
1373 | FB::jsonToVariantValue(json_value.toStyledString())
1374 | )
1375 | );
1376 | return NULL;
1377 | }
1378 |
1379 | return FB::jsonValueToVariant(json_value);
1380 | }
1381 |
1382 | ///////////////////////////////////////////////////////////////////////////////
1383 | /// @fn FB::variant gpgDeletePrivateKey(const std::string& keyid)
1384 | ///
1385 | /// @brief Deletes key specified in keyid from the Private keyring.
1386 | ///
1387 | /// @param keyid The ID of the key to delete from the Private keyring.
1388 | ///////////////////////////////////////////////////////////////////////////////
1389 | FB::variant webpgPluginAPI::gpgDeletePrivateKey(
1390 | const std::string& keyid,
1391 | const boost::optional& callback=NULL
1392 | ) {
1393 | Json::Value json_value = m_webpgAPI->gpgDeletePrivateKey(keyid);
1394 |
1395 | if (callback != NULL) {
1396 | js_callback = *callback;
1397 | js_callback->InvokeAsync("",
1398 | FB::variant_list_of(
1399 | FB::jsonToVariantValue(json_value.toStyledString())
1400 | )
1401 | );
1402 | return NULL;
1403 | }
1404 |
1405 | return FB::jsonValueToVariant(json_value);
1406 | }
1407 |
1408 | ///////////////////////////////////////////////////////////////////////////////
1409 | /// @fn FB::variant gpgDeletePrivateSubKey(const std::string& keyid,
1410 | /// int key_idx)
1411 | ///
1412 | /// @brief Deletes subkey located at index key_idx form the key specified in keyid.
1413 | ///
1414 | /// @param keyid The ID of the key to delete the subkey from.
1415 | /// @param key_idx The index of the subkey to delete.
1416 | ///////////////////////////////////////////////////////////////////////////////
1417 | FB::variant webpgPluginAPI::gpgDeletePrivateSubKey(
1418 | const std::string& keyid,
1419 | int key_idx,
1420 | const boost::optional& callback=NULL
1421 | ) {
1422 | Json::Value json_value = m_webpgAPI->gpgDeletePrivateSubKey(keyid, key_idx);
1423 |
1424 | if (callback != NULL) {
1425 | js_callback = *callback;
1426 | js_callback->InvokeAsync("",
1427 | FB::variant_list_of(
1428 | FB::jsonToVariantValue(json_value.toStyledString())
1429 | )
1430 | );
1431 | return NULL;
1432 | }
1433 |
1434 | return FB::jsonValueToVariant(json_value);
1435 | }
1436 |
1437 | ///////////////////////////////////////////////////////////////////////////////
1438 | /// @fn FB::variant gpgSetKeyTrust(const std::string& keyid,
1439 | /// long trust_level)
1440 | ///
1441 | /// @brief Sets the gnupg trust level assignment for the given keyid.
1442 | ///
1443 | /// @param keyid The ID of the key to assign the trust level on.
1444 | /// @param trust_level The level of trust to assign.
1445 | ///////////////////////////////////////////////////////////////////////////////
1446 | FB::variant webpgPluginAPI::gpgSetKeyTrust(
1447 | const std::string& keyid,
1448 | long trust_level,
1449 | const boost::optional& callback=NULL
1450 | ) {
1451 | Json::Value json_value = m_webpgAPI->gpgSetKeyTrust(keyid, trust_level);
1452 |
1453 | if (callback != NULL) {
1454 | js_callback = *callback;
1455 | js_callback->InvokeAsync("",
1456 | FB::variant_list_of(
1457 | FB::jsonToVariantValue(json_value.toStyledString())
1458 | )
1459 | );
1460 | return NULL;
1461 | }
1462 |
1463 | return FB::jsonValueToVariant(json_value);
1464 | }
1465 |
1466 | ///////////////////////////////////////////////////////////////////////////////
1467 | /// @fn FB::variant gpgAddUID(const std::string& keyid,
1468 | /// const std::string& name,
1469 | /// const std::string& email,
1470 | /// const std::string& comment)
1471 | ///
1472 | /// @brief Adds a new UID to the key specified by keyid
1473 | ///
1474 | /// @param keyid The ID of the key to add the UID to.
1475 | /// @param name The name to assign to the new UID.
1476 | /// @param email The email address to assign to the new UID.
1477 | /// @param comment The comment to assign to the new UID.
1478 | ///////////////////////////////////////////////////////////////////////////////
1479 | FB::variant webpgPluginAPI::gpgAddUID(
1480 | const std::string& keyid,
1481 | const std::string& name,
1482 | const std::string& email,
1483 | const std::string& comment,
1484 | const boost::optional& callback=NULL
1485 | ) {
1486 | Json::Value json_value = m_webpgAPI->gpgAddUID(
1487 | keyid,
1488 | name,
1489 | email,
1490 | comment
1491 | );
1492 |
1493 | if (callback != NULL) {
1494 | js_callback = *callback;
1495 | js_callback->InvokeAsync("",
1496 | FB::variant_list_of(
1497 | FB::jsonToVariantValue(json_value.toStyledString())
1498 | )
1499 | );
1500 | return NULL;
1501 | }
1502 |
1503 | return FB::jsonValueToVariant(json_value);
1504 | }
1505 |
1506 | ///////////////////////////////////////////////////////////////////////////////
1507 | /// @fn FB::variant gpgDeleteUID(const std::string& keyid, long uid_idx)
1508 | ///
1509 | /// @brief Deletes the UID specified by uid_idx from the key specified with keyid.
1510 | ///
1511 | /// @param keyid The ID of the key to delete to the specified UID from.
1512 | /// @param uid_idx The index of the UID to delete from the key.
1513 | ///////////////////////////////////////////////////////////////////////////////
1514 | FB::variant webpgPluginAPI::gpgDeleteUID(
1515 | const std::string& keyid,
1516 | long uid_idx,
1517 | const boost::optional& callback=NULL
1518 | ) {
1519 | Json::Value json_value = m_webpgAPI->gpgDeleteUID(keyid, uid_idx);
1520 |
1521 | if (callback != NULL) {
1522 | js_callback = *callback;
1523 | js_callback->InvokeAsync("",
1524 | FB::variant_list_of(
1525 | FB::jsonToVariantValue(json_value.toStyledString())
1526 | )
1527 | );
1528 | return NULL;
1529 | }
1530 |
1531 | return FB::jsonValueToVariant(json_value);
1532 | }
1533 |
1534 | ///////////////////////////////////////////////////////////////////////////////
1535 | /// @fn FB::variant gpgSetPrimaryUID(const std::string& keyid, long uid_idx)
1536 | ///
1537 | /// @brief Sets a given UID as the primary for the key specified with keyid.
1538 | ///
1539 | /// @param keyid The ID of the key with the UID to make primary.
1540 | /// @param uid_idx The index of the UID to make primary on the key.
1541 | ///////////////////////////////////////////////////////////////////////////////
1542 | FB::variant webpgPluginAPI::gpgSetPrimaryUID(
1543 | const std::string& keyid,
1544 | long uid_idx,
1545 | const boost::optional& callback=NULL
1546 | ) {
1547 | Json::Value json_value = m_webpgAPI->gpgSetPrimaryUID(keyid, uid_idx);
1548 |
1549 | if (callback != NULL) {
1550 | js_callback = *callback;
1551 | js_callback->InvokeAsync("",
1552 | FB::variant_list_of(
1553 | FB::jsonToVariantValue(json_value.toStyledString())
1554 | )
1555 | );
1556 | return NULL;
1557 | }
1558 |
1559 | return FB::jsonValueToVariant(json_value);
1560 | }
1561 |
1562 | ///////////////////////////////////////////////////////////////////////////////
1563 | /// @fn FB::variant gpgSetPubkeyExpire(const std::string& keyid, long expire)
1564 | ///
1565 | /// @brief Sets the expiration of the public key of the given keyid.
1566 | ///
1567 | /// @param keyid The ID of the key to set the expiration on.
1568 | /// @param expire The expiration to assign to the key.
1569 | ///////////////////////////////////////////////////////////////////////////////
1570 | FB::variant webpgPluginAPI::gpgSetPubkeyExpire(
1571 | const std::string& keyid,
1572 | long expire,
1573 | const boost::optional& callback=NULL
1574 | ) {
1575 | Json::Value json_value = m_webpgAPI->gpgSetPubkeyExpire(keyid, expire);
1576 |
1577 | if (callback != NULL) {
1578 | js_callback = *callback;
1579 | js_callback->InvokeAsync("",
1580 | FB::variant_list_of(
1581 | FB::jsonToVariantValue(json_value.toStyledString())
1582 | )
1583 | );
1584 | return NULL;
1585 | }
1586 |
1587 | return FB::jsonValueToVariant(json_value);
1588 | }
1589 |
1590 | ///////////////////////////////////////////////////////////////////////////////
1591 | /// @fn FB::variant gpgSetSubkeyExpire(const std::string& keyid,
1592 | /// long key_idx,
1593 | /// long expire)
1594 | ///
1595 | /// @brief Sets the expiration of the subkey specified with on the
1596 | /// key specified with .
1597 | ///
1598 | /// @param keyid The ID of the key to set the expiration on.
1599 | /// @param key_idx The index of the subkey to set the expiration on.
1600 | /// @param expire The expiration to assign to the key.
1601 | ///////////////////////////////////////////////////////////////////////////////
1602 | FB::variant webpgPluginAPI::gpgSetSubkeyExpire(
1603 | const std::string& keyid,
1604 | long key_idx,
1605 | long expire,
1606 | const boost::optional& callback=NULL
1607 | ) {
1608 | Json::Value json_value = m_webpgAPI->gpgSetSubkeyExpire(
1609 | keyid,
1610 | key_idx,
1611 | expire
1612 | );
1613 |
1614 | if (callback != NULL) {
1615 | js_callback = *callback;
1616 | js_callback->InvokeAsync("",
1617 | FB::variant_list_of(
1618 | FB::jsonToVariantValue(json_value.toStyledString())
1619 | )
1620 | );
1621 | return NULL;
1622 | }
1623 |
1624 | return FB::jsonValueToVariant(json_value);
1625 | }
1626 |
1627 | ///////////////////////////////////////////////////////////////////////////////
1628 | /// @fn FB::variant gpgExportPublicKey(const std::string& keyid)
1629 | ///
1630 | /// @brief Exports the public key specified with as an ASCII armored
1631 | /// PGP Block.
1632 | ///////////////////////////////////////////////////////////////////////////////
1633 | FB::variant webpgPluginAPI::gpgExportPublicKey(
1634 | const std::string& keyid,
1635 | const boost::optional& callback=NULL
1636 | ) {
1637 | Json::Value json_value = m_webpgAPI->gpgExportPublicKey(keyid);
1638 |
1639 | if (callback != NULL) {
1640 | js_callback = *callback;
1641 | js_callback->InvokeAsync("",
1642 | FB::variant_list_of(
1643 | FB::jsonToVariantValue(json_value.toStyledString())
1644 | )
1645 | );
1646 | return NULL;
1647 | }
1648 |
1649 | return FB::jsonValueToVariant(json_value);
1650 | }
1651 |
1652 | ///////////////////////////////////////////////////////////////////////////////
1653 | /// @fn FB::variant gpgPublishPublicKey(const std::string& keyid)
1654 | ///
1655 | /// @brief Exports the key specified by to the configured keyserver
1656 | ///////////////////////////////////////////////////////////////////////////////
1657 | FB::variant webpgPluginAPI::gpgPublishPublicKey(
1658 | const std::string& keyid,
1659 | const boost::optional& callback=NULL
1660 | ) {
1661 | Json::Value json_value = m_webpgAPI->gpgPublishPublicKey(keyid);
1662 |
1663 | if (callback != NULL) {
1664 | js_callback = *callback;
1665 | js_callback->InvokeAsync("",
1666 | FB::variant_list_of(
1667 | FB::jsonToVariantValue(json_value.toStyledString())
1668 | )
1669 | );
1670 | return NULL;
1671 | }
1672 |
1673 | return FB::jsonValueToVariant(json_value);
1674 | }
1675 |
1676 | ///////////////////////////////////////////////////////////////////////////////
1677 | /// @fn FB::variant gpgRevokeKey(const std::string& keyid,
1678 | /// int key_idx,
1679 | /// int reason,
1680 | /// const std::string &desc)
1681 | ///
1682 | /// @brief Revokes the given subkey with the reason and description specified.
1683 | ///
1684 | /// @param keyid The ID of the key to revoke.
1685 | /// @param key_idx The index of the subkey to revoke.
1686 | /// @param reason The gnupg reason for the revocation.
1687 | /// @param desc The text description for the revocation.
1688 | ///////////////////////////////////////////////////////////////////////////////
1689 | FB::variant webpgPluginAPI::gpgRevokeKey(
1690 | const std::string& keyid,
1691 | int key_idx, int reason,
1692 | const std::string &desc,
1693 | const boost::optional& callback=NULL
1694 | ) {
1695 | Json::Value json_value = m_webpgAPI->gpgRevokeKey(
1696 | keyid,
1697 | key_idx,
1698 | reason,
1699 | desc
1700 | );
1701 |
1702 | if (callback != NULL) {
1703 | js_callback = *callback;
1704 | js_callback->InvokeAsync("",
1705 | FB::variant_list_of(
1706 | FB::jsonToVariantValue(json_value.toStyledString())
1707 | )
1708 | );
1709 | return NULL;
1710 | }
1711 |
1712 | return FB::jsonValueToVariant(json_value);
1713 | }
1714 |
1715 | ///////////////////////////////////////////////////////////////////////////////
1716 | /// @fn FB::variant gpgRevokeUID(const std::string& keyid,
1717 | /// int uid_idx,
1718 | /// int reason,
1719 | /// const std::string &desc)
1720 | ///
1721 | /// @brief Revokes the given UID with the reason and description specified.
1722 | ///
1723 | /// @param keyid The ID of the key with the UID to revoke.
1724 | /// @param uid_idx The index of the UID to revoke.
1725 | /// @param reason The gnupg reason for the revocation.
1726 | /// @param desc The text description for the revocation.
1727 | ///////////////////////////////////////////////////////////////////////////////
1728 | FB::variant webpgPluginAPI::gpgRevokeUID(
1729 | const std::string& keyid,
1730 | int uid_idx, int reason,
1731 | const std::string &desc,
1732 | const boost::optional& callback=NULL
1733 | ) {
1734 | Json::Value json_value = m_webpgAPI->gpgRevokeUID(
1735 | keyid,
1736 | uid_idx,
1737 | reason,
1738 | desc
1739 | );
1740 |
1741 | if (callback != NULL) {
1742 | js_callback = *callback;
1743 | js_callback->InvokeAsync("",
1744 | FB::variant_list_of(
1745 | FB::jsonToVariantValue(json_value.toStyledString())
1746 | )
1747 | );
1748 | return NULL;
1749 | }
1750 |
1751 | return FB::jsonValueToVariant(json_value);
1752 | }
1753 |
1754 | ///////////////////////////////////////////////////////////////////////////////
1755 | /// @fn FB::variant gpgRevokeSignature(const std::string& keyid,
1756 | /// int uid_idx,
1757 | /// int sig_idx,
1758 | /// int reason,
1759 | /// const std::string &desc)
1760 | ///
1761 | /// @brief Revokes the given signature on the specified UID of key
1762 | /// with the reason and description specified.
1763 | ///
1764 | /// @param keyid The ID of the key with the signature to revoke.
1765 | /// @param uid_idx The index of the UID with the signature to revoke.
1766 | /// @param sig_idx The index of the signature to revoke.
1767 | /// @param reason The gnupg reason for the revocation.
1768 | /// @param desc The text description for the revocation.
1769 | ///////////////////////////////////////////////////////////////////////////////
1770 | FB::variant webpgPluginAPI::gpgRevokeSignature(
1771 | const std::string& keyid,
1772 | int uid_idx,
1773 | int sig_idx,
1774 | int reason,
1775 | const std::string &desc,
1776 | const boost::optional& callback=NULL
1777 | ) {
1778 | Json::Value json_value = m_webpgAPI->gpgRevokeSignature(
1779 | keyid,
1780 | uid_idx,
1781 | sig_idx,
1782 | reason,
1783 | desc
1784 | );
1785 |
1786 | if (callback != NULL) {
1787 | js_callback = *callback;
1788 | js_callback->InvokeAsync("",
1789 | FB::variant_list_of(
1790 | FB::jsonToVariantValue(json_value.toStyledString())
1791 | )
1792 | );
1793 | return NULL;
1794 | }
1795 |
1796 | return FB::jsonValueToVariant(json_value);
1797 | }
1798 |
1799 | ///////////////////////////////////////////////////////////////////////////////
1800 | /// @fn FB::variant gpgChangePassphrase(const std::string& keyid)
1801 | ///
1802 | /// @brief Invokes the gpg-agent to change the passphrase for the given key.
1803 | ///
1804 | /// @param keyid The ID of the key to change the passphrase.
1805 | ///////////////////////////////////////////////////////////////////////////////
1806 | FB::variant webpgPluginAPI::gpgChangePassphrase(
1807 | const std::string& keyid,
1808 | const boost::optional& callback=NULL
1809 | ) {
1810 | Json::Value json_value = m_webpgAPI->gpgChangePassphrase(keyid);
1811 |
1812 | if (callback != NULL) {
1813 | js_callback = *callback;
1814 | js_callback->InvokeAsync("",
1815 | FB::variant_list_of(
1816 | FB::jsonToVariantValue(json_value.toStyledString())
1817 | )
1818 | );
1819 | return NULL;
1820 | }
1821 |
1822 | return FB::jsonValueToVariant(json_value);
1823 | }
1824 |
1825 | void webpgPluginAPI::gpgShowPhoto(
1826 | const std::string& keyid,
1827 | const boost::optional& callback=NULL
1828 | ) {
1829 | m_webpgAPI->gpgShowPhoto(keyid);
1830 |
1831 | Json::Value json_value = "showing";
1832 |
1833 | if (callback != NULL) {
1834 | js_callback = *callback;
1835 | js_callback->InvokeAsync("",
1836 | FB::variant_list_of(
1837 | FB::jsonToVariantValue(json_value.toStyledString())
1838 | )
1839 | );
1840 | }
1841 | }
1842 |
1843 | FB::variant webpgPluginAPI::gpgAddPhoto(
1844 | const std::string& keyid,
1845 | const std::string& photo_name,
1846 | const std::string& photo_data,
1847 | const boost::optional& callback=NULL
1848 | ) {
1849 | Json::Value json_value = m_webpgAPI->gpgAddPhoto(
1850 | keyid,
1851 | photo_name,
1852 | photo_data
1853 | );
1854 |
1855 | if (callback != NULL) {
1856 | js_callback = *callback;
1857 | js_callback->InvokeAsync("",
1858 | FB::variant_list_of(
1859 | FB::jsonToVariantValue(json_value.toStyledString())
1860 | )
1861 | );
1862 | return NULL;
1863 | }
1864 |
1865 | return FB::jsonValueToVariant(json_value);
1866 | }
1867 |
1868 | FB::variant webpgPluginAPI::gpgGetPhotoInfo(
1869 | const std::string& keyid,
1870 | const boost::optional& callback=NULL
1871 | ) {
1872 | Json::Value json_value = m_webpgAPI->gpgGetPhotoInfo(keyid);
1873 |
1874 | if (callback != NULL) {
1875 | js_callback = *callback;
1876 | js_callback->InvokeAsync("",
1877 | FB::variant_list_of(
1878 | FB::jsonToVariantValue(json_value.toStyledString())
1879 | )
1880 | );
1881 | return NULL;
1882 | }
1883 |
1884 | return FB::jsonValueToVariant(json_value);
1885 | }
1886 |
1887 | ///////////////////////////////////////////////////////////////////////////////
1888 | /// @fn FB::variant setTempGPGOption(const std::string& option,
1889 | /// const std::string& value)
1890 | ///
1891 | /// @brief Creates a backup of the gpg.conf file and writes the options to
1892 | /// gpg.conf; This should be called prior to initializing the context.
1893 | ///////////////////////////////////////////////////////////////////////////////
1894 | FB::variant webpgPluginAPI::setTempGPGOption(
1895 | const std::string& option,
1896 | const std::string& value=NULL,
1897 | const boost::optional& callback=NULL
1898 | ) {
1899 | Json::Value json_value = m_webpgAPI->setTempGPGOption(
1900 | option,
1901 | value
1902 | );
1903 |
1904 | if (callback != NULL) {
1905 | js_callback = *callback;
1906 | js_callback->InvokeAsync("",
1907 | FB::variant_list_of(
1908 | FB::jsonToVariantValue(json_value.toStyledString())
1909 | )
1910 | );
1911 | return NULL;
1912 | }
1913 |
1914 | return FB::jsonValueToVariant(json_value);
1915 | }
1916 |
1917 | ///////////////////////////////////////////////////////////////////////////////
1918 | /// @fn FB::variant restoreGPGConfig()
1919 | ///
1920 | /// @brief Restores the gpg.conf file from memory or the backup file.
1921 | ///////////////////////////////////////////////////////////////////////////////
1922 | FB::variant webpgPluginAPI::restoreGPGConfig(
1923 | const boost::optional& callback=NULL
1924 | ) {
1925 | Json::Value json_value = m_webpgAPI->restoreGPGConfig();
1926 |
1927 | if (callback != NULL) {
1928 | js_callback = *callback;
1929 | js_callback->InvokeAsync("",
1930 | FB::variant_list_of(
1931 | FB::jsonToVariantValue(json_value.toStyledString())
1932 | )
1933 | );
1934 | return NULL;
1935 | }
1936 |
1937 | return FB::jsonValueToVariant(json_value);
1938 | }
1939 |
1940 | ///////////////////////////////////////////////////////////////////////////////
1941 | /// @fn FB::variant getTemporaryPath()
1942 | ///
1943 | /// @brief Attempts to determine the system or user temporary path.
1944 | ///////////////////////////////////////////////////////////////////////////////
1945 | FB::variant webpgPluginAPI::getTemporaryPath(
1946 | const boost::optional& callback=NULL
1947 | ) {
1948 | Json::Value json_value = m_webpgAPI->getTemporaryPath();
1949 |
1950 | if (callback != NULL) {
1951 | js_callback = *callback;
1952 | js_callback->InvokeAsync("",
1953 | FB::variant_list_of(
1954 | FB::jsonToVariantValue(json_value.toStyledString())
1955 | )
1956 | );
1957 | return NULL;
1958 | }
1959 |
1960 | return FB::jsonValueToVariant(json_value);
1961 | }
1962 |
1963 | FB::VariantMap webpgPluginAPI::webpg_status() {
1964 | webpgPluginAPI::init();
1965 | return webpgPluginAPI::webpg_status_map;
1966 | }
1967 |
1968 | FB::VariantMap webpgPluginAPI::get_webpg_status(
1969 | const boost::optional& callback=NULL
1970 | ) {
1971 | webpgPluginAPI::init();
1972 |
1973 | if (callback != NULL) {
1974 | js_callback = *callback;
1975 | js_callback->InvokeAsync("",
1976 | FB::variant_list_of(
1977 | webpgPluginAPI::webpg_status_map
1978 | )
1979 | );
1980 | }
1981 |
1982 | return webpgPluginAPI::webpg_status_map;
1983 | }
1984 |
1985 | std::string webpgPluginAPI::version() {
1986 | return FBSTRING_PLUGIN_VERSION;
1987 | }
1988 |
1989 | ///////////////////////////////////////////////////////////////////////////////
1990 | /// @fn std::string get_version()
1991 | ///
1992 | /// @brief Retruns the defined plugin version
1993 | ///////////////////////////////////////////////////////////////////////////////
1994 | // Read-only property version
1995 | std::string webpgPluginAPI::get_version(
1996 | const boost::optional& callback=NULL
1997 | ) {
1998 | if (callback != NULL) {
1999 | js_callback = *callback;
2000 | js_callback->InvokeAsync("",
2001 | FB::variant_list_of(
2002 | FB::jsonToVariantValue(FBSTRING_PLUGIN_VERSION)
2003 | )
2004 | );
2005 | return NULL;
2006 | }
2007 | return FBSTRING_PLUGIN_VERSION;
2008 | }
2009 |
2010 | ///////////////////////////////////////////////////////////////////////////////
2011 | /// @fn bool openpgp_detected()
2012 | ///
2013 | /// @brief Determines if OpenPGP is available as a valid engine.
2014 | ///////////////////////////////////////////////////////////////////////////////
2015 | bool webpgPluginAPI::openpgp_detected()
2016 | {
2017 | return m_webpgAPI->openpgp_detected();
2018 | }
2019 |
2020 | ///////////////////////////////////////////////////////////////////////////////
2021 | /// @fn bool gpgconf_detected()
2022 | ///
2023 | /// @brief Determines gpgconf is available to the engine.
2024 | ///////////////////////////////////////////////////////////////////////////////
2025 | bool webpgPluginAPI::gpgconf_detected()
2026 | {
2027 | return m_webpgAPI->gpgconf_detected();
2028 | }
2029 |
2030 | webpgPtr webpgPluginAPI::createWebPG()
2031 | {
2032 | return boost::make_shared();
2033 | }
2034 |
2035 | ///////////////////////////////////////////////////////////////////////////////
2036 | /// @fn FB::variant setStringMode(const bool& value)
2037 | ///
2038 | /// @brief Sets the return of JSON data as a JSON string (not parsed)
2039 | ///////////////////////////////////////////////////////////////////////////////
2040 | void webpgPluginAPI::setStringMode(const bool& value)
2041 | {
2042 | STRINGMODE = value;
2043 | }
2044 |
2045 | FB::variant webpgPluginAPI::sendMessage(
2046 | const FB::VariantMap& msgInfo,
2047 | const boost::optional& callback=NULL
2048 | ) {
2049 | Json::Value params = variantToJsonValue(msgInfo);
2050 | FB::VariantMap recipients_m = VariantMapValue(msgInfo, "recipients");
2051 | Json::Value recipients = variantToJsonValue(recipients_m);
2052 | FB::variant to = VariantListValue(recipients_m, "to");
2053 | FB::variant cc = VariantListValue(recipients_m, "cc");
2054 | FB::variant bcc = VariantListValue(recipients_m, "bcc");
2055 | FB::variant keys = VariantListValue(recipients_m, "keys");
2056 | recipients["to"] = variantToJsonValue(to);
2057 | recipients["cc"] = variantToJsonValue(cc);
2058 | recipients["bcc"] = variantToJsonValue(bcc);
2059 | recipients["keys"] = variantToJsonValue(keys);
2060 | params["recipients"] = recipients;
2061 | FB::variant signers = VariantListValue(msgInfo, "signers");
2062 | params["signers"] = variantToJsonValue(signers);
2063 |
2064 | FB::variant result = FB::jsonValueToVariant(m_webpgAPI->sendMessage(params));
2065 |
2066 | if (callback != NULL) {
2067 | js_callback = *callback;
2068 | js_callback->InvokeAsync("",
2069 | FB::variant_list_of(
2070 | result
2071 | )
2072 | );
2073 | return NULL;
2074 | }
2075 |
2076 | return result;
2077 | }
2078 |
--------------------------------------------------------------------------------
/webpgPlugin/webpgPluginAPI.h:
--------------------------------------------------------------------------------
1 | /**********************************************************\
2 | Original Author: Kyle L. Huff (kylehuff)
3 |
4 | Created: Jan 14, 2011
5 | License: GNU General Public License, version 2
6 | http://www.gnu.org/licenses/gpl-2.0.html
7 |
8 | Copyright 2011 Kyle L. Huff, CURETHEITCH development team
9 | \**********************************************************/
10 | /*! \mainpage webpg-npapi Documentation
11 | *
12 | * \section intro_sec Introduction
13 | *
14 | * webpg-npapi is an NPAPI plugin project that provides GnuPG related \
15 | * Public/Private Key operations for use in major browsers.
16 | * \n
17 | * \n
18 | *
19 | * \section install_sec Compiling
20 | *
21 | * \subsection step1 Step 1: Obtain the source
22 | *
23 | * git clone http://github.com/kylehuff/webpg-npapi.git\n
24 | * \n
25 | *
26 | * \subsection step2 Step 2: Retreieve the submodules
27 | *
28 | * cd webpg-npapi\n
29 | * git submodule init\n
30 | * git submodule update --recursive\n
31 | * \n
32 | *
33 | * \subsection step3 Step 3: Create the build environment
34 | *
35 | * \subsection linux Linux: cmake
36 | *
37 | * ./firebreath/prepmake.sh webpgPlugin build\n
38 | *
39 | * \subsection osx OSX: cmake/XCode
40 | *
41 | * ./firebreath/prepmac.sh webpgPlugin build\n
42 | *
43 | * \subsection win Windows: cmake/VS 2005, 2008, 2010
44 | *
45 | * firebreath/prep{VS version}.cmd webpgPlugin build\n
46 | * \n
47 | *
48 | * \subsection step4 Step 4: Build the source
49 | *
50 | * cmake --build build --config webpgPlugin --target MinSizeRel
51 | *
52 | *
53 | *
54 | *
55 | *
56 | *
57 | *
58 | */
59 |
60 | #include
61 | #include
62 | #include
63 | #include
64 | #include "JSObject.h"
65 | #include "JSAPIAuto.h"
66 | #include "BrowserHost.h"
67 | #include
68 | #include
69 |
70 | #if _MSC_VER
71 | #define snprintf _snprintf
72 | #endif
73 |
74 | #include "libwebpg/webpg.h"
75 |
76 | #include "webpgPlugin.h"
77 |
78 | #include "fbjson.h"
79 | #include
80 | #include "FBPointers.h"
81 |
82 | FB_FORWARD_PTR(webpgPluginAPI);
83 | FB_FORWARD_PTR(webpg);
84 |
85 | #ifndef H_webpgPluginAPI
86 | #define H_webpgPluginAPI
87 |
88 | //typedef struct {
89 | // FB::variant host_url;
90 | // FB::variant username;
91 | // FB::variant bearer;
92 | // FB::VariantMap recipients;
93 | // FB::VariantList signers;
94 | // FB::variant subject;
95 | // FB::variant message;
96 | //} msgParams;
97 |
98 | //typedef struct {
99 | // char *data;
100 | // int body_size;
101 | // int body_pos;
102 | //} readarg_t;
103 |
104 | static bool STRINGMODE = false;
105 | const int kMaxCharPerLine = 76;
106 | const char* const kEOL = "\r\n";
107 |
108 | const char kHexTable[] = "0123456789ABCDEF";
109 |
110 | inline FB::variant VariantValue(const FB::VariantMap& vmap, std::string key) {
111 | FB::VariantMap::const_iterator it;
112 | FB::variant value;
113 |
114 | it = vmap.find(key);
115 |
116 | if (it != vmap.end()) {
117 | if (it->second.is_of_type())
118 | value = "VariantMap";
119 | else if (it->second.is_of_type())
120 | value = "VaraintList";
121 | else
122 | value = it->second;
123 | }
124 |
125 | return value;
126 | }
127 |
128 | inline FB::VariantMap VariantMapValue(const FB::VariantMap& vmap, std::string key) {
129 | FB::VariantMap::const_iterator it;
130 | FB::VariantMap value;
131 |
132 | it = vmap.find(key);
133 |
134 | if (it != vmap.end())
135 | value = it->second.convert_cast();
136 |
137 | return value;
138 | }
139 |
140 | inline FB::VariantList VariantListValue(const FB::VariantMap& vmap, std::string key) {
141 | FB::VariantMap::const_iterator it;
142 | FB::VariantList value;
143 |
144 | it = vmap.find(key);
145 |
146 | if (it != vmap.end())
147 | value = it->second.convert_cast();
148 |
149 | return value;
150 | }
151 |
152 | ///////////////////////////////////////////////////////////////////////////////
153 | /// @class webpgPluginAPI
154 | ///
155 | /// @brief Main webpg Class
156 | ///////////////////////////////////////////////////////////////////////////////
157 | class webpgPluginAPI : public FB::JSAPIAuto
158 | {
159 | public:
160 | webpgPluginAPI(const webpgPluginPtr& plugin,
161 | const FB::BrowserHostPtr& host);
162 | virtual ~webpgPluginAPI();
163 |
164 | webpgPluginPtr getPlugin();
165 |
166 | webpgPtr createWebPG();
167 |
168 | FB::VariantMap webpg_status_map;
169 |
170 | ///////////////////////////////////////////////////////////////////////////
171 | /// @fn void init()
172 | ///
173 | /// @brief Initializes the webpgPlugin and sets the status variables.
174 | ///////////////////////////////////////////////////////////////////////////
175 | void init();
176 |
177 | ///////////////////////////////////////////////////////////////////////////
178 | /// @fn FB::variant webpgPluginAPI::getPublicKeyList()
179 | ///
180 | /// @brief Calls webpgPluginAPI::getKeyList() without specifying a search
181 | /// string, and the secret_only paramter as false, which returns only
182 | /// Public Keys from the keyring.
183 | ///////////////////////////////////////////////////////////////////////////
184 | FB::variant getPublicKeyList(
185 | const boost::optional fast,
186 | const boost::optional async,
187 | const boost::optional& callback
188 | );
189 |
190 | void threaded_getPublicKeyList();
191 |
192 | ///////////////////////////////////////////////////////////////////////////
193 | /// @fn FB::variant getPrivateKeyList()
194 | ///
195 | /// @brief Calls webpgPluginAPI::getKeyList() without specifying a search
196 | /// string, and the secret_only paramter as true, which returns only
197 | /// Private Keys from the keyring.
198 | ///////////////////////////////////////////////////////////////////////////
199 | FB::variant getPrivateKeyList(
200 | const boost::optional fast,
201 | const boost::optional async,
202 | const boost::optional& callback
203 | );
204 |
205 | ///////////////////////////////////////////////////////////////////////////
206 | /// @fn FB::variant getNamedKey(const std::string& name)
207 | ///
208 | /// @brief Calls webpgPluginAPI::getKeyList() with a search string and the
209 | /// secret_only paramter as false, which returns only Public Keys from
210 | /// the keyring.
211 | ///////////////////////////////////////////////////////////////////////////
212 | FB::variant getNamedKey(
213 | const std::string& name,
214 | const boost::optional fast,
215 | const boost::optional async,
216 | const boost::optional& callback
217 | );
218 |
219 | ///////////////////////////////////////////////////////////////////////////
220 | /// @fn FB::variant getExternalKey(const std::string& name)
221 | ///
222 | /// @brief Calls webpgPluginAPI::getKeyList() after setting the context to
223 | /// external mode with a search string and the secret_only paramter as
224 | /// "0", which returns only Public Keys
225 | ///////////////////////////////////////////////////////////////////////////
226 | FB::variant getExternalKey(
227 | const std::string& name,
228 | const boost::optional& callback
229 | );
230 |
231 | ///////////////////////////////////////////////////////////////////////////
232 | /// @fn FB::variant gpgSetPreference(const std::string& preference,
233 | /// const std::string& pref_value)
234 | ///
235 | /// @brief Attempts to set the specified gpgconf preference with the value
236 | /// of pref_value.
237 | ///
238 | /// @param preference The preference to set.
239 | /// @param pref_value The value to assign to the specified preference.
240 | ///////////////////////////////////////////////////////////////////////////
241 | FB::variant gpgSetPreference(
242 | const std::string& preference,
243 | const std::string& pref_value,
244 | const boost::optional& callback
245 | );
246 |
247 | ///////////////////////////////////////////////////////////////////////////
248 | /// @fn FB::variant gpgGetPreference(const std::string& preference)
249 | ///
250 | /// @brief Attempts to gett the specified gpgconf preference with the value
251 | /// of pref_value.
252 | ///
253 | /// @param preference The preference to set.
254 | ///////////////////////////////////////////////////////////////////////////
255 | FB::variant gpgGetPreference(
256 | const std::string& preference,
257 | const boost::optional& callback
258 | );
259 |
260 | ///////////////////////////////////////////////////////////////////////////
261 | /// @fn FB::variant webpgPluginAPI::gpgSetGroup(
262 | /// const std::string& group,
263 | /// const std::string& group_value)
264 | ///
265 | /// @brief Attempts to define or clear the specified group preference
266 | /// with the value of .
267 | ///
268 | /// @param group The group to set.
269 | /// @param group_value The value to assign to the specified group.
270 | ///////////////////////////////////////////////////////////////////////////
271 | FB::variant gpgSetGroup(
272 | const std::string& group,
273 | const std::string& group_value,
274 | const boost::optional& callback
275 | );
276 |
277 | ///////////////////////////////////////////////////////////////////////////
278 | /// @fn FB::variant webpgPluginAPI::gpgSetHomeDir(const std::string& gnupg_path)
279 | ///
280 | /// @brief Sets the GNUPGHOME static variable to the path specified in
281 | /// gnupg_path. This should be called prior to initializing the
282 | /// gpgme context.
283 | ///////////////////////////////////////////////////////////////////////////
284 | FB::variant gpgSetHomeDir(
285 | const std::string& gnupg_path,
286 | const boost::optional& callback
287 | );
288 | FB::variant gpgGetHomeDir(
289 | const boost::optional& callback
290 | );
291 |
292 | ///////////////////////////////////////////////////////////////////////////
293 | /// @fn FB::variant webpgPluginAPI::gpgSetBinary(const std::string& gnupg_exec)
294 | ///
295 | /// @brief Sets the GNUPGBIN static variable to the path specified in
296 | /// gnupg_exec. This should be called prior to initializing the
297 | /// gpgme context.
298 | ///////////////////////////////////////////////////////////////////////////
299 | FB::variant gpgSetBinary(
300 | const std::string& gnupg_exec,
301 | const boost::optional& callback
302 | );
303 | FB::variant gpgGetBinary(
304 | const boost::optional& callback
305 | );
306 |
307 | ///////////////////////////////////////////////////////////////////////////
308 | /// @fn FB::variant webpgPluginAPI::gpgSetGPGConf(const std::string& gpgconf_exec)
309 | ///
310 | /// @brief Sets the GPGCONF static variable to the path specified in
311 | /// gpgconf_exec.
312 | ///////////////////////////////////////////////////////////////////////////
313 | FB::variant gpgSetGPGConf(
314 | const std::string& gpgconf_exec,
315 | const boost::optional& callback
316 | );
317 | FB::variant gpgGetGPGConf(
318 | const boost::optional& callback
319 | );
320 |
321 | ///////////////////////////////////////////////////////////////////////////
322 | /// @fn FB::variant webpgPluginAPI::gpgEncrypt(const std::string& data, const FB::VariantList& enc_to_keyids, bool sign)
323 | ///
324 | /// @brief Encrypts the data passed in data with the key ids passed in
325 | /// enc_to_keyids and optionally signs the data.
326 | ///
327 | /// @param data The data to encrypt.
328 | /// @param enc_to_keyids A VariantList of key ids to encrypt to (recpients).
329 | /// @param sign The data should be also be signed.
330 | ///////////////////////////////////////////////////////////////////////////
331 | FB::variant gpgEncrypt(
332 | const std::string& data,
333 | const FB::VariantList& enc_to_keyids,
334 | const boost::optional& sign,
335 | const boost::optional& opt_signers,
336 | const boost::optional& callback
337 | );
338 |
339 | ///////////////////////////////////////////////////////////////////////////
340 | /// @fn FB::variant webpgPluginAPI::gpgSymmetricEncrypt(const std::string& data, bool sign)
341 | ///
342 | /// @brief Calls webpgPluginAPI::gpgEncrypt() without any recipients specified
343 | /// which initiates a Symmetric encryption method on the gpgme context.
344 | ///
345 | /// @param data The data to symmetrically encrypt.
346 | /// @param sign The data should also be signed. NOTE: Signed symmetric
347 | /// encryption does not work in gpgme v1.3.2; For details,
348 | /// see https://bugs.g10code.com/gnupg/issue1440
349 | ///////////////////////////////////////////////////////////////////////////
350 | FB::variant gpgSymmetricEncrypt(
351 | const std::string& data,
352 | const boost::optional& sign,
353 | const boost::optional& opt_signers,
354 | const boost::optional& callback
355 | );
356 |
357 | ///////////////////////////////////////////////////////////////////////////
358 | /// @fn FB::variant webpgPluginAPI::gpgDecryptVerify(const std::string& data, const std::string& plaintext, int use_agent)
359 | ///
360 | /// @brief Attempts to decrypt and verify the string data. If use_agent
361 | /// is 0, it will attempt to disable the key-agent to prevent the
362 | /// passphrase dialog from displaying. This is useful in cases where
363 | /// you want to verify or decrypt without unlocking the private keyring
364 | /// (i.e. in an automated parsing environment).
365 | ///
366 | /// @param data The data to decrypt and/or verify.
367 | /// @param plaintext The plaintext of a detached signature.
368 | /// @param use_agent Attempt to disable the gpg-agent.
369 | ///////////////////////////////////////////////////////////////////////////
370 | FB::variant gpgDecryptVerify(
371 | const std::string& data,
372 | const std::string& plaintext,
373 | int use_agent,
374 | const boost::optional& callback
375 | );
376 |
377 | ///////////////////////////////////////////////////////////////////////////
378 | /// @fn FB::variant webpgPluginAPI::gpgDecrypt(const std::string& data)
379 | ///
380 | /// @brief Calls webpgPluginAPI::gpgDecryptVerify() with the use_agent flag
381 | /// specifying to not disable the gpg-agent.
382 | ///
383 | /// @param data The data to decyrpt.
384 | ///////////////////////////////////////////////////////////////////////////
385 | FB::variant gpgDecrypt(
386 | const std::string& data,
387 | const boost::optional& callback
388 | );
389 |
390 | FB::variant gpgVerify(
391 | const std::string& data,
392 | const boost::optional& plaintext,
393 | const boost::optional& callback
394 | );
395 | ///////////////////////////////////////////////////////////////////////////
396 | /// @fn FB::variant webpgPluginAPI::gpgSignText(FB::VariantList& signers, const std::string& plain_text, int sign_mode)
397 | ///
398 | /// @brief Signs the text specified in plain_text with the key ids specified
399 | /// in signers, with the signature mode specified in sign_mode.
400 | ///////////////////////////////////////////////////////////////////////////
401 | FB::variant gpgSignText(
402 | const std::string& plain_text,
403 | const FB::VariantList& signers,
404 | const boost::optional& opt_sign_mode,
405 | const boost::optional& callback
406 | );
407 |
408 | ///////////////////////////////////////////////////////////////////////////
409 | /// @fn FB::variant webpgPluginAPI::gpgSignUID(const std::string& keyid, long sign_uid, const std::string& with_keyid, long local_only, long trust_sign, long trust_level)
410 | ///
411 | /// @brief Signs the UID index of the specified keyid using the signing key
412 | /// with_keyid.
413 | ///
414 | /// @param keyid The ID of the key with the desired UID to sign.
415 | /// @param sign_uid The 0 based index of the UID.
416 | /// @param with_keyid The ID of the key to create the signature with.
417 | /// @param local_only Specifies if the signature is local only (non exportable).
418 | /// @param trust_sign Specifies if this is a trust signature.
419 | /// @param trust_level The level of trust to assign.
420 | ///////////////////////////////////////////////////////////////////////////
421 | FB::variant gpgSignUID(
422 | const std::string& keyid,
423 | long uid,
424 | const std::string& with_keyid,
425 | long local_only,
426 | long trust_sign,
427 | long trust_level,
428 | const boost::optional& notation_name,
429 | const boost::optional& notation_value,
430 | const boost::optional& callback
431 | );
432 |
433 | ///////////////////////////////////////////////////////////////////////////
434 | /// @fn FB::variant webpgPluginAPI::gpgDeleteUIDSign(const std::string& keyid, long uid, long signature)
435 | ///
436 | /// @brief Deletes the Signature signature on the uid of keyid.
437 | ///
438 | /// @param keyid The ID of the key containing the UID to delete the signature from.
439 | /// @param uid The index of the UID containing the signature to delete.
440 | /// @param signature The signature index of the signature to delete.
441 | ///////////////////////////////////////////////////////////////////////////
442 | FB::variant gpgDeleteUIDSign(
443 | const std::string& keyid,
444 | long sign_uid,
445 | long signature,
446 | const boost::optional& callback
447 | );
448 |
449 | ///////////////////////////////////////////////////////////////////////////
450 | /// @fn FB::variant webpgPluginAPI::gpgEnableKey(const std::string& keyid)
451 | ///
452 | /// @brief Sets the key specified with keyid as enabled in gpupg.
453 | ///
454 | /// @param keyid The ID of the key to enable.
455 | ///////////////////////////////////////////////////////////////////////////
456 | FB::variant gpgEnableKey(
457 | const std::string& keyid,
458 | const boost::optional& callback
459 | );
460 |
461 | ///////////////////////////////////////////////////////////////////////////
462 | /// @fn FB::variant webpgPluginAPI::gpgDisableKey(const std::string& keyid)
463 | ///
464 | /// @brief Sets the key specified with keyid as disabled in gpupg.
465 | ///
466 | /// @param keyid The ID of the key to disable.
467 | ///////////////////////////////////////////////////////////////////////////
468 | FB::variant gpgDisableKey(
469 | const std::string& keyid,
470 | const boost::optional& callback
471 | );
472 |
473 | ///////////////////////////////////////////////////////////////////////////
474 | /// @fn std::string webpgPluginAPI::gpgGenKey(const std::string& key_type, const std::string& key_length,
475 | /// const std::string& subkey_type, const std::string& subkey_length, const std::string& name_real,
476 | /// const std::string& name_comment, const std::string& name_email, const std::string& expire_date,
477 | /// const std::string& passphrase)
478 | ///
479 | /// @brief Queues a threaded gpg genkey operation.
480 | ///
481 | /// @param key_type The key type to genereate.
482 | /// @param key_length The size of the key to generate.
483 | /// @param subkey_type The subkey type to generate.
484 | /// @param subkey_length The size of the subkey to genereate.
485 | /// @param name_real The name to assign the UID.
486 | /// @param name_comment The comment to assign to the UID.
487 | /// @param name_email The email address to assign to the UID.
488 | /// @param expire_date The expiration date to assign to the generated key.
489 | /// @param passphrase The passphrase to assign the to the key.
490 | ///////////////////////////////////////////////////////////////////////////
491 | std::string gpgGenKey(
492 | const std::string& key_type,
493 | const std::string& key_length,
494 | const std::string& subkey_type,
495 | const std::string& subkey_length,
496 | const std::string& name_real,
497 | const std::string& name_comment,
498 | const std::string& name_email,
499 | const std::string& expire_date,
500 | const std::string& passphrase
501 | );
502 |
503 | ///////////////////////////////////////////////////////////////////////////
504 | /// @fn std::string webpgPluginAPI::gpgGenSubKey(const std::string& keyid,
505 | /// const std::string& subkey_type, const std::string& subkey_length,
506 | /// const std::string& subkey_expire, bool sign_flag, bool enc_flag, bool auth_flag)
507 | ///
508 | /// @brief Queues a threaded gpg gensubkey operation.
509 | ///
510 | /// @param keyid The key to generate the subkey on.
511 | /// @param subkey_type The subkey type to generate.
512 | /// @param subkey_length The size of the subkey to genereate.
513 | /// @param subkey_expire The expiration date to assign to the generated subkey.
514 | /// @param sign_flag Set the sign capabilities flag.
515 | /// @param enc_flag Set the encrypt capabilities flag.
516 | /// @param auth_flag Set the auth capabilities flag.
517 | ///////////////////////////////////////////////////////////////////////////
518 | std::string gpgGenSubKey(
519 | const std::string& keyid,
520 | const std::string& subkey_type, const std::string& subkey_length,
521 | const std::string& subkey_expire, bool sign_flag, bool enc_flag,
522 | bool auth_flag
523 | );
524 |
525 | /*
526 | static class method which accepts the calling object as a parameter
527 | so it can thread a member function
528 | */
529 | static void genKeyThreadCaller(webpgPluginAPI* api, genKeyParams params)
530 | {
531 | api->threaded_gpgGenKey(params);
532 | };
533 |
534 | static void genSubKeyThreadCaller(webpgPluginAPI* api,
535 | genSubKeyParams params)
536 | {
537 | api->threaded_gpgGenSubKey(params);
538 | };
539 |
540 | static void getKeyListThreadCaller(
541 | const std::string& name,
542 | bool secret_only,
543 | bool fast,
544 | webpgPluginAPI* api
545 | );
546 |
547 | ///////////////////////////////////////////////////////////////////////////
548 | /// @fn void webpgPluginAPI::keygen_progress_cb(void *self, const char *what, int type, int current, int total)
549 | ///
550 | /// @brief Called by the long-running, asymmetric gpg genkey method to display the status.
551 | ///
552 | /// @param self A reference to webpgPluginAPI, since the method is called
553 | /// outside of the class.
554 | /// @param what The current action status from gpg genkey.
555 | /// @param type The type of of action.
556 | /// @param current ?
557 | /// @param total ?
558 | ///////////////////////////////////////////////////////////////////////////
559 | static void keygen_progress_cb(
560 | void *self, const char *what,
561 | int type, int current, int total
562 | );
563 |
564 | static void keylist_progress_cb(void *self, const char* msg_value);
565 | static void javascript_cb(void *self, const char* msg_value);
566 | FB::JSObjectPtr threaded_js_callback;
567 | FB::JSObjectPtr js_callback;
568 |
569 | ///////////////////////////////////////////////////////////////////////////
570 | /// @fn void webpgPluginAPI::threaded_gpgGenKey(genKeyParams params)
571 | ///
572 | /// @brief Calls webpgPluginAPI::gpgGenKeyWorker() with the specified parameters.
573 | ///
574 | /// @param params The parameters used to generete the key.
575 | ///////////////////////////////////////////////////////////////////////////
576 | void threaded_gpgGenKey(genKeyParams params);
577 |
578 | ///////////////////////////////////////////////////////////////////////////
579 | /// @fn void webpgPluginAPI::threaded_gpgGenSubKey(genKeyParams params)
580 | ///
581 | /// @brief Calls gpgGenSubKeyWorker() with the specified parameters.
582 | ///
583 | /// @param params The parameters used to generete the subkey.
584 | ///////////////////////////////////////////////////////////////////////////
585 | void threaded_gpgGenSubKey(genSubKeyParams params);
586 |
587 | ///////////////////////////////////////////////////////////////////////////
588 | /// @fn FB::variant webpgPluginAPI::gpgImportKey(const std::string& ascii_key)
589 | ///
590 | /// @brief Imports the ASCII encoded key ascii_key
591 | ///
592 | /// @param ascii_key An armored, ascii encoded PGP Key block.
593 | ///////////////////////////////////////////////////////////////////////////
594 | FB::variant gpgImportKey(
595 | const std::string& ascii_key,
596 | const boost::optional& callback
597 | );
598 |
599 | ///////////////////////////////////////////////////////////////////////////
600 | /// @fn FB::variant webpgPluginAPI::gpgImportExternalKey(const std::string& ascii_key)
601 | ///
602 | /// @brief Imports the ASCII encoded key ascii_key
603 | ///
604 | /// @param ascii_key An armored, ascii encoded PGP Key block.
605 | ///////////////////////////////////////////////////////////////////////////
606 | FB::variant gpgImportExternalKey(
607 | const std::string& keyid,
608 | const boost::optional& callback
609 | );
610 |
611 | ///////////////////////////////////////////////////////////////////////////
612 | /// @fn FB::variant webpgPluginAPI::gpgDeletePublicKey(const std::string& keyid)
613 | ///
614 | /// @brief Deletes key specified in keyid from the Public keyring.
615 | ///
616 | /// @param keyid The ID of the key to delete from the Public keyring.
617 | ///////////////////////////////////////////////////////////////////////////
618 | FB::variant gpgDeletePublicKey(
619 | const std::string& keyid,
620 | const boost::optional& callback
621 | );
622 |
623 | ///////////////////////////////////////////////////////////////////////////
624 | /// @fn FB::variant webpgPluginAPI::gpgDeletePrivateKey(const std::string& keyid)
625 | ///
626 | /// @brief Deletes key specified in keyid from the Private keyring.
627 | ///
628 | /// @param keyid The ID of the key to delete from the Private keyring.
629 | ///////////////////////////////////////////////////////////////////////////
630 | FB::variant gpgDeletePrivateKey(
631 | const std::string& keyid,
632 | const boost::optional& callback
633 | );
634 |
635 | ///////////////////////////////////////////////////////////////////////////
636 | /// @fn FB::variant webpgPluginAPI::gpgDeletePrivateSubKey(const std::string& keyid, int key_idx)
637 | ///
638 | /// @brief Deletes subkey located at index key_idx form the key specified in keyid.
639 | ///
640 | /// @param keyid The ID of the key to delete the subkey from.
641 | /// @param key_idx The index of the subkey to delete.
642 | ///////////////////////////////////////////////////////////////////////////
643 | FB::variant gpgDeletePrivateSubKey(
644 | const std::string& keyid,
645 | int key_idx,
646 | const boost::optional& callback
647 | );
648 |
649 | ///////////////////////////////////////////////////////////////////////////
650 | /// @fn FB::variant webpgPluginAPI::gpgSetKeyTrust(const std::string& keyid, long trust_level)
651 | ///
652 | /// @brief Sets the gnupg trust level assignment for the given keyid.
653 | ///
654 | /// @param keyid The ID of the key to assign the trust level on.
655 | /// @param trust_level The level of trust to assign.
656 | ///////////////////////////////////////////////////////////////////////////
657 | FB::variant gpgSetKeyTrust(
658 | const std::string& keyid,
659 | long trust_level,
660 | const boost::optional& callback
661 | );
662 |
663 | ///////////////////////////////////////////////////////////////////////////
664 | /// @fn FB::variant webpgPluginAPI::gpgAddUID(const std::string& keyid, const std::string& name,
665 | /// const std::string& email, const std::string& comment)
666 | ///
667 | /// @brief Adds a new UID to the key specified by keyid
668 | ///
669 | /// @param keyid The ID of the key to add the UID to.
670 | /// @param name The name to assign to the new UID.
671 | /// @param email The email address to assign to the new UID.
672 | /// @param comment The comment to assign to the new UID.
673 | ///////////////////////////////////////////////////////////////////////////
674 | FB::variant gpgAddUID(
675 | const std::string& keyid,
676 | const std::string& name,
677 | const std::string& email,
678 | const std::string& comment,
679 | const boost::optional& callback
680 | );
681 |
682 | ///////////////////////////////////////////////////////////////////////////
683 | /// @fn FB::variant webpgPluginAPI::gpgDeleteUID(const std::string& keyid, long uid_idx)
684 | ///
685 | /// @brief Deletes the UID specified by uid_idx from the key specified with keyid.
686 | ///
687 | /// @param keyid The ID of the key to delete to the specified UID from.
688 | /// @param uid_idx The index of the UID to delete from the key.
689 | ///////////////////////////////////////////////////////////////////////////
690 | FB::variant gpgDeleteUID(
691 | const std::string& keyid,
692 | long uid_idx,
693 | const boost::optional& callback
694 | );
695 |
696 | ///////////////////////////////////////////////////////////////////////////
697 | /// @fn FB::variant webpgPluginAPI::gpgSetPrimaryUID(const std::string& keyid, long uid_idx)
698 | ///
699 | /// @brief Sets a given UID as the primary for the key specified with keyid.
700 | ///
701 | /// @param keyid The ID of the key with the UID to make primary.
702 | /// @param uid_idx The index of the UID to make primary on the key.
703 | ///////////////////////////////////////////////////////////////////////////
704 | FB::variant gpgSetPrimaryUID(
705 | const std::string& keyid,
706 | long uid_idx,
707 | const boost::optional& callback
708 | );
709 |
710 | ///////////////////////////////////////////////////////////////////////////
711 | /// @fn FB::variant webpgPluginAPI::gpgSetKeyExpire(const std::string& keyid, long key_idx, long expire)
712 | ///
713 | /// @brief Sets the expiration of the given key_idx on the key keyid with the expiration of expire.
714 | ///
715 | /// @param keyid The ID of the key to set the expiration on.
716 | /// @param key_idx The index of the subkey to set the expiration on.
717 | /// @param expire The expiration to assign.
718 | ///////////////////////////////////////////////////////////////////////////
719 | FB::variant gpgSetKeyExpire(
720 | const std::string& keyid,
721 | long key_idx,
722 | long expire,
723 | const boost::optional& callback
724 | );
725 |
726 | ///////////////////////////////////////////////////////////////////////////
727 | /// @fn FB::variant webpgPluginAPI::gpgSetPubkeyExpire(const std::string& keyid, long expire)
728 | ///
729 | /// @brief Sets the expiration of the public key of the given keyid.
730 | ///
731 | /// @param keyid The ID of the key to set the expiration on.
732 | /// @param expire The expiration to assign to the key.
733 | ///////////////////////////////////////////////////////////////////////////
734 | FB::variant gpgSetPubkeyExpire(
735 | const std::string& keyid,
736 | long expire,
737 | const boost::optional& callback
738 | );
739 |
740 | ///////////////////////////////////////////////////////////////////////////
741 | /// @fn FB::variant webpgPluginAPI::gpgSetSubkeyExpire(const std::string& keyid, long key_idx, long expire)
742 | ///
743 | /// @brief Sets the expiration of the subkey specified with key_idx on the key specified with keyid.
744 | ///
745 | /// @param keyid The ID of the key to set the expiration on.
746 | /// @param key_idx The index of the subkey to set the expiration on.
747 | /// @param expire The expiration to assign to the key.
748 | ///////////////////////////////////////////////////////////////////////////
749 | FB::variant gpgSetSubkeyExpire(
750 | const std::string& keyid,
751 | long key_idx,
752 | long expire,
753 | const boost::optional& callback
754 | );
755 |
756 | ///////////////////////////////////////////////////////////////////////////
757 | /// @fn FB::variant webpgPluginAPI::gpgExportPublicKey(const std::string& keyid)
758 | ///
759 | /// @brief Exports the public key specified with keyid as an ASCII armored encoded PGP Block.
760 | ///////////////////////////////////////////////////////////////////////////
761 | FB::variant gpgExportPublicKey(
762 | const std::string& keyid,
763 | const boost::optional& callback
764 | );
765 |
766 | ///////////////////////////////////////////////////////////////////////////
767 | /// @fn FB::variant webpgPluginAPI::gpgPublishPublicKey(const std::string& keyid)
768 | ///
769 | /// @brief Exports the key specified by keyid to the configured keyserver
770 | ///////////////////////////////////////////////////////////////////////////
771 | FB::variant gpgPublishPublicKey(
772 | const std::string& keyid,
773 | const boost::optional& callback
774 | );
775 |
776 | ///////////////////////////////////////////////////////////////////////////
777 | /// @fn FB::variant webpgPluginAPI::gpgRevokeKey(const std::string& keyid, int key_idx, int reason,
778 | /// const std::string &desc)
779 | ///
780 | /// @brief Revokes the given key/subkey with the reason and description specified.
781 | ///
782 | /// @param keyid The ID of the key to revoke.
783 | /// @param key_idx The index of the subkey to revoke.
784 | /// @param reason The gnupg reason for the revocation.
785 | /// @param desc The text description for the revocation.
786 | ///////////////////////////////////////////////////////////////////////////
787 | FB::variant gpgRevokeKey(
788 | const std::string& keyid,
789 | int key_idx,
790 | int reason,
791 | const std::string &desc,
792 | const boost::optional& callback
793 | );
794 |
795 | ///////////////////////////////////////////////////////////////////////////
796 | /// @fn FB::variant webpgPluginAPI::gpgRevokeUID(const std::string& keyid, int uid_idx, int reason,
797 | /// const std::string &desc)
798 | ///
799 | /// @brief Revokes the given UID with the reason and description specified.
800 | ///
801 | /// @param keyid The ID of the key with the UID to revoke.
802 | /// @param uid_idx The index of the UID to revoke.
803 | /// @param reason The gnupg reason for the revocation.
804 | /// @param desc The text description for the revocation.
805 | ///////////////////////////////////////////////////////////////////////////
806 | FB::variant gpgRevokeUID(
807 | const std::string& keyid,
808 | int uid_idx,
809 | int reason,
810 | const std::string &desc,
811 | const boost::optional& callback
812 | );
813 |
814 | ///////////////////////////////////////////////////////////////////////////
815 | /// @fn FB::variant webpgPluginAPI::gpgRevokeSignature(const std::string& keyid, int uid_idx, int sig_idx,
816 | /// int reason, const std::string &desc)
817 | ///
818 | /// @brief Revokes the given signature on the specified UID of key keyid with the reason and description specified.
819 | ///
820 | /// @param keyid The ID of the key with the signature to revoke.
821 | /// @param uid_idx The index of the UID with the signature to revoke.
822 | /// @param sig_idx The index of the signature to revoke.
823 | /// @param reason The gnupg reason for the revocation.
824 | /// @param desc The text description for the revocation.
825 | ///////////////////////////////////////////////////////////////////////////
826 | FB::variant gpgRevokeSignature(
827 | const std::string& keyid,
828 | int uid_idx,
829 | int sig_idx,
830 | int reason,
831 | const std::string &desc,
832 | const boost::optional& callback
833 | );
834 |
835 | ///////////////////////////////////////////////////////////////////////////
836 | /// @fn FB::variant webpgPluginAPI::gpgChangePassphrase(const std::string& keyid)
837 | ///
838 | /// @brief Invokes the gpg-agent to change the passphrase for the given key.
839 | ///
840 | /// @param keyid The ID of the key to change the passphrase.
841 | ///////////////////////////////////////////////////////////////////////////
842 | FB::variant gpgChangePassphrase(
843 | const std::string& keyid,
844 | const boost::optional& callback
845 | );
846 |
847 | void gpgShowPhoto(
848 | const std::string& keyid,
849 | const boost::optional& callback
850 | );
851 |
852 | FB::variant gpgAddPhoto(
853 | const std::string& keyid,
854 | const std::string& photo_name,
855 | const std::string& photo_data,
856 | const boost::optional& callback
857 | );
858 |
859 | FB::variant gpgGetPhotoInfo(
860 | const std::string& keyid,
861 | const boost::optional& callback
862 | );
863 |
864 | ///////////////////////////////////////////////////////////////////////////
865 | /// @fn FB::variant webpgPluginAPI::setTempGPGOption(const std::string& option, const std::string& value)
866 | ///
867 | /// @brief Creates a backup of the gpg.conf file and writes the options to
868 | /// gpg.conf; This should be called prior to initializing the context.
869 | ///////////////////////////////////////////////////////////////////////////
870 | FB::variant setTempGPGOption(
871 | const std::string& option,
872 | const std::string& value,
873 | const boost::optional& callback
874 | );
875 |
876 | ///////////////////////////////////////////////////////////////////////////
877 | /// @fn FB::variant webpgPluginAPI::restoreGPGConfig()
878 | ///
879 | /// @brief Restores the gpg.conf file from memory or the backup file.
880 | ///////////////////////////////////////////////////////////////////////////
881 | FB::variant restoreGPGConfig(
882 | const boost::optional& callback
883 | );
884 |
885 | ///////////////////////////////////////////////////////////////////////////
886 | /// @fn FB::variant webpgPluginAPI::getTemporaryPath()
887 | ///
888 | /// @brief Attempts to determine the system or user temporary path.
889 | ///////////////////////////////////////////////////////////////////////////
890 | FB::variant getTemporaryPath(
891 | const boost::optional& callback
892 | );
893 |
894 | FB::variant sendMessage(
895 | const FB::VariantMap& msgInfo,
896 | const boost::optional& callback
897 | );
898 |
899 | FB::VariantMap webpg_status();
900 |
901 | ///////////////////////////////////////////////////////////////////////////
902 | /// @fn FB::variant webpgPluginAPI::get_webpg_status()
903 | ///
904 | /// @brief Executes webpgPluginAPI::init() to set the status variables and
905 | /// populates the "edit_status" property with the contents of the
906 | /// edit_status constant.
907 | ///////////////////////////////////////////////////////////////////////////
908 | FB::VariantMap get_webpg_status(
909 | const boost::optional& callback
910 | );
911 |
912 | ///////////////////////////////////////////////////////////////////////////
913 | /// @fn std::string webpgPluginAPI::get_version()
914 | ///
915 | /// @brief Retruns the defined plugin version
916 | ///////////////////////////////////////////////////////////////////////////
917 | std::string version();
918 | std::string get_version(
919 | const boost::optional& callback
920 | );
921 |
922 | ///////////////////////////////////////////////////////////////////////////
923 | /// @fn bool webpgPluginAPI::openpgp_detected()
924 | ///
925 | /// @brief Determines if OpenPGP is available as a valid engine.
926 | ///////////////////////////////////////////////////////////////////////////
927 | bool openpgp_detected();
928 |
929 | ///////////////////////////////////////////////////////////////////////////
930 | /// @fn bool webpgPluginAPI::gpgconf_detected()
931 | ///
932 | /// @brief Determines if gpgconf is available to the engine.
933 | ///////////////////////////////////////////////////////////////////////////
934 | bool gpgconf_detected();
935 |
936 | void setStringMode(const bool& value);
937 | FB_JSAPI_EVENT(prog, 1, (std::string));
938 | private:
939 | webpgPluginWeakPtr m_plugin;
940 | webpgPtr m_webpgAPI;
941 | FB::BrowserHostPtr m_host;
942 | int IsEOL(
943 | const std::string::const_iterator& iter,
944 | const std::string& input
945 | );
946 | };
947 |
948 | #endif // H_webpgPluginAPI
949 |
--------------------------------------------------------------------------------