зеркало из https://github.com/mozilla/pjs.git
Part of Messenger Mac landing
This commit is contained in:
Родитель
a0ce53652e
Коммит
55d7f55ccf
|
@ -34,12 +34,13 @@
|
|||
#ifdef MORK_OBSOLETE
|
||||
|
||||
#include <Types.h>
|
||||
#include "plstr.h"
|
||||
|
||||
static void // copied almost verbatim from the IronDoc debugger sources:
|
||||
mork_mac_break_string(register const char* inMessage) /*i*/
|
||||
{
|
||||
Str255 pascalStr; // to hold Pascal string version of inMessage
|
||||
mork_u4 length = XP_STRLEN(inMessage);
|
||||
mork_u4 length = PL_strlen(inMessage);
|
||||
|
||||
// if longer than maximum 255 bytes, just copy 255 bytes worth
|
||||
pascalStr[ 0 ] = (length > 255)? 255 : length;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
// { %%%%% begin platform defs peculiar to Mork %%%%%
|
||||
#ifdef XP_MAC
|
||||
#define MORK_OBSOLETE 1
|
||||
#define MORK_MAC 1
|
||||
#endif
|
||||
|
||||
|
@ -74,7 +73,6 @@
|
|||
#ifdef MORK_OBSOLETE
|
||||
#include "xp_file.h"
|
||||
#include "ctype.h"
|
||||
|
||||
#define MORK_ISPRINT(c) isprint(c)
|
||||
|
||||
#define MORK_FILETELL(file) XP_FileTell(file)
|
||||
|
|
|
@ -34,12 +34,13 @@
|
|||
#ifdef MORK_OBSOLETE
|
||||
|
||||
#include <Types.h>
|
||||
#include "plstr.h"
|
||||
|
||||
static void // copied almost verbatim from the IronDoc debugger sources:
|
||||
mork_mac_break_string(register const char* inMessage) /*i*/
|
||||
{
|
||||
Str255 pascalStr; // to hold Pascal string version of inMessage
|
||||
mork_u4 length = XP_STRLEN(inMessage);
|
||||
mork_u4 length = PL_strlen(inMessage);
|
||||
|
||||
// if longer than maximum 255 bytes, just copy 255 bytes worth
|
||||
pascalStr[ 0 ] = (length > 255)? 255 : length;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
// { %%%%% begin platform defs peculiar to Mork %%%%%
|
||||
#ifdef XP_MAC
|
||||
#define MORK_OBSOLETE 1
|
||||
#define MORK_MAC 1
|
||||
#endif
|
||||
|
||||
|
@ -74,7 +73,6 @@
|
|||
#ifdef MORK_OBSOLETE
|
||||
#include "xp_file.h"
|
||||
#include "ctype.h"
|
||||
|
||||
#define MORK_ISPRINT(c) isprint(c)
|
||||
|
||||
#define MORK_FILETELL(file) XP_FileTell(file)
|
||||
|
|
|
@ -236,9 +236,12 @@ protected:
|
|||
static int FindInCache(nsMsgDatabase* pMessageDB);
|
||||
PRBool MatchDbName(nsFileSpec &dbName); // returns TRUE if they match
|
||||
|
||||
#ifdef XP_PC // this should go away when we can provide our own file stream to MDB/Mork
|
||||
#if defined(XP_PC) || defined(XP_MAC) // this should go away when we can provide our own file stream to MDB/Mork
|
||||
static void UnixToNative(char*& ioPath);
|
||||
#endif
|
||||
#if defined(XP_MAC)
|
||||
static void NativeToUnix(char*& ioPath);
|
||||
#endif
|
||||
|
||||
// Flag handling routines
|
||||
virtual nsresult SetKeyFlag(nsMsgKey key, PRBool set, PRInt32 flag,
|
||||
|
|
|
@ -74,7 +74,7 @@ nsMailDatabase::~nsMailDatabase()
|
|||
|
||||
char *nativeFolderName = nsCRT::strdup((const char *) folderName);
|
||||
|
||||
#ifdef XP_PC
|
||||
#if defined(XP_PC) || defined(XP_MAC)
|
||||
UnixToNative(nativeFolderName);
|
||||
#endif
|
||||
stat (nativeFolderName, &st);
|
||||
|
@ -221,6 +221,7 @@ void nsMailDatabase::UpdateFolderFlag(nsIMessage *mailHdr, PRBool bSet,
|
|||
nsIOFileStream *fileStream = (m_folderStream) ? m_folderStream : *ppFileStream;
|
||||
//#ifdef GET_FILE_STUFF_TOGETHER
|
||||
#ifdef XP_MAC
|
||||
/* ducarroz: Do we still need this ??
|
||||
// This is a horrible hack and we should make sure we don't need it anymore.
|
||||
// It has to do with multiple people having the same file open, I believe, but the
|
||||
// mac file system only has one handle, and they compete for the file position.
|
||||
|
@ -231,6 +232,7 @@ void nsMailDatabase::UpdateFolderFlag(nsIMessage *mailHdr, PRBool bSet,
|
|||
fid = gIncorporateFID;
|
||||
savedPosition = ftell(gIncorporateFID); // so we can restore it.
|
||||
}
|
||||
*/
|
||||
#endif // XP_MAC
|
||||
PRUint32 offset;
|
||||
(void)mailHdr->GetStatusOffset(&offset);
|
||||
|
@ -313,9 +315,11 @@ void nsMailDatabase::UpdateFolderFlag(nsIMessage *mailHdr, PRBool bSet,
|
|||
SetReparse(TRUE);
|
||||
}
|
||||
#ifdef XP_MAC
|
||||
/* ducarroz: Do we still need this ??
|
||||
// Restore the file position
|
||||
if (savedPosition >= 0)
|
||||
XP_FileSeek(fid, savedPosition, SEEK_SET);
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
@ -327,7 +331,7 @@ void nsMailDatabase::UpdateFolderFlag(nsIMessage *mailHdr, PRBool bSet,
|
|||
}
|
||||
//#endif // GET_FILE_STUFF_TOGETHER
|
||||
#ifdef XP_MAC
|
||||
if (!m_folderStream && fid != gIncorporateFID)
|
||||
if (!m_folderStream /*&& fid != gIncorporateFID*/) /* ducarroz: Do we still need this ?? */
|
||||
#else
|
||||
if (!m_folderStream)
|
||||
#endif
|
||||
|
@ -339,7 +343,7 @@ void nsMailDatabase::UpdateFolderFlag(nsIMessage *mailHdr, PRBool bSet,
|
|||
nsresult ret = NS_OK;
|
||||
struct stat st;
|
||||
char *nativeFileName = nsCRT::strdup(m_folderName);
|
||||
#ifdef XP_PC
|
||||
#if defined(XP_PC) || defined(XP_MAC)
|
||||
UnixToNative(nativeFileName);
|
||||
#endif
|
||||
|
||||
|
@ -435,7 +439,7 @@ nsresult nsMailDatabase::SetFolderInfoValid(nsFileSpec &folderName, int num, int
|
|||
nsresult err;
|
||||
|
||||
char *nativeFileName = nsCRT::strdup(folderName);
|
||||
#ifdef XP_PC
|
||||
#if defined(XP_PC) || defined(XP_MAC)
|
||||
UnixToNative(nativeFileName);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -36,7 +36,12 @@
|
|||
#include "nsILocale.h"
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsILocaleFactory.h"
|
||||
|
||||
#if defined(XP_MAC) && defined(CompareString)
|
||||
#undef CompareString
|
||||
#endif
|
||||
#include "nsICollation.h"
|
||||
|
||||
#include "nsCollationCID.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
|
@ -436,8 +441,71 @@ void nsMsgDatabase::UnixToNative(char*& ioPath)
|
|||
*cp = *(cp + 1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* XP_PC */
|
||||
|
||||
#ifdef XP_MAC
|
||||
// this code is stolen from nsFileSpecMac. Since MDB requires a native path, for
|
||||
// the time being, we'll just take the Unix/Canonical form and munge it
|
||||
void nsMsgDatabase::UnixToNative(char*& ioPath)
|
||||
// This just does string manipulation. It doesn't check reality, or canonify, or
|
||||
// anything
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
// Relying on the fact that the unix path is always longer than the mac path:
|
||||
size_t len = strlen(ioPath);
|
||||
char* result = new char[len + 2]; // ... but allow for the initial colon in a partial name
|
||||
if (result)
|
||||
{
|
||||
char* dst = result;
|
||||
const char* src = ioPath;
|
||||
if (*src == '/') // * full path
|
||||
src++;
|
||||
else if (strchr(src, '/')) // * partial path, and not just a leaf name
|
||||
*dst++ = ':';
|
||||
strcpy(dst, src);
|
||||
|
||||
while ( *dst != 0)
|
||||
{
|
||||
if (*dst == '/')
|
||||
*dst++ = ':';
|
||||
else
|
||||
*dst++;
|
||||
}
|
||||
PR_Free(ioPath);
|
||||
ioPath = result;
|
||||
}
|
||||
}
|
||||
|
||||
void nsMsgDatabase::NativeToUnix(char*& ioPath)
|
||||
// This just does string manipulation. It doesn't check reality, or canonify, or
|
||||
// anything
|
||||
//----------------------------------------------------------------------------------------
|
||||
{
|
||||
size_t len = strlen(ioPath);
|
||||
char* result = new char[len + 2]; // ... but allow for the initial colon in a partial name
|
||||
if (result)
|
||||
{
|
||||
char* dst = result;
|
||||
const char* src = ioPath;
|
||||
if (*src == ':') // * partial path, and not just a leaf name
|
||||
src++;
|
||||
else if (strchr(src, ':')) // * full path
|
||||
*dst++ = '/';
|
||||
strcpy(dst, src);
|
||||
|
||||
while ( *dst != 0)
|
||||
{
|
||||
if (*dst == ':')
|
||||
*dst++ = '/';
|
||||
else
|
||||
*dst++;
|
||||
}
|
||||
PR_Free(ioPath);
|
||||
ioPath = result;
|
||||
}
|
||||
}
|
||||
#endif /* XP_MAC */
|
||||
|
||||
// Open the MDB database synchronously. If successful, this routine
|
||||
// will set up the m_mdbStore and m_mdbEnv of the database object
|
||||
// so other database calls can work.
|
||||
|
@ -454,8 +522,15 @@ NS_IMETHODIMP nsMsgDatabase::OpenMDB(const char *dbName, PRBool create)
|
|||
struct stat st;
|
||||
char *nativeFileName = nsCRT::strdup(dbName);
|
||||
|
||||
#if defined(XP_MAC)
|
||||
char * unixPath = nsCRT::strdup(dbName);
|
||||
NativeToUnix(unixPath);
|
||||
m_dbName = nsCRT::strdup(unixPath);
|
||||
delete [] unixPath;
|
||||
#else
|
||||
m_dbName = nsCRT::strdup(dbName);
|
||||
#ifdef XP_PC
|
||||
#endif
|
||||
#if defined(XP_PC) || defined(XP_MAC)
|
||||
UnixToNative(nativeFileName);
|
||||
#endif
|
||||
if (stat(nativeFileName, &st))
|
||||
|
|
Загрузка…
Ссылка в новой задаче