Update of /cvsroot/mahogany/M/src/classes
In directory sc8-pr-cvs1:/tmp/cvs-serv31916/src/classes
Modified Files:
ComposeTemplate.cpp MApplication.cpp MModule.cpp
MessageView.cpp Moptions.cpp XFace.cpp
Log Message:
changed "make install" under Unix to be more consistent with FSSTD and common sense:
1. binary is now installed in $prefix/bin
2. $prefix/share/mahogany (and not Mahogany) contains only arch-independent files
3. modules are now in $prefix/lib/mahogany/modules
4. code has been updated accordingly and tweaked to ensure that everything
works both after and before the installation
5. some preliminary/untested code for Mac OS X bundle directory detection added
Index: ComposeTemplate.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/ComposeTemplate.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -b -u -2 -r1.61 -r1.62
--- ComposeTemplate.cpp 27 Dec 2003 22:57:51 -0000 1.61
+++ ComposeTemplate.cpp 12 Jan 2004 17:48:29 -0000 1.62
@@ -949,5 +949,5 @@
String path = READ_CONFIG(profile, MP_COMPOSETEMPLATEPATH_GLOBAL);
if ( path.empty() )
- path = mApplication->GetGlobalDir();
+ path = mApplication->GetDataDir();
if ( !path.empty() || path.Last() != '/' )
{
Index: MApplication.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MApplication.cpp,v
retrieving revision 1.285
retrieving revision 1.286
diff -b -u -2 -r1.285 -r1.286
--- MApplication.cpp 4 Jan 2004 02:17:10 -0000 1.285
+++ MApplication.cpp 12 Jan 2004 17:48:29 -0000 1.286
@@ -64,4 +64,8 @@
#include "wx/persctrl.h" // for wxPControls::SetSettingsPath
+#ifdef OS_MAC
+ #include <CoreServices/CoreServices.h>
+#endif // OS_MAC
+
#ifdef OS_WIN
#include <shlobj.h>
@@ -103,7 +107,4 @@
#ifdef OS_UNIX
-extern const MOption MP_ETCPATH;
-extern const MOption MP_PREFIXPATH;
-extern const MOption MP_ROOTDIRNAME;
extern const MOption MP_USE_SENDMAIL;
#endif // OS_UNIX
@@ -127,4 +128,10 @@
// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+static const wxChar *MAHOGANY_DATADIR = _T("share/mahogany");
+
+// ----------------------------------------------------------------------------
// functions
// ----------------------------------------------------------------------------
@@ -973,20 +980,39 @@
if ( m_globalDir.empty() || !PathFinder::IsDir(m_globalDir) )
{
- // under Unix we try to find our directory in some standard locations
-#ifdef OS_UNIX
- bool found;
- if ( PathFinder::IsDir(M_BASEDIR) )
+ // [try to] find the global directory
+
+#if defined(OS_MAC)
+ // use the bundle directory under Mac OS X
+ CFBundleRef bundle = CFBundleGetMainBundle();
+ if ( bundle )
{
- m_globalDir = M_BASEDIR;
+ CFURLRef url = CFBundleCopyBundleURL(bundle);
+ if ( url )
+ {
+ CFStringRef path = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
+ if ( path )
+ {
+ // hmm, do we need to use CFStringGetCString() here instead?
+ m_globalDir = CFStringGetCStringPtr(path, CFStringGetSystemEncoding);
- found = true;
+ CFRelease(path);
+ }
+
+ CFRelease(url);
}
- else
- {
- PathFinder pf(GetStringDefault(MP_PREFIXPATH));
- pf.AddPaths(M_PREFIX,false,true);
- m_globalDir = pf.FindDir(GetStringDefault(MP_ROOTDIRNAME), &found);
}
+#elif defined(OS_UNIX)
+ // under Unix we try to find our directory first in compiled-in location
+ // and then in some standard ones
+
+ static const wxChar *
+ stdPrefixes = _T("/usr:/usr/local:/opt:/usr/local/opt:/tmp");
+ PathFinder pf(stdPrefixes);
+ pf.AddPaths(M_PREFIX,false,true /* prepend */);
+
+ bool found;
+ m_globalDir = pf.FindDir(MAHOGANY_DATADIR, &found);
+ // if failed, give up and ask the user
if ( !found )
{
@@ -995,11 +1021,6 @@
"\"%s\"\n"
"Would you like to specify its location now?"),
- GetStringDefault(MP_ROOTDIRNAME),
- GetStringDefault(MP_ETCPATH));
-#else
- String msg = _("Cannot find global program directory.\n"
- "\n"
- "Would you like to specify its location now?");
-#endif // OS_UNIX
+ MAHOGANY_DATADIR,
+ stdPrefixes);
if ( MDialog_YesNoDialog(msg, NULL, MDIALOG_YESNOTITLE,
M_DLG_YES_DEFAULT,
@@ -1012,15 +1033,29 @@
}
}
-#ifdef OS_WIN
- else // under Windows, use the same directory as the local one
- {
- m_globalDir = m_localDir;
}
-#endif // OS_WIN
-#ifdef OS_UNIX
+ else // found in a std location
+ {
+ // we want just the DESTDIR, not DESTDIR/share/mahogany, so
+ // truncate (-1 for slash)
+ m_globalDir.resize(m_globalDir.length() - strlen(MAHOGANY_DATADIR) - 1);
+ }
+#elif defined(OS_WIN)
+ // use the program installation directory under Windows
+ wxString path;
+ if ( ::GetModuleFileName(NULL, wxStringBuffer(path, MAX_PATH), MAX_PATH) )
+ {
+ // get just the directory
+ wxSplitPath(path, &m_globalDir, NULL, NULL);
}
-#endif // OS_UNIX
+#else
+ #error "Don't know how to find program directory on this platform!"
+#endif // OS_MAC/OS_UNIX/OS_WIN
- if ( !m_globalDir.empty() )
+ if ( m_globalDir.empty() )
+ {
+ // use the user directory by default -- what else can we do?
+ m_globalDir = m_localDir;
+ }
+ else // got valid global directory, save it for subequent runs
{
m_profile->writeEntry(MP_GLOBALDIR, m_globalDir);
@@ -1345,16 +1380,11 @@
{
String dir = GetGlobalDir();
- if ( dir.empty() )
- {
- // M_TOP_SOURCEDIR is defined by configure
-#ifdef M_TOP_SOURCEDIR
- dir = M_TOP_SOURCEDIR;
-#endif
- if ( !dir.empty() )
- dir += '/';
-
- dir += _T("src");
- }
+#ifdef OS_UNIX
+ // if we used local directory as fall back for the global one because we
+ // couldn't find the latter, there is no sense to append "share/..." to it
+ if ( dir != GetLocalDir() )
+ dir << _T('/') << MAHOGANY_DATADIR;
+#endif // OS_UNIX
return dir;
@@ -1371,8 +1401,8 @@
// attempt to load the extra information supplied with M:
- if(wxFileExists(GetGlobalDir()+_T("/mailcap")))
- m_mimeManager->ReadMailcap(GetGlobalDir()+_T("/mailcap"));
- if(wxFileExists(GetGlobalDir()+_T("/mime.types")))
- m_mimeManager->ReadMimeTypes(GetGlobalDir()+_T("/mime.types"));
+ if(wxFileExists(GetDataDir()+_T("/mailcap")))
+ m_mimeManager->ReadMailcap(GetDataDir()+_T("/mailcap"));
+ if(wxFileExists(GetDataDir()+_T("/mime.types")))
+ m_mimeManager->ReadMimeTypes(GetDataDir()+_T("/mime.types"));
#endif // 0
Index: MModule.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MModule.cpp,v
retrieving revision 1.86
retrieving revision 1.87
diff -b -u -2 -r1.86 -r1.87
--- MModule.cpp 11 Oct 2003 17:02:37 -0000 1.86
+++ MModule.cpp 12 Jan 2004 17:48:29 -0000 1.87
@@ -834,57 +834,76 @@
wxArrayString dirs;
- // make it possible to use modules without installing them
+ // 1. look in user directory
+
+ const String localDir = mApplication->GetLocalDir();
+
+ String pathUser;
+
+#ifdef OS_UNIX
+ // look first under extra M_CANONICAL_HOST directory under Unix, this
+ // allows to have arch-dependent modules which is handy when your home
+ // directory is shared between multiple machines (via NFS for example)
+
+ pathUser << localDir
+ << DIR_SEPARATOR << M_CANONICAL_HOST
+ << DIR_SEPARATOR << _T("modules") << DIR_SEPARATOR;
+
+ dirs.Add(pathUser);
+
+ pathUser.clear();
+#endif // Unix
+
+ pathUser << localDir << DIR_SEPARATOR << _T("modules") << DIR_SEPARATOR;
+
+ dirs.Add(pathUser);
+
+ // 2. look in global directory
+
+ // look in $prefix/lib/mahogany modules but just in modules under the
+ // program/bundle directory elsewhere (not that it mattered anyhow as
+ // dynamic modules are not supported neither under Windows nor under Mac
+ // right now...)
+ const String globalDir = mApplication->GetGlobalDir();
+ if ( globalDir != localDir )
+ {
+ String pathSystem;
+ pathSystem << globalDir << DIR_SEPARATOR
+#ifdef OS_UNIX
+ << _T("lib/mahogany/")
+#endif // Unix
+ << _T("modules") << DIR_SEPARATOR;
+
+ dirs.Add(pathSystem);
+ }
+
+ // 3. finally, also make it possible to use modules without installing them
+ // so look in the source tree
#ifdef M_TOP_BUILDDIR
- wxString path0;
- path0 << M_TOP_BUILDDIR
+ wxString pathSrcTree;
+ pathSrcTree << M_TOP_BUILDDIR
<< DIR_SEPARATOR << _T("src")
<< DIR_SEPARATOR << _T("modules") << DIR_SEPARATOR;
- dirs.Add(path0);
+ dirs.Add(pathSrcTree);
- path0.clear();
- path0 << M_TOP_BUILDDIR
+ pathSrcTree.clear();
+ pathSrcTree << M_TOP_BUILDDIR
<< DIR_SEPARATOR << _T("src")
<< DIR_SEPARATOR << _T("adb") << DIR_SEPARATOR;
- dirs.Add(path0);
+ dirs.Add(pathSrcTree);
- path0.clear();
- path0 << M_TOP_BUILDDIR
+ pathSrcTree.clear();
+ pathSrcTree << M_TOP_BUILDDIR
<< DIR_SEPARATOR << _T("src")
<< DIR_SEPARATOR << _T("modules")
<< DIR_SEPARATOR << _T("crypt") << DIR_SEPARATOR;
- dirs.Add(path0);
+ dirs.Add(pathSrcTree);
- path0.clear();
- path0 << M_TOP_BUILDDIR
+ pathSrcTree.clear();
+ pathSrcTree << M_TOP_BUILDDIR
<< DIR_SEPARATOR << _T("src")
<< DIR_SEPARATOR << _T("modules")
<< DIR_SEPARATOR << _T("viewflt") << DIR_SEPARATOR;
- dirs.Add(path0);
+ dirs.Add(pathSrcTree);
#endif // Unix
-
- // look under extra M_CANONICAL_HOST directory under Unix, but not for other
- // platforms (doesn't make much sense under Windows)
-
- wxString path1;
- path1 << mApplication->GetGlobalDir()
-#ifdef OS_UNIX
- << DIR_SEPARATOR << M_CANONICAL_HOST
-#endif // Unix
- << DIR_SEPARATOR << _T("modules") << DIR_SEPARATOR;
-
- dirs.Add(path1);
-
- wxString path2;
- path2 << mApplication->GetLocalDir()
-#ifdef OS_UNIX
- << DIR_SEPARATOR << M_CANONICAL_HOST
-#endif // Unix
- << DIR_SEPARATOR << _T("modules") << DIR_SEPARATOR;
-
- // under Windows, the global and local dirs might be the same
- if ( path2 != path1 )
- {
- dirs.Add(path2);
- }
return dirs;
Index: MessageView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MessageView.cpp,v
retrieving revision 1.145
retrieving revision 1.146
diff -b -u -2 -r1.145 -r1.146
--- MessageView.cpp 20 Dec 2003 14:36:48 -0000 1.145
+++ MessageView.cpp 12 Jan 2004 17:48:29 -0000 1.146
@@ -587,4 +587,8 @@
m_usingDefViewer = true;
+
+ // make sure that the viewer name is empty if we're using the dummy one:
+ // this is how we can determine whether we have a real viewer or not
+ m_ProfileValues.msgViewer.clear();
}
else // we have a real viewer now
@@ -610,8 +614,13 @@
MModule::ListAvailableModules(MESSAGE_VIEWER_INTERFACE);
- if ( !listing )
+ if ( !listing || !listing->Count() )
{
wxLogError(_("No message viewer plugins found. It will be "
- "impossible to view any messages."));
+ "impossible to view any messages.\n"
+ "\n"
+ "Please check that Mahogany plugins are available."));
+
+ if ( listing )
+ listing->DecRef();
}
else // have at least one viewer, load it
Index: Moptions.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/Moptions.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -b -u -2 -r1.72 -r1.73
--- Moptions.cpp 4 Jan 2004 02:17:49 -0000 1.72
+++ Moptions.cpp 12 Jan 2004 17:48:29 -0000 1.73
@@ -130,9 +130,5 @@
#ifdef OS_UNIX
-const MOption MP_PATHLIST;
-const MOption MP_ROOTDIRNAME;
const MOption MP_AFMPATH;
-const MOption MP_ETCPATH;
-const MOption MP_PREFIXPATH;
#endif // OS_UNIX
@@ -543,9 +539,5 @@
#ifdef OS_UNIX
- DEFINE_OPTION(MP_PATHLIST),
- DEFINE_OPTION(MP_ROOTDIRNAME),
DEFINE_OPTION(MP_AFMPATH),
- DEFINE_OPTION(MP_ETCPATH),
- DEFINE_OPTION(MP_PREFIXPATH),
#endif // OS_UNIX
Index: XFace.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/XFace.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -b -u -2 -r1.31 -r1.32
--- XFace.cpp 12 Oct 2003 01:41:21 -0000 1.31
+++ XFace.cpp 12 Jan 2004 17:48:29 -0000 1.32
@@ -210,5 +210,5 @@
PathFinder pf(READ_APPCONFIG(MP_ICONPATH), true);
pf.AddPaths(mApplication->GetLocalDir() + DIR_SEPARATOR + _T("icons"), true);
- pf.AddPaths(mApplication->GetGlobalDir() + DIR_SEPARATOR + _T("icons"), true);
+ pf.AddPaths(mApplication->GetDataDir() + DIR_SEPARATOR + _T("icons"), true);
String name = pf.FindFile(_T("xface.xpm"), &success);
if(success)
-------------------------------------------------------
This SF.net email is sponsored by: Perforce Software.
Perforce is the Fast Software Configuration Management System offering
advanced branching capabilities and atomic changes on 50+ platforms.
Free Eval! http://www.perforce.com/perforce/loadprog.html
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates