[GnuPG Logo]    
· English ·        
Links  
   
 
authorMarkus Montkowski <[email protected]>
Thu, 15 May 2025 12:36:04 +0000 (14:36 +0200)
committerMarkus Montkowski <[email protected]>
Thu, 15 May 2025 12:36:04 +0000 (14:36 +0200)
* src/explorer-events: change hasSelection to only return true if a
                       mailitem was selected and
                       hasMailitemEventReadBeenCalled returns true
* src/gpgoladdin.h:   define new functions
                        markMailitemEventReadAsCalled
                        bool hasMailitemEventReadBeenCalled
* src/gpgoladdin.cpp: implement the new functions and a static var to
                      store the state.
* src/mail.h:         remove code for isVdPostponed
* src/map.cpp:        implement isVdPostponed and add more loging
* src/mailitem-events.cpp: Call markMailitemEventReadAsCalled on READ
* src/ribbon-callbacks.cpp: Add Tracepoint calls to hunt down crash

--
Add functions to set/read a flag gets set whenever the mailitem-event
READ event is called it indicated that no other addin like titus
filtered out the event. If set we invalidate the ribon on
SelectionChange events in explorer-events as we would normally do that
on handling the READ event.

src/explorer-events.cpp
src/gpgoladdin.cpp
src/gpgoladdin.h
src/mail.cpp
src/mail.h
src/mailitem-events.cpp
src/ribbon-callbacks.cpp

index 9fbb6144670757f234d5ffaaabe7c3afa774e663..0476b7e4522b44f776dba467611ef93a7796f116 100644 (file)
@@ -114,7 +114,7 @@ hasSelection (LPDISPATCH explorer)
   if (count)
     {
       LPDISPATCH selectitem = NULL, mailitem = NULL;
-      bool selected = true;
+      bool selected = hasMailitemEventReadBeenCalled ();
       if (count == 1)
         {
           // If we call this on a selection with more items
index 416da3378b1a4ff5cfc006d0f83d5cb2f0a61e49..f85d63188ca2eade94d6768184c5bad82153906e 100644 (file)
@@ -420,6 +420,23 @@ void check_auto_vd_mail()
     }
 }
 
+/* This flag gets set whenever the mailitem-event READ event
+is called it indicated that no other addin like titus filtered
+out the READ event. If set we invalidate the ribon on SelectionChange
+events in explorer-events as we would normally do that on handling READ*/
+static bool mailitemEventReadCalled = false;
+void
+markMailitemEventReadAsCalled()
+{
+  mailitemEventReadCalled = true;
+}
+
+bool
+hasMailitemEventReadBeenCalled()
+{
+  return mailitemEventReadCalled;
+}
+
 void
 check_html_preferred()
 {
@@ -513,7 +530,7 @@ GpgolAddin::OnStartupComplete (SAFEARRAY** custom)
   TRACEPOINT;
 
   i18n_init ();
-
+TRACEPOINT
   if (!create_responder_window())
     {
       log_error ("%s:%s: Failed to create the responder window;",
@@ -533,7 +550,7 @@ GpgolAddin::OnStartupComplete (SAFEARRAY** custom)
       log_error ("%s:%s: Failed to create messagehook. ",
                  SRCNAME, __func__);
     }
-
+TRACEPOINT
   /* Clean GpgOL prefixed categories.
      They might be left over from a crash or something unexpected
      error. We want to avoid pollution with the signed by categories.
@@ -543,10 +560,10 @@ GpgolAddin::OnStartupComplete (SAFEARRAY** custom)
   m_applicationEventSink = install_ApplicationEvents_sink (m_application);
   m_explorersEventSink = install_explorer_sinks (m_application);
   check_html_preferred ();
-
+TRACEPOINT
   CloseHandle (CreateThread (NULL, 0, init_gpgme_config, nullptr, 0,
                              NULL));
-
+TRACEPOINT
   KeyCache::instance ()->populate ();
   return S_OK;
 }
index a119493b34615f9fca8cf938662b0ef48bfbdfd0..da4a62acd0a11ccb56771fcadc21d0d4fc107649 100644 (file)
@@ -290,4 +290,8 @@ void gpgoladdin_invalidate_ui ();
  * Registry key.  */
 void check_html_preferred ();
 
+/* Functions to detect/handle filtered READ events*/
+void markMailitemEventReadAsCalled();
+bool hasMailitemEventReadBeenCalled();
+
 #endif /*GPGOLADDIN_H*/
index f3865e7a4571b644dd6048ac3286f11b26a6045f..67a1ce878b629d3b664e0ac60e06cac813324da0 100644 (file)
@@ -112,7 +112,7 @@ Mail::Mail (LPDISPATCH mailitem) :
     m_close_triggered(false),
     m_is_html_alternative(false),
     m_needs_encrypt(false),
-    m_vd_postponed(false),
+    m_vd_postponed(true),
     m_moss_position(0),
     m_crypto_flags(0),
     m_cached_html_body(nullptr),
@@ -1314,8 +1314,10 @@ Mail::isCryptoMail () const
       m_type == MSGTYPE_SMIME)
     {
       /* Not a message for us. */
+      log_debug ("N");
       TRETURN false;
     }
+  log_debug ("Y");
   TRETURN true;
 }
 
@@ -3418,13 +3420,17 @@ bool
 Mail::isSigned () const
 {
   TSTART;
-  TRETURN m_verify_result.numSignatures() > 0;
+  bool ret =  m_verify_result.numSignatures() > 0;
+  log_debug (ret?"Y":"N");
+  TRETURN ret;
 }
 
 bool
 Mail::isEncrypted () const
 {
   TSTART;
+  log_debug (!m_decrypt_result.isNull()?"Y":"N");
+
   TRETURN !m_decrypt_result.isNull();
 }
 
@@ -3945,12 +3951,14 @@ Mail::get_signature_level () const
   TSTART;
   if (!m_is_signed)
     {
+      log_debug("level=0");
       TRETURN 0;
     }
 
   if (m_uid.isNull ())
     {
       /* No m_uid matches our sender. */
+      log_debug("level=0");
       TRETURN 0;
     }
 
@@ -3958,21 +3966,28 @@ Mail::get_signature_level () const
       (m_uid.validity () == UserID::Validity::Full &&
       level_4_check (m_uid))) && (!in_de_vs_mode () || m_sig.isDeVs()))
     {
+      log_debug("level=4");
       TRETURN 4;
     }
   if (m_is_valid && m_uid.validity () == UserID::Validity::Full &&
       (!in_de_vs_mode () || m_sig.isDeVs()))
     {
+      log_debug("level=3");
       TRETURN 3;
     }
   if (m_is_valid)
     {
+      log_debug("level=2");
       TRETURN 2;
     }
   if (m_sig.validity() == Signature::Validity::Marginal)
     {
+      log_debug("level=1");
       TRETURN 1;
     }
+
+  log_debug("level=0");
+
   if (m_sig.summary() & Signature::Summary::TofuConflict ||
       m_uid.tofuInfo().validity() == TofuInfo::Conflict)
     {
@@ -3987,6 +4002,7 @@ Mail::getCryptoIconID () const
   TSTART;
   int level = get_signature_level ();
   int offset = isEncrypted () ? ENCRYPT_ICON_OFFSET : 0;
+  log_debug("CryptoIconID=%d", IDI_LEVEL_0 + level + offset);
   TRETURN IDI_LEVEL_0 + level + offset;
 }
 
@@ -4849,16 +4865,28 @@ Mail::setDoAutosecure_m (bool value)
 bool
 Mail::realyDecryptedSuccessfully () const
 {
-  return m_decrypt_result.isNull() || m_decrypt_result.error().code()==0;
+  TSTART;
+  bool ret = m_decrypt_result.isNull() || m_decrypt_result.error().code()==0;
+  log_debug ("%s:%s: return %s", SRCNAME, __func__, ret?"Y":"N");
+  TRETURN ret;
 }
 
 
 bool
 Mail::decryptedSuccessfully () const
 {
-  return m_decrypt_result.isNull() || !m_decrypt_result.error();
+  TSTART;
+  bool ret = m_decrypt_result.isNull() || !m_decrypt_result.error();
+  log_debug ("%s:%s: return %s", SRCNAME, __func__, ret?"Y":"N");
+  TRETURN ret;
 }
 
+bool Mail::isVdPostponed () const
+{
+  log_debug ("%s:%s: %s", SRCNAME, __func__, m_vd_postponed?"Y":"N");
+  return m_vd_postponed;
+};
+
 void
 Mail::installFolderEventHandler_o()
 {
index df3ac1e0dbcf90af5059355a41fceeb82c2f1d4d..caaf94890347658fcf98bdca6c913e87c68ed19e 100644 (file)
@@ -727,7 +727,7 @@ public:
   /* returns a copy from copy() with setCopyParent set*/
   Mail * getCopy();
 
-  bool isVdPostponed () const { return m_vd_postponed; };
+  bool isVdPostponed () const;
 
 private:
   /* Returns a copy of the mail object. */
index f5e2a482b0068be6e0a98124a45e84bf54eb6cdd..258f9cd1fef5394cf00143c874eeebbe981ac04d 100644 (file)
@@ -266,6 +266,8 @@ EVENT_SINK_INVOKE(MailItemEvents)
               log_addins ();
               addinsLogged = true;
             }
+
+          markMailitemEventReadAsCalled();
           if (!m_mail->isCryptoMail ())
             {
               log_debug ("%s:%s: Non crypto mail %p opened. Updating sigstatus.",
index fa288d17def424ae1e788f646858761617c980c9..c234088c694e6456cec14a9adfbb7da4557f01d9 100644 (file)
@@ -852,7 +852,8 @@ HRESULT get_is_crypto_mail (LPDISPATCH ctrl, VARIANT *result)
   MY_MAIL_GETTER
 
   result->vt = VT_BOOL | VT_BYREF;
-  result->pboolVal = mail && ((mail->isSigned () &&!mail->isEncrypted()) || mail->realyDecryptedSuccessfully ()) ?
+  result->pboolVal = mail && !mail->isVdPostponed ()
+                 && ((mail->isSigned () &&!mail->isEncrypted ()) || mail->realyDecryptedSuccessfully ()) ?
                           &var_true : &var_false;
 
   TRACEPOINT;
@@ -864,7 +865,7 @@ HRESULT get_is_vd_postponed (LPDISPATCH ctrl, VARIANT *result)
   MY_MAIL_GETTER
 
   result->vt = VT_BOOL | VT_BYREF;
-  result->pboolVal = mail && (mail->isVdPostponed () ) ?
+  result->pboolVal = mail && (mail->isVdPostponed () && mail->isCryptoMail ()) ?
                           &var_true : &var_false;
 
   TRACEPOINT;
 
   
 
 
  Technical resources for this
service are sponsered by
 
  g10 Code GmbH  

Valid XHTML 1.0!     Peace!     Valid CSS!