[Spambayes-checkins] spambayes/Outlook2000 addin.py,1.87,1.88

Mark Hammond mhammond at users.sourceforge.net
Fri Aug 8 00:45:49 EDT 2003


Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1:/tmp/cvs-serv27218

Modified Files:
	addin.py 
Log Message:
Fix bug [ 784323 ] Plug-in will not intialize/watch in offline mode
by not treating failure to create the 'Spam' field in the Outlook folder
as fatal.  I'm sure it used to not be fatal once, and is again now :)


Index: addin.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/addin.py,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** addin.py	6 Aug 2003 06:56:21 -0000	1.87
--- addin.py	8 Aug 2003 06:45:47 -0000	1.88
***************
*** 1154,1158 ****
                      new_hook.Init(msgstore_folder, self.application, self.manager)
                      new_hooks[msgstore_folder.id] = new_hook
!                     self.manager.EnsureOutlookFieldsForFolder(msgstore_folder.GetID())
                      print "SpamBayes: Watching for new messages in folder ", name
              else:
--- 1154,1169 ----
                      new_hook.Init(msgstore_folder, self.application, self.manager)
                      new_hooks[msgstore_folder.id] = new_hook
!                     try:
!                         self.manager.EnsureOutlookFieldsForFolder(msgstore_folder.GetID())
!                     except:
!                         # An exception checking that Outlook's folder has a
!                         # 'spam' field is not fatal, nor really even worth
!                         # telling the user about, nor even worth a traceback
!                         # (as it is likely a COM error).
!                         print "ERROR: Failed to check folder '%s' for " \
!                               "Spam field" % name
!                         etype, value, tb = sys.exc_info()
!                         tb = None # dont want it, and nuke circular ref
!                         traceback.print_exception(etype, value, tb)
                      print "SpamBayes: Watching for new messages in folder ", name
              else:
***************
*** 1209,1216 ****
          pass
  
! def RegisterAddin(klass):
!     # prints to help debug binary install issues.
      import _winreg
!     key = _winreg.CreateKey(_winreg.HKEY_CURRENT_USER,
                              "Software\\Microsoft\\Office\\Outlook\\Addins")
      subkey = _winreg.CreateKey(key, klass._reg_progid_)
--- 1220,1226 ----
          pass
  
! def _DoRegister(klass, root):
      import _winreg
!     key = _winreg.CreateKey(root,
                              "Software\\Microsoft\\Office\\Outlook\\Addins")
      subkey = _winreg.CreateKey(key, klass._reg_progid_)
***************
*** 1219,1226 ****
--- 1229,1259 ----
      _winreg.SetValueEx(subkey, "Description", 0, _winreg.REG_SZ, "SpamBayes anti-spam tool")
      _winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, "SpamBayes")
+ 
+ def RegisterAddin(klass):
+     import _winreg
+     # Try and register twice - once in HKLM, and once in HKCU.  This seems
+     # to help roaming profiles, etc.  Once registered, it is both registered
+     # on this machine for the current user (even when they roam, assuming it
+     # has been installed on the remote machine also) and for any user on this
+     # machine.
+     try:
+         _DoRegister(klass, _winreg.HKEY_LOCAL_MACHINE)
+     except WindowsError:
+         # But they may not have the rights to install there.
+         pass
+     # We don't catch exception registering just for this user though
+     # that is fatal!
+     _DoRegister(klass, _winreg.HKEY_CURRENT_USER)
      print "Registration complete."
  
  def UnregisterAddin(klass):
      import _winreg
+     try:
+         _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE,
+                           "Software\\Microsoft\\Office\\Outlook\\Addins\\" \
+                           + klass._reg_progid_)
+     except WindowsError:
+         pass
+     # and again for current user.
      try:
          _winreg.DeleteKey(_winreg.HKEY_CURRENT_USER,





More information about the Spambayes-checkins mailing list