Revision: 7504
          http://mahogany.svn.sourceforge.net/mahogany/?rev=7504&view=rev
Author:   vadz
Date:     2008-08-05 00:11:21 +0000 (Tue, 05 Aug 2008)

Log Message:
-----------
add GUI support for cryptographically signing the messages

Modified Paths:
--------------
    trunk/M/CHANGES
    trunk/M/doc/Manual.htex
    trunk/M/include/Composer.h
    trunk/M/include/Moptions.h
    trunk/M/include/gui/wxComposeView.h
    trunk/M/src/classes/Moptions.cpp
    trunk/M/src/gui/wxComposeView.cpp
    trunk/M/src/gui/wxOptionsDlg.cpp

Modified: trunk/M/CHANGES
===================================================================
--- trunk/M/CHANGES     2008-08-04 20:45:51 UTC (rev 7503)
+++ trunk/M/CHANGES     2008-08-05 00:11:21 UTC (rev 7504)
@@ -6,9 +6,10 @@
       See at the end of file for the list of contributors (initials appearing
       in the second column of the changelog below).
 
-Release 0.68 '' September xx, 2007
+Release 0.68 '' September xx, 2008
 ---------------------------------------
 
+2008-08-05 VZ: Add support for signing outgoing messages using OpenPGP
 2008-05-04 VZ: Improve the display of the embedded messages.
 2008-05-04 VZ: Allow toggling tool/status bars and showing full-screen.
 2008-05-02 VZ: Add support for server-side spam filters.

Modified: trunk/M/doc/Manual.htex
===================================================================
--- trunk/M/doc/Manual.htex     2008-08-04 20:45:51 UTC (rev 7503)
+++ trunk/M/doc/Manual.htex     2008-08-05 00:11:21 UTC (rev 7504)
@@ -69,6 +69,8 @@
 
 \begin{itemize}
    \item A much faster DSPAM storage driver is used now.
+   \item Mahogany now supports signing outgoing messages using OpenPGP, see
+         the new options in the composer options page (\ref{ComposePage}).
    \item Added ``Remove attachments'' command which can be used to strip the
          unwanted attachments from a message in a local or IMAP folder.
    \item Added the possibility to treat different addresses as equivalent,
@@ -2319,6 +2321,20 @@
 \item \textbf{Use signature separator}\\
 If enabled, your signature will be separated from the text with two
 dashes. This is a common Internet/Usenet convention.
+\item \textbf{Show signing controls in composer}\\
+If this option is enabled, the checkbox allowing you to choose whether you want
+to sign the message cryptographically is shown in the composer. Disable this
+option only if you are sure that you never want to sign your messages to free
+up some screen space.
+\item \textbf{Enable signing by default}\\
+If true, the checkbox mentioned above will be initially checked. Notice that
+if you are editing the options of an individual folder, this option can be set
+from here but that it is also changed by simply setting or clearing the
+checkbox -- its contents will be remembered for the next messages composed from
+this folder.
+\item \textbf{User name to sign messages as}\\
+If you have multiple keys, select the one to be used by default (it will be
+possible to change it for the individual messages in the composer window) here.
 \item \textbf{Use XFace}\\
 XFaces are small black and white bitmaps which can be added to the
 message header to identify the sender. Mahogany will recognise and

Modified: trunk/M/include/Composer.h
===================================================================
--- trunk/M/include/Composer.h  2008-08-04 20:45:51 UTC (rev 7503)
+++ trunk/M/include/Composer.h  2008-08-05 00:11:21 UTC (rev 7504)
@@ -32,6 +32,9 @@
 /// the composer options (i.e. values read from profile)
 struct ComposerOptions
 {
+   /// @name Appearance options
+   //@{
+
    /// font description
    String m_font;
 
@@ -43,6 +46,20 @@
    wxColour m_fg,
             m_bg;
 
+   //@}
+
+   /// @name PGP options
+   //@{
+
+   /// sign the message cryptographically?
+   bool m_signWithPGP;
+
+   /// the user name to sign as
+   String m_signWithPGPAs;
+
+   //@}
+
+
    /// ctor initializes everything to some invalid values
    ComposerOptions();
 

Modified: trunk/M/include/Moptions.h
===================================================================
--- trunk/M/include/Moptions.h  2008-08-04 20:45:51 UTC (rev 7503)
+++ trunk/M/include/Moptions.h  2008-08-05 00:11:21 UTC (rev 7504)
@@ -223,6 +223,9 @@
 extern const MOption MP_COMPOSE_USE_SIGNATURE;
 extern const MOption MP_COMPOSE_SIGNATURE;
 extern const MOption MP_COMPOSE_USE_SIGNATURE_SEPARATOR;
+extern const MOption MP_COMPOSE_USE_PGP;
+extern const MOption MP_COMPOSE_PGPSIGN;
+extern const MOption MP_COMPOSE_PGPSIGN_AS;
 extern const MOption MP_COMPOSE_USE_XFACE;
 extern const MOption MP_COMPOSE_XFACE_FILE;
 extern const MOption MP_FOLDER_TYPE;
@@ -857,6 +860,12 @@
 #define   MP_COMPOSE_SIGNATURE_NAME      "SignatureFile"
 /// use "-- " to separate signature in composition?
 #define   MP_COMPOSE_USE_SIGNATURE_SEPARATOR_NAME   "ComposeSeparateSignature"
+/// show PGP-related controls in the composer?
+#define   MP_COMPOSE_USE_PGP_NAME   "ShowPGPControls"
+/// sign messages with PGP?
+#define   MP_COMPOSE_PGPSIGN_NAME   "SignWithPGP"
+/// the user name to sign messages with PGP as
+#define   MP_COMPOSE_PGPSIGN_AS_NAME   "SignWithPGPAs"
 
 /// use XFace in composition?
 #define   MP_COMPOSE_USE_XFACE_NAME   "UseXFaces"
@@ -1721,6 +1730,12 @@
 #endif
 /// use "-- " to separate signature in composition?
 #define   MP_COMPOSE_USE_SIGNATURE_SEPARATOR_DEFVAL   1
+/// show PGP-related controls in the composer?
+#define   MP_COMPOSE_USE_PGP_DEFVAL   1l
+/// sign messages with PGP?
+#define   MP_COMPOSE_PGPSIGN_DEFVAL   1l
+/// the user name to sign messages with PGP as
+#define   MP_COMPOSE_PGPSIGN_AS_DEFVAL   ""
 
 /// use XFace in composition?
 #define   MP_COMPOSE_USE_XFACE_DEFVAL   1

Modified: trunk/M/include/gui/wxComposeView.h
===================================================================
--- trunk/M/include/gui/wxComposeView.h 2008-08-04 20:45:51 UTC (rev 7503)
+++ trunk/M/include/gui/wxComposeView.h 2008-08-05 00:11:21 UTC (rev 7504)
@@ -443,8 +443,11 @@
    void CreateMenu();
 
    /// create and initialize the editor
-   void CreateEditor(void);
+   void CreateEditor();
 
+   /// create the PGP-related controls, returns the window containing them all
+   wxWindow *CreatePGPControls();
+
    /// init our various appearance parameters
    void InitAppearance();
 
@@ -476,6 +479,12 @@
    /// get the options (for MessageEditor)
    const Options& GetOptions() const { return m_options; }
 
+   /// update UI handler for "sign as" control
+   void OnUpdateUISignAs(wxUpdateUIEvent& event)
+   {
+      event.Enable( m_chkPGPSign->GetValue() );
+   }
+
    /// the profile (never NULL)
    Profile *m_Profile;
 
@@ -524,6 +533,12 @@
       /// the editor where the message is really edited
    MessageEditor *m_editor;
 
+      /// checkbox enabling cryptographically signing the message
+   wxCheckBox *m_chkPGPSign;
+
+      /// the user name to use for cryptographically signing the message
+   wxTextCtrl *m_txtPGPSignAs;
+
    //@}
 
    /// the type of the last recipient

Modified: trunk/M/src/classes/Moptions.cpp
===================================================================
--- trunk/M/src/classes/Moptions.cpp    2008-08-04 20:45:51 UTC (rev 7503)
+++ trunk/M/src/classes/Moptions.cpp    2008-08-05 00:11:21 UTC (rev 7504)
@@ -284,6 +284,9 @@
 const MOption MP_COMPOSE_USE_SIGNATURE;
 const MOption MP_COMPOSE_SIGNATURE;
 const MOption MP_COMPOSE_USE_SIGNATURE_SEPARATOR;
+const MOption MP_COMPOSE_USE_PGP;
+const MOption MP_COMPOSE_PGPSIGN;
+const MOption MP_COMPOSE_PGPSIGN_AS;
 const MOption MP_COMPOSE_USE_XFACE;
 const MOption MP_COMPOSE_XFACE_FILE;
 const MOption MP_FOLDER_TYPE;
@@ -705,6 +708,9 @@
     DEFINE_OPTION(MP_COMPOSE_USE_SIGNATURE),
     DEFINE_OPTION(MP_COMPOSE_SIGNATURE),
     DEFINE_OPTION(MP_COMPOSE_USE_SIGNATURE_SEPARATOR),
+    DEFINE_OPTION(MP_COMPOSE_USE_PGP),
+    DEFINE_OPTION(MP_COMPOSE_PGPSIGN),
+    DEFINE_OPTION(MP_COMPOSE_PGPSIGN_AS),
     DEFINE_OPTION(MP_COMPOSE_USE_XFACE),
     DEFINE_OPTION(MP_COMPOSE_XFACE_FILE),
     DEFINE_OPTION(MP_FOLDER_TYPE),

Modified: trunk/M/src/gui/wxComposeView.cpp
===================================================================
--- trunk/M/src/gui/wxComposeView.cpp   2008-08-04 20:45:51 UTC (rev 7503)
+++ trunk/M/src/gui/wxComposeView.cpp   2008-08-05 00:11:21 UTC (rev 7504)
@@ -118,8 +118,11 @@
 extern const MOption MP_CHECK_FORGOTTEN_ATTACHMENTS;
 extern const MOption MP_COMPOSE_BCC;
 extern const MOption MP_COMPOSE_CC;
+extern const MOption MP_COMPOSE_PGPSIGN;
+extern const MOption MP_COMPOSE_PGPSIGN_AS;
 extern const MOption MP_COMPOSE_SHOW_FROM;
 extern const MOption MP_COMPOSE_TO;
+extern const MOption MP_COMPOSE_USE_PGP;
 extern const MOption MP_CURRENT_IDENTITY;
 extern const MOption MP_CVIEW_BGCOLOUR;
 extern const MOption MP_CVIEW_COLOUR_HEADERS;
@@ -956,6 +959,10 @@
       m_fontFamily = GetFontFamilyFromProfile(profile, MP_CVIEW_FONT);
       m_fontSize = READ_CONFIG(profile, MP_CVIEW_FONT_SIZE);
    }
+
+   // PGP options
+   m_signWithPGP = READ_CONFIG_BOOL(profile, MP_COMPOSE_PGPSIGN);
+   m_signWithPGPAs = READ_CONFIG_TEXT(profile, MP_COMPOSE_PGPSIGN_AS);
 }
 
 wxFont ComposerOptions::GetFont() const
@@ -1808,6 +1815,9 @@
    m_encoding = wxFONTENCODING_SYSTEM;
 
    m_txtSubject = NULL;
+
+   m_chkPGPSign = NULL;
+   m_txtPGPSignAs = NULL;
 }
 
 bool wxComposeView::IsReplyTo(const Message& original) const
@@ -1860,6 +1870,16 @@
 
 wxComposeView::~wxComposeView()
 {
+   // save the last values of PGP options
+   if ( m_chkPGPSign )
+   {
+      const bool sign = m_chkPGPSign->GetValue();
+      m_Profile->writeEntry(MP_COMPOSE_PGPSIGN, sign);
+      if ( sign )
+         m_Profile->writeEntry(MP_COMPOSE_PGPSIGN_AS, 
m_txtPGPSignAs->GetValue());
+   }
+
+
    delete m_rcptMain;
    WX_CLEAR_ARRAY(m_rcptExtra);
 
@@ -2224,6 +2244,15 @@
    m_splitter->SplitHorizontally(m_panel, m_editor->GetWindow(), 
heightHeaders);
    m_splitter->SetMinimumPaneSize(heightHeaders);
 
+   if ( READ_CONFIG(m_Profile, MP_COMPOSE_USE_PGP) )
+   {
+      wxBoxSizer * const sizer = new wxBoxSizer(wxVERTICAL);
+      sizer->Add(m_splitter, wxSizerFlags(1).Expand());
+      sizer->Add(CreatePGPControls(), wxSizerFlags().Expand());
+      SetSizer(sizer);
+   }
+   //else: rely on splitter taking up the entire frame as its only child
+
    // note that we must show and layout the frame before setting the control
    // values or the text would be scrolled to the right in the text fields as
    // they initially don't have enough space to show it...
@@ -2247,9 +2276,8 @@
    AddTo(READ_CONFIG(m_Profile, MP_COMPOSE_TO));
 }
 
-/// create the compose window itself
 void
-wxComposeView::CreateEditor(void)
+wxComposeView::CreateEditor()
 {
    wxASSERT_MSG( m_editor == NULL, _T("creating the editor twice?") );
 
@@ -2311,6 +2339,48 @@
    m_editor = editor;
 }
 
+wxWindow *
+wxComposeView::CreatePGPControls()
+{
+   wxPanel * const panelPGP = new wxPanel(this);
+   wxBoxSizer * const sizer = new wxBoxSizer(wxHORIZONTAL);
+
+   // align all subsequent controls to the right by inserting an expandable
+   // sizer before them
+   sizer->AddStretchSpacer();
+
+   m_chkPGPSign = new wxCheckBox(panelPGP, wxID_ANY, _("&Sign message"));
+   m_chkPGPSign->SetToolTip(
+      _("If checked, the message will be cryptographically signed.\n"
+        "\n"
+        "You need to have access to the private key which will be "
+        "used for signing.")
+   );
+   m_chkPGPSign->SetValue(m_options.m_signWithPGP);
+   sizer->Add(m_chkPGPSign, wxSizerFlags().Border(wxALL & ~wxRIGHT).Centre());
+
+   sizer->Add(new wxStaticText(panelPGP, wxID_ANY, _("a&s ")),
+              wxSizerFlags().Centre());
+
+   m_txtPGPSignAs = new wxTextCtrl(panelPGP, wxID_ANY, 
m_options.m_signWithPGPAs);
+   m_txtPGPSignAs->SetToolTip(
+      _("Enter here the user name to use for signing or leave empty to use "
+        "the default key in your key store.")
+   );
+   sizer->Add(m_txtPGPSignAs, wxSizerFlags().Border(wxALL & ~wxLEFT).Centre());
+
+   m_txtPGPSignAs->Connect(
+      wxEVT_UPDATE_UI,
+      wxUpdateUIEventHandler(wxComposeView::OnUpdateUISignAs),
+      NULL,
+      this
+   );
+
+   panelPGP->SetSizer(sizer);
+
+   return panelPGP;
+}
+
 void
 wxComposeView::InitAppearance()
 {
@@ -4623,6 +4693,16 @@
       msg->AddHeaderEntry(headerNames[nHeader], headerValues[nHeader]);
    }
 
+
+   // postprocess the message
+   // -----------------------
+
+   // cryptographically sign the message if configured to do it
+   if ( m_chkPGPSign->GetValue() )
+   {
+      msg->EnableSigning(m_txtPGPSignAs->GetValue());
+   }
+
    // the caller is responsible for deleting the object
    return msg.Detach();
 }

Modified: trunk/M/src/gui/wxOptionsDlg.cpp
===================================================================
--- trunk/M/src/gui/wxOptionsDlg.cpp    2008-08-04 20:45:51 UTC (rev 7503)
+++ trunk/M/src/gui/wxOptionsDlg.cpp    2008-08-05 00:11:21 UTC (rev 7504)
@@ -260,6 +260,11 @@
    ConfigField_Signature,
    ConfigField_SignatureFile,
    ConfigField_SignatureSeparator,
+   ConfigField_ComposerSpacer0,
+   ConfigField_SignWithPGPHelp,
+   ConfigField_SignWithPGPEnable,
+   ConfigField_SignWithPGP,
+   ConfigField_SignWithPGPAs,
    ConfigField_XFaceFile,
    ConfigField_WrapMargin,
 
@@ -1306,8 +1311,19 @@
                                                    Field_Bool | 
Field_Advanced,  -1},
    { gettext_noop("&Use signature"),               Field_Bool,    -1,          
              },
    { gettext_noop("&Signature file"),              Field_File,    
ConfigField_Signature      },
+
    { gettext_noop("Use signature se&parator"),     Field_Bool,    
ConfigField_Signature      },
 
+   { "",                                           Field_Message, -1 },
+   { gettext_noop("Mahogany may sign outgoing messages in OpenPGP format.\n"
+                  "You need to have a private key to be able to do this, "
+                  "if you have several of them you may specify the one to 
use\n"
+                  "by default below (you will be able to change it in the "
+                  "composer window)"),             Field_Message, -1 },
+   { gettext_noop("Show &signing controls in composer"), Field_Bool, -1 },
+   { gettext_noop("Enable signing by &default"),   Field_Bool, 
ConfigField_SignWithPGPEnable },
+   { gettext_noop("&User name to sign messages as"), Field_Advanced | 
Field_Text,
+                                                   ConfigField_SignWithPGP },
    { gettext_noop("Configure &XFace..."),          Field_XFace,   -1          
},
    { gettext_noop("&Wrap margin"),                 Field_Number | 
Field_Global,  -1,                        },
 
@@ -2054,6 +2070,11 @@
    CONFIG_ENTRY(MP_COMPOSE_USE_SIGNATURE),
    CONFIG_ENTRY(MP_COMPOSE_SIGNATURE),
    CONFIG_ENTRY(MP_COMPOSE_USE_SIGNATURE_SEPARATOR),
+   CONFIG_NONE(), // spacer
+   CONFIG_NONE(), // PGP help
+   CONFIG_ENTRY(MP_COMPOSE_USE_PGP),
+   CONFIG_ENTRY(MP_COMPOSE_PGPSIGN),
+   CONFIG_ENTRY(MP_COMPOSE_PGPSIGN_AS),
    CONFIG_ENTRY(MP_COMPOSE_XFACE_FILE),
    CONFIG_ENTRY(MP_WRAPMARGIN),
 


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to