Update of /cvsroot/mahogany/M/src/gui
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28270/src/gui

Modified Files:
        wxMApp.cpp wxModulesDlg.cpp 
Log Message:
1. show all modules in modules dialog and allow the user to prevent them
   from being loaded instead of asking him to select those which he wants
   to be loaded
2. removed support for .mmd files from MModule, nobody used it for ages
   anyhow
3. MModule::GetProvider() now looks among all modules, not just loaded ones


Index: wxMApp.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxMApp.cpp,v
retrieving revision 1.291
retrieving revision 1.292
diff -b -u -2 -r1.291 -r1.292
--- wxMApp.cpp  7 Jul 2004 19:43:37 -0000       1.291
+++ wxMApp.cpp  11 Jul 2004 00:07:17 -0000      1.292
@@ -1529,20 +1529,19 @@
 wxMApp::LoadModules(void)
 {
-   kbStringList modules;
-   kbStringList::iterator i;
+   RefCounter<MModuleListing>
+      listing(MModule::ListAvailableModules(STARTUP_INTERFACE));
 
-   String moduleString = READ_APPCONFIG(MP_MODULES);
-   wxChar *modulestring = strutil_strdup(moduleString);
-   strutil_tokenise(modulestring, _T(":"), modules);
-   delete [] modulestring;
+   if ( !listing )
+      return;
 
-   MModule *module;
-   for(i = modules.begin(); i != modules.end(); i++)
+   const size_t count = listing->Count();
+   for ( size_t n = 0; n < count; n++ )
    {
-      module = MModule::LoadModule(**i);
-      if(module == NULL)
+      const String& name = (*listing)[n].GetName();
+      MModule *module = MModule::LoadModule(name);
+
+      if ( !module )
       {
-         ERRORMESSAGE((_("Cannot load module '%s'."),
-                       (**i).c_str()));
+         ERRORMESSAGE((_("Cannot load module '%s'."), name.c_str()));
       }
       else
@@ -1557,5 +1556,5 @@
                    module->GetVersion()));
 
-#endif
+#endif // DEBUG
       }
    }
@@ -1567,5 +1566,5 @@
    for ( ModulesList::iterator i = gs_GlobalModulesList.begin();
          i != gs_GlobalModulesList.end();
-         i++ )
+         ++i )
    {
       MModule *module = (**i).m_Module;
@@ -1582,9 +1581,8 @@
 wxMApp::UnloadModules(void)
 {
-   for (ModulesList::iterator j = gs_GlobalModulesList.begin();
-       j != gs_GlobalModulesList.end();)
+   for ( ModulesList::iterator i = gs_GlobalModulesList.begin();
+         i != gs_GlobalModulesList.end();
+         ++i )
    {
-      ModulesList::iterator i = j;
-      ++j;
       (**i).m_Module->DecRef();
    }

Index: wxModulesDlg.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxModulesDlg.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -b -u -2 -r1.32 -r1.33
--- wxModulesDlg.cpp    18 Jun 2004 02:31:28 -0000      1.32
+++ wxModulesDlg.cpp    11 Jul 2004 00:07:18 -0000      1.33
@@ -1,9 +1,17 @@
-/*-*- c++ -*-********************************************************
- * wxModulesDlg.cpp -  a dialog to choose which modules to load     *
- *                                                                  *
- * (C) 1999-2000 by Karsten Ball�der ([EMAIL PROTECTED])            *
- *                                                                  *
- * $Id$
- *******************************************************************/
+///////////////////////////////////////////////////////////////////////////////
+// Project:     M - cross platform e-mail GUI client
+// File name:   gui/wxModulesDlg.cpp
+// Purpose:     dialog to configure the modules [not] to load
+// Author:      Karsten Ball�der
+// Modified by: Vadim Zeitlin on 2004-07-11 to select modules not to be loaded
+// Created:     13.04.01 (extracted from src/gui/wxComposeView.cpp)
+// CVS-ID:      $Id$
+// Copyright:   (c) 1999-2004 M-Team
+// Licence:     M license
+///////////////////////////////////////////////////////////////////////////////
+
+// ============================================================================
+// declarations
+// ============================================================================
 
 // ----------------------------------------------------------------------------
@@ -34,8 +42,16 @@
 #include "gui/wxDialogLayout.h"
 
-extern const MOption MP_MODULES;
+// ----------------------------------------------------------------------------
+// options and message boxes we use here
+// ----------------------------------------------------------------------------
+
+extern const MOption MP_MODULES_DONT_LOAD;
 
 extern const MPersMsgBox *M_MSGBOX_MODULES_WARNING;
 
+// ----------------------------------------------------------------------------
+// wxModulesDialog
+// ----------------------------------------------------------------------------
+
 class wxModulesDialog : public wxManuallyLaidOutDialog
 {
@@ -54,8 +70,6 @@
 protected:
    MModuleListing *m_Listing;
-   kbStringList    m_Modules;
    wxCheckListBox *m_checklistBox;
    wxTextCtrl     *m_textCtrl;
-   kbStringList::iterator FindInList(const wxString &module) const;
 
    DECLARE_EVENT_TABLE()
@@ -67,14 +81,14 @@
 END_EVENT_TABLE()
 
+// ============================================================================
+// implementation
+// ============================================================================
 
 wxModulesDialog::wxModulesDialog(wxWindow *parent)
-   : wxManuallyLaidOutDialog( parent,
-                              _("Extension Modules Configuration"),
+               : wxManuallyLaidOutDialog(parent,
+                                         _("Loadable Modules Configuration"),
                               _T("ModulesDialog"))
 {
-   // we only show the modules which can be loaded at starup and not, for
-   // example, different importers as it doesn't make sense to select them in
-   // this dialog
-   m_Listing = MModule::ListLoadableModules();
+   m_Listing = MModule::ListAvailableModules();
 
    // create controls
@@ -84,10 +98,11 @@
 
    // create a short help message above
-   wxStaticText *msg = new wxStaticText
+   wxStaticText *
+      msg = new wxStaticText
                            (
                             this,
                             -1,
-                            _("The selected modules will be loaded\n"
-                              "into Mahogany at the next program start.")
+                  _("The modules checked in the list below will be used by\n"
+                  "Mahogany as needed, uncheck a module to never load it.")
                            );
 
@@ -155,24 +170,27 @@
 bool wxModulesDialog::TransferDataToWindow()
 {
-   // get list of configured modules
-   wxString modules = READ_APPCONFIG(MP_MODULES);
-   wxChar *tmp = strutil_strdup(modules);
-   strutil_tokenise(tmp, _T(":"), m_Modules);
+   if ( !m_Listing )
+      return FALSE;
 
-   size_t count = m_Listing ? m_Listing->Count() : 0;
+   // get list of modules which shouldn't be loaded
+   wxString modulesStr = READ_APPCONFIG(MP_MODULES_DONT_LOAD);
+   wxArrayString modules = strutil_restore_array(modulesStr);
 
    // add the items to the checklistbox
+   const size_t count = m_Listing->Count();
    for ( size_t n = 0; n < count; n++ )
    {
-      m_checklistBox->Append((*m_Listing)[n].GetShortDescription());
-      if( FindInList((*m_Listing)[n].GetName()) != m_Modules.end() )
-         m_checklistBox->Check(n, TRUE);
+      const MModuleListingEntry& entry = (*m_Listing)[n];
+
+      const wxString
+            name(entry.GetName()),
+            desc(entry.GetShortDescription());
+
+      m_checklistBox->Append(desc.empty() ? name : desc);
+      m_checklistBox->Check(n, modules.Index(name) == wxNOT_FOUND);
    }
 
-   if(count)
       InternalUpdate(0);
 
-   delete [] tmp;
-
    return TRUE;
 }
@@ -180,34 +198,24 @@
 bool wxModulesDialog::TransferDataFromWindow()
 {
-   wxString setting;
-#if wxCHECK_VERSION(2, 3, 2)
-   size_t count = (size_t)m_checklistBox->GetCount();
-#else
-   size_t count = (size_t)m_checklistBox->Number();
-#endif
+   wxArrayString modules;
+   const size_t count = (size_t)m_checklistBox->GetCount();
    for ( size_t n = 0; n < count; n++ )
    {
-      if(m_checklistBox->IsChecked(n))
+      if ( !m_checklistBox->IsChecked(n) )
       {
-         setting << (*m_Listing)[n].GetName();
-         if(n != count-1) setting << ':';
+         modules.Add((*m_Listing)[n].GetName());
       }
    }
-   mApplication->GetProfile()->writeEntry(MP_MODULES, setting);
-   return TRUE;
-}
 
-kbStringList::iterator
-wxModulesDialog::FindInList(const wxString &module) const
-{
-   kbStringList::iterator i;
-   for(i = m_Modules.begin(); i != m_Modules.end(); i++)
-      if( (**i) == module)
-         return i;
-   return m_Modules.end();
+   mApplication->GetProfile()->
+      writeEntry(MP_MODULES_DONT_LOAD, strutil_flatten_array(modules));
+
+   return TRUE;
 }
 
+// ----------------------------------------------------------------------------
+// our public API
+// ----------------------------------------------------------------------------
 
-/// creates and shows the dialog allowing to choose modules
 extern
 void ShowModulesDialog(wxFrame *parent)
@@ -217,5 +225,5 @@
    {
       MDialog_Message(
-         _("Notice: any changes to the modules settings will only\n"
+         _("Notice: most changes to the modules settings will only\n"
            "take effect the next time you start Mahogany."),
          parent,



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to