|
From: <set...@us...> - 2006-04-25 03:00:25
|
Revision: 1335 Author: sethdill Date: 2006-04-24 20:00:10 -0700 (Mon, 24 Apr 2006) ViewCVS: http://svn.sourceforge.net/frontierkernel/?rev=1335&view=rev Log Message: ----------- Merged trunk changes r1324:1332 into the Conversant branch. Modified Paths: -------------- Frontier/branches/Conversant/Common/SystemHeaders/standard.h Frontier/branches/Conversant/Common/headers/file.h Frontier/branches/Conversant/Common/headers/frontierdefs.h Frontier/branches/Conversant/Common/headers/osincludes.h Frontier/branches/Conversant/Common/headers/processinternal.h Frontier/branches/Conversant/Common/headers/strings.h Frontier/branches/Conversant/Common/resources/Mac/kernelverbs.r Frontier/branches/Conversant/Common/resources/Win32/kernelverbs.rc Frontier/branches/Conversant/Common/source/FrontierWinMain.c Frontier/branches/Conversant/Common/source/fileops.c Frontier/branches/Conversant/Common/source/fileverbs.c Frontier/branches/Conversant/Common/source/lang.c Frontier/branches/Conversant/Common/source/langstartup.c Frontier/branches/Conversant/Common/source/process.c Frontier/branches/Conversant/Common/source/shell.c Frontier/branches/Conversant/Common/source/strings.c Frontier/branches/Conversant/Common/source/stringverbs.c Modified: Frontier/branches/Conversant/Common/SystemHeaders/standard.h =================================================================== --- Frontier/branches/Conversant/Common/SystemHeaders/standard.h 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/SystemHeaders/standard.h 2006-04-25 03:00:10 UTC (rev 1335) @@ -437,6 +437,10 @@ #define quickdrawglobal(x) qd.x +extern boolean flcominitialized; /* set up in lang.c */ +extern boolean initCOM( void ); /* see FrontierWinMain.c */ +extern void shutdownCOM( void ); + #endif #endif Modified: Frontier/branches/Conversant/Common/headers/file.h =================================================================== --- Frontier/branches/Conversant/Common/headers/file.h 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/headers/file.h 2006-04-25 03:00:10 UTC (rev 1335) @@ -424,7 +424,7 @@ extern boolean fifgetendoffile (const tyfilespec *fs, long *eof); - /* filepath.c */ +#pragma mark === filepath.c === extern boolean directorytopath (long, short, bigstring); @@ -449,7 +449,7 @@ extern void initfsdefault (void); /* 2005-07-18 creedon */ - /*fileverbs.c*/ +#pragma mark === fileverbs.c === //extern filecheckdefaultpath (bigstring); @@ -458,7 +458,7 @@ extern boolean filestart (void); /*6.1b15 AR*/ -// filedialog.c +#pragma mark === filedialog.c === extern boolean sfdialog (tysfverb, bigstring, ptrsftypelist, tyfilespec *, OSType); /* 2005-10-06 creedon - added OSType */ @@ -482,9 +482,14 @@ #endif -// filemp3.c +#pragma mark === filemp3.c === boolean getmp3info (const tyfilespec *, long *, long *, long *, long *, boolean *); +#pragma mark === fileops.c === +extern short getfilelabelindex (const tyfilespec *, short *); /* 2006-04-23 creedon */ + +extern boolean setfilelabelindex (const tyfilespec *, short, boolean); /* 2006-04-23 creedon */ + Modified: Frontier/branches/Conversant/Common/headers/frontierdefs.h =================================================================== --- Frontier/branches/Conversant/Common/headers/frontierdefs.h 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/headers/frontierdefs.h 2006-04-25 03:00:10 UTC (rev 1335) @@ -35,11 +35,13 @@ #ifdef WIN95VERSION #define FRONTIERCOM 1 -#ifndef OPMLEDITOR - #define FRONTIERWEB 0 -#else //OPMLEDITOR - #define FRONTIERWEB 1 /* 2006-02-05 aradke: enable HTML display in main window background */ -#endif // OPMLEDITOR + + #ifndef OPMLEDITOR + #define FRONTIERWEB 0 + #else //OPMLEDITOR + #define FRONTIERWEB 1 /* 2006-02-05 aradke: enable HTML display in main window background */ + #endif // OPMLEDITOR + #undef winhybrid #define fljustpacking 0 #undef flcomponent Modified: Frontier/branches/Conversant/Common/headers/osincludes.h =================================================================== --- Frontier/branches/Conversant/Common/headers/osincludes.h 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/headers/osincludes.h 2006-04-25 03:00:10 UTC (rev 1335) @@ -37,6 +37,8 @@ #ifdef WIN95VERSION #define WIN32_LEAN_AND_MEAN 1 + #define _WIN32_DCOM 1 + #define CINTERFACE 1 #include <windows.h> @@ -55,6 +57,10 @@ #include <winsock2.h> #include <mswsock.h> + #undef __cplusplus + #include <objbase.h> + #include <mlang.h> + #endif /* WIN95VERSION */ Modified: Frontier/branches/Conversant/Common/headers/processinternal.h =================================================================== --- Frontier/branches/Conversant/Common/headers/processinternal.h 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/headers/processinternal.h 2006-04-25 03:00:10 UTC (rev 1335) @@ -195,6 +195,9 @@ ThreadEntryUPP threadEntryCallbackUPP; #endif + + boolean flcominitialized; + } tythreadglobals, *ptrthreadglobals, **hdlthreadglobals; Modified: Frontier/branches/Conversant/Common/headers/strings.h =================================================================== --- Frontier/branches/Conversant/Common/headers/strings.h 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/headers/strings.h 2006-04-25 03:00:10 UTC (rev 1335) @@ -161,6 +161,7 @@ extern void copyctopstring (const char *, bigstring); #ifdef WIN95VERSION +extern boolean copyWideToPString (const wchar_t *, bigstring); extern void copyrezstring (const bigstring, bigstring); #endif @@ -266,9 +267,9 @@ extern boolean utf8tomacroman (Handle, Handle); /* 2006-02-25 creedon */ -extern boolean gettextencodingid (const Handle, long *); /* 2006-04-20 smd */ +extern boolean convertCharset( Handle, Handle, bigstring, bigstring ); -extern boolean converttextencoding (Handle, Handle, long, long); /* 2006-04-14 smd */ +extern boolean isTextEncodingAvailable( bigstring ); /* 2006-04-23 smd */ #endif Modified: Frontier/branches/Conversant/Common/resources/Mac/kernelverbs.r =================================================================== --- Frontier/branches/Conversant/Common/resources/Mac/kernelverbs.r 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/resources/Mac/kernelverbs.r 2006-04-25 03:00:10 UTC (rev 1335) @@ -601,7 +601,8 @@ "multipleReplaceAll", "macromantoutf8", // 2006-02-25 creedon "utf8tomacroman", // 2006-02-25 creedon - "convertcharset" /* 2006-04-13 smd */ + "convertcharset", /* 2006-04-13 smd */ + "ischarsetavailable" /* 2006-04-23 smd */ } } }; @@ -693,7 +694,10 @@ "freespaceonvolumedouble", "volumesizedouble", "getmp3info", - "readwholefile" /* 2006-04-11 aradke */ + "readwholefile", /* 2006-04-11 aradke */ + "getLabelIndex", /* 2006-04-23 creedon */ + "setLabelIndex", /* 2006-04-23 creedon */ + "getLabelNames" /* 2006-04-23 creedon */ } } }; @@ -719,7 +723,6 @@ "deletenamedresource", "getresourceattributes", "setresourceattributes" - } } }; @@ -760,7 +763,7 @@ "about", "quicktime", /*7.0b4 PBS: QuickTime Player window*/ "getfile", - "isreadonly" /*7.0b6 PBS: is a window read-only*/ + "isreadonly", /*7.0b6 PBS: is a window read-only*/ } } }; @@ -1132,7 +1135,7 @@ "hmacMD5", "MD5", "SHA1", - "hmacSHA1" + "hmacSHA1", } } }; Modified: Frontier/branches/Conversant/Common/resources/Win32/kernelverbs.rc =================================================================== --- Frontier/branches/Conversant/Common/resources/Win32/kernelverbs.rc 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/resources/Win32/kernelverbs.rc 2006-04-25 03:00:10 UTC (rev 1335) @@ -514,7 +514,7 @@ 1, //Number of "blocks" in this resource "string\0", //Function Processor Name false, //Window required - 59, //Count of verbs + 60, //Count of verbs "delete\0", "insert\0", "popleading\0", @@ -573,7 +573,8 @@ "multiplereplaceall\0", "macromantoutf8\0", // 2006-02-25 creedon "utf8tomacroman\0", // 2006-02-25 creedon - "convertcharset\0" /* 2006-04-16 smd */ + "convertcharset\0", /* 2006-04-16 smd */ + "ischarsetavailable\0" /* 2006-04-24 smd */ END @@ -582,7 +583,7 @@ 1, //Number of "blocks" in this resource "file\0", //Function Processor Name false, //Window required - 82, //Count of verbs + 86, //Count of verbs "created\0", "modified\0", "type\0", @@ -663,8 +664,11 @@ "getpathchar\0", "freespaceonvolumedouble\0", "volumesizedouble\0", - "getmp3info\0", /*7.0b12 PBS: Andr\xE9's file.getMp3Info verb*/ - "readwholefile\0" /* 2006-04-11 aradke */ + "getmp3info\0", /*7.0b12 PBS: Andr\xE9's file.getMp3Info verb*/ + "readwholefile\0", /* 2006-04-11 aradke */ + "getLabelIndex\0", /* 2006-04-23 creedon */ + "setLabelIndex\0", /* 2006-04-23 creedon */ + "getLabelNames" /* 2006-04-23 creedon */ END 1008 /*idrezverbs*/ EFP DISCARDABLE @@ -691,12 +695,12 @@ END -1009 /*idwindowverbs*/ EFP DISCARDABLE +1009 /* idwindowverbs */ EFP DISCARDABLE BEGIN - 1, //Number of "blocks" in this resource - "window\0", //Function Processor Name - true, //Window required - 30, //Count of verbs + 1, // Number of "blocks" in this resource + "window\0", // Function Processor Name + true, // Window required + 30, // Count of verbs "isopen\0", "open\0", "isfront\0", @@ -726,7 +730,7 @@ "settitle\0", "about\0", "getfile\0", - "isreadonly\0" + "isreadonly\0", END @@ -1070,7 +1074,7 @@ "hmacMD5\0", "MD5\0", "SHA1\0", - "hmacSHA1\0" + "hmacSHA1\0", END #include "conversantverbs.rc" Modified: Frontier/branches/Conversant/Common/source/FrontierWinMain.c =================================================================== --- Frontier/branches/Conversant/Common/source/FrontierWinMain.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/FrontierWinMain.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -2974,8 +2974,38 @@ } /*COMSYSModule*/ +boolean initCOM () +{ + if ( !flcominitialized ) + { + LPVOID reserved = NULL; + HRESULT err; + + err = CoInitialize( reserved ); + + if ( SUCCEEDED( err ) ) + { + flcominitialized = true; + return (true); + } + else + return (false); + } + + return (true); +} + +void shutdownCOM () +{ + CoUninitialize(); + flcominitialized = false; +} + + Handle COMStartup () { + initCOM(); + gcomServerInfo.hCOMModule = LoadLibrary ("COMDLL.DLL"); if (gcomServerInfo.hCOMModule == NULL) @@ -2991,7 +3021,7 @@ if ((gcomServerInfo.cominit != NULL) && (gcomServerInfo.comclear != NULL)) { fillcalltable(&gcomServerInfo.calltable); - + (*(gcomServerInfo.cominit)) (gcomServerInfo.hInstance, gcomServerInfo.hPrevInstance, gcomServerInfo.lpCmdLine, gcomServerInfo.nCmdShow, &gcomServerInfo.calltable); } } @@ -3000,6 +3030,8 @@ } /*COMStartup*/ boolean COMShutdown () { + shutdownCOM(); + if ((gcomServerInfo.cominit != NULL) && (gcomServerInfo.comclear != NULL)) (*(gcomServerInfo.comclear)) (); @@ -3009,6 +3041,7 @@ gcomServerInfo.cominit = NULL; gcomServerInfo.comclear = NULL; gcomServerInfo.hCOMModule = NULL; + return (true); } /*COMShutdown*/ Modified: Frontier/branches/Conversant/Common/source/fileops.c =================================================================== --- Frontier/branches/Conversant/Common/source/fileops.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/fileops.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -2313,7 +2313,9 @@ #endif } /*lockvolume*/ + #ifdef MACVERSION + boolean unmountvolume (const tyfilespec *fs) { /* @@ -2461,42 +2463,41 @@ static boolean index2label (short ixlabel, bigstring bslabel) { /* - new: pascal OSErr GetLabel(short labelNumber, RGBColor *labelColor, Str255 labelString) - = {0x303c, 0x050B, 0xABC9}; + 2006-04-24 creedon: use GetLabel instead of looking for resources that don't exists on Mac OS X + deleted old code see revision 1268 */ - Handle hlabel; - - setemptystring (bslabel); - if ((ixlabel < 0) || (ixlabel > 7)) return (false); - hlabel = GetResource ('lstr', -16392 + ixlabel); + RGBColor labelcolor; // we don't use the value we put into here - if (hlabel == nil) - return (false); - - copyheapstring ((hdlstring) hlabel, bslabel); - + if (GetLabel (ixlabel, &labelcolor, bslabel) != noErr) + return (false); + return (true); - } /*index2label*/ + } /* index2label */ static boolean label2index (bigstring bslabel, short *ixlabel) { + /* + 2006-04-24 creedon: use GetLabel instead of looking for resources that don't exists on Mac OS X + deleted old code see revision 1268 + */ + register short ix; - Handle hlabel; + RGBColor labelcolor; // we don't use the value we put into here + bigstring bs; for (ix = 0; ix < 8; ++ix) { - hlabel = GetResource ('lstr', -16392 + ix); + if (GetLabel (ix, &labelcolor, bs) != noErr) - if (hlabel == nil) - continue; - - if (RelString ((ptrstring) *hlabel, bslabel, false, false) == 0) { + return (false); + if (RelString (bslabel, bs, false, false) == 0) { + *ixlabel = ix; return (true); @@ -2504,7 +2505,7 @@ } return (false); - } /*label2index*/ + } /* label2index */ boolean getfilelabel (const tyfilespec *fs, bigstring bslabel) { @@ -2520,26 +2521,18 @@ boolean setfilelabel (const tyfilespec *fs, bigstring bslabel) { - CInfoPBRec pb; - register short flags; + /* + 2006-04-24 creedon: factored most of the code into setfilelabelindex function + code deleted see revision 1268 + */ + short ixlabel; if (!label2index (bslabel, &ixlabel)) return (false); - if (!getmacfileinfo (fs, &pb)) - return (false); - - flags = pb.hFileInfo.ioFlFndrInfo.fdFlags; - - flags &= 0xFFF1; /*clear out old index*/ - - flags |= ixlabel << 1; /*slam in new index*/ - - pb.hFileInfo.ioFlFndrInfo.fdFlags = flags; - - return (setmacfileinfo (fs, &pb)); - } /*setfilelabel*/ + return (setfilelabelindex (fs, ixlabel, false)); + } /* setfilelabel */ boolean mountvolume (bigstring volumepath, bigstring username, bigstring password) { @@ -2627,6 +2620,58 @@ return (!oserror (errcode)); } /*mountvolume*/ + + +short getfilelabelindex (const tyfilespec *fs, short *ixlabel) { + + /* + 2006-04-23 creedon: created, cribbed from getfilelabel function + */ + + tyfileinfo info; + short maptouserinterfaceindex [8] = {0, 7, 4, 6, 5, 3, 1, 2}; + + if (!filegetinfo (fs, &info)) + return (false); + + *ixlabel = maptouserinterfaceindex [info.ixlabel]; + + return (true); + } /* getfilelabelindex */ + + +boolean setfilelabelindex (const tyfilespec *fs, short ixlabel, boolean flmapfromuserinterfaceindex) { + + /* + 2006-04-24 creedon: created, cribbed from setfilelabel function + */ + + CInfoPBRec pb; + register short flags; + + if ((ixlabel < 0) || (ixlabel > 7)) + return (false); + + if (!getmacfileinfo (fs, &pb)) + return (false); + + flags = pb.hFileInfo.ioFlFndrInfo.fdFlags; + + flags &= 0xFFF1; // clear out old index + + if (flmapfromuserinterfaceindex) { + short mapfromuserinterfaceindex [8] = {0, 6, 7, 5, 2, 4, 3, 1}; + + ixlabel = mapfromuserinterfaceindex [ixlabel]; + } + + flags |= ixlabel << 1; // slam in new index + + pb.hFileInfo.ioFlFndrInfo.fdFlags = flags; + + return (setmacfileinfo (fs, &pb)); + } /* setfilelabelindex */ + #endif Modified: Frontier/branches/Conversant/Common/source/fileverbs.c =================================================================== --- Frontier/branches/Conversant/Common/source/fileverbs.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/fileverbs.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -46,6 +46,7 @@ #include "kernelverbdefs.h" #include "shell.rsrc.h" #include "byteorder.h" /* 2006-04-16 aradke: for SWAP_REZ_BYTE_ORDER */ +#include "oplist.h" /* 2006-04-23 creedon */ #ifdef MACVERSION @@ -250,8 +251,14 @@ getmp3infofunc, - readwholefilefunc, /* 2006-04-11 aradke */ + readwholefilefunc, /* 2006-04-11 aradke */ + getlabelindexfunc, /* 2006-04-23 creedon */ + + setlabelindexfunc, /* 2006-04-23 creedon */ + + getlabelnamesfunc, /* 2006-04-23 creedon */ + ctfileverbs } tyfiletoken; @@ -1914,6 +1921,87 @@ return (setbooleanvalue (setfilelabel (&fs, bslabel), v)); } /*setlabelverb*/ + +static boolean getlabelindexverb (hdltreenode hparam1, tyvaluerecord *v) { + + /* + 2006-04-24 creedon: created, cribbed from getlabelverb function + */ + + tyfilespec fs; + short ixlabel; + + flnextparamislast = true; + + if (!getpathvalue (hparam1, 1, &fs)) + return (false); + + if (!getfilelabelindex (&fs, &ixlabel)) + return (false); + + return (setintvalue (ixlabel, v)); + } /* getlabelindexverb */ + + +static boolean setlabelindexverb (hdltreenode hparam1, tyvaluerecord *v) { + + /* + 2006-04-24 creedon: created, cribbed from setlabelverb function + */ + + tyfilespec fs; + short index; + + if (!getpathvalue (hparam1, 1, &fs)) + return (false); + + flnextparamislast = true; + + if (!getintvalue (hparam1, 2, &index)) + return (false); + + return (setbooleanvalue (setfilelabelindex (&fs, index, true), v)); + } /* setlabelindexverb */ + + +static boolean getlabelnamesverb (hdltreenode hparam1, tyvaluerecord *v) { + #pragma unused (hparam1) + + /* + 2006-04-24 creedon: created, cribbed from statusbargetsectionsfunc case of langfunctionvalue function + */ + + bigstring bsarray [8]; + hdllistrecord hlist; + int ix; + RGBColor labelcolor; + short mapfromuserinterfaceindex [8] = {0, 6, 7, 5, 2, 4, 3, 1}; + + for (ix = 0; ix < 8; ++ix) + + if (GetLabel (ix, &labelcolor, bsarray [ix]) != noErr) + + return (false); + + if (!opnewlist (&hlist, false)) + return (false); + + for (ix = 0; ix < 8; ++ix) + + if (!langpushliststring (hlist, bsarray [mapfromuserinterfaceindex [ix]])) + + goto getlabelnamesverberror; + + return (setheapvalue ((Handle) hlist, listvaluetype, v)); + + getlabelnamesverberror: + + opdisposelist (hlist); + + return (false); + + } /* getlabelnamesverb */ + #endif @@ -3529,7 +3617,15 @@ return (true); } + + case getlabelindexfunc: /* 2006-04-24 creedon */ + return (getlabelindexverb (hp1, v)); + case setlabelindexfunc: /* 2006-04-24 creedon */ + return (setlabelindexverb (hp1, v)); + + case getlabelnamesfunc: /* 2006-04-24 creedon */ + return (getlabelnamesverb (hp1, v)); #endif case folderfrompathfunc: Modified: Frontier/branches/Conversant/Common/source/lang.c =================================================================== --- Frontier/branches/Conversant/Common/source/lang.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/lang.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -81,7 +81,10 @@ tylangcallbacks langcallbacks; /*routines that wire the language into environment*/ +boolean flcominitialized = false; + + static short ctrootchains = 0; /*number of hashtable chains that include the root*/ static boolean flevaluateglobalwith = false; /*dmb 4.1b12 - new flag for langcard support*/ Modified: Frontier/branches/Conversant/Common/source/langstartup.c =================================================================== --- Frontier/branches/Conversant/Common/source/langstartup.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/langstartup.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -432,14 +432,14 @@ err = TECCountAvailableTextEncodings( &ct ); if ( err != noErr ) { - pophashtable(); - return (true); // don't kill the whole startup } - TextEncoding enc; + TextEncoding enc, encOut; TextEncoding availEncodings[ ct ]; - bigstring ianaName; + bigstring ianaName, displayName; + unsigned long lenDisplayName; + RegionCode reg; err = TECGetAvailableTextEncodings ( availEncodings, ct, &actual_ct ); if ( err != noErr ) @@ -464,55 +464,77 @@ if ( err != noErr ) continue; - langassignlongvalue( cSetsTable, ianaName, (long) enc ); + /* + get the encoding's display name, which is the value of the table cell + */ + err = GetTextEncodingName( enc, kTextEncodingFullName, verUS, kTextEncodingMacRoman, 255, &lenDisplayName, ®, &encOut, (TextPtr) displayName + 1 ); + if ( err != noErr ) + continue; + + displayName[ 0 ] = (unsigned char) lenDisplayName; + + langassignstringvalue( cSetsTable, ianaName, displayName ); } + + return (true); + #endif #if WIN95VERSION - langassignlongvalue( cSetsTable, "\x05" "ASCII", 20127 ); - langassignlongvalue( cSetsTable, "\x08" "US-ASCII", 20127 ); /* alias for ASCII */ + HRESULT err; + IMultiLanguage2 * pMultiLanguage; + IEnumCodePage * pEnumCodePage; + UINT i, cnum = 0; + MIMECPINFO cpInfo; + long ccpInfo; + bigstring ianaName, displayName; + + initCOM(); + + err = CoCreateInstance( + &CLSID_CMultiLanguage, + NULL, + CLSCTX_INPROC_SERVER, + &IID_IMultiLanguage2, + (void **) &pMultiLanguage ); + + if ( FAILED( err ) ) + goto done; + + err = pMultiLanguage->lpVtbl->EnumCodePages( + pMultiLanguage, + 0, // MIMECONTF_MAILNEWS | MIMECONTF_BROWSER | MIMECONTF_VALID | MIMECONTF_MIME_LATEST + 9, /* LANGID. I'm totally guessing that 0 means "all", here. -- smd */ + (IEnumCodePage **) &pEnumCodePage ); - langassignlongvalue( cSetsTable, "\x09" "MACINTOSH", 10000 ); - langassignlongvalue( cSetsTable, "\x08" "MacRoman", 10000 ); /* alias for MACINTOSH */ + if ( FAILED( err ) ) + goto done; + + pMultiLanguage->lpVtbl->GetNumberOfCodePageInfo( pMultiLanguage, &cnum ); - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-1", 28591 ); - langassignlongvalue( cSetsTable, "\x0b" "iso-latin-1", 28591 ); /* alias for iso-8859-1 */ - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-2", 28592 ); - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-3", 28593 ); - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-4", 28594 ); - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-5", 28595 ); - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-6", 28596 ); - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-7", 28597 ); - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-8", 28598 ); - langassignlongvalue( cSetsTable, "\x0a" "iso-8859-9", 28599 ); - langassignlongvalue( cSetsTable, "\x0b" "iso-8859-10", 28592 ); + // pcpInfo = (PMIMECPINFO)CoTaskMemAlloc( sizeof(MIMECPINFO) ); + + for ( i = 0; i < cnum; i++ ) + { + err = pEnumCodePage->lpVtbl->Next( pEnumCodePage, 1, &cpInfo, &ccpInfo ); + + if ( SUCCEEDED( err ) && ( ccpInfo != 0 ) ) + { + if ( copyWideToPString( cpInfo.wszWebCharset, ianaName ) + && copyWideToPString( cpInfo.wszDescription, displayName ) ) + langassignstringvalue( cSetsTable, ianaName, displayName ); + //langassignlongvalue( cSetsTable, ianaName, cpInfo.uiCodePage ); + } + } + + pEnumCodePage->lpVtbl->Release( pEnumCodePage ); + pMultiLanguage->lpVtbl->Release( pMultiLanguage ); + // CoTaskMemFree( (LPVOID) pcpInfo ); + +done: + return (true); - langassignlongvalue( cSetsTable, "\x0c" "windows-1250", 1250 ); - langassignlongvalue( cSetsTable, "\x0f" "windows-latin-2", 1250 ); /* code page 1250, Central Europe */ - - langassignlongvalue( cSetsTable, "\x0c" "windows-1251", 1251 ); /* code page 1251, Slavic Cyrillic */ - - langassignlongvalue( cSetsTable, "\x0c" "windows-1252", 1252 ); - langassignlongvalue( cSetsTable, "\x0f" "windows-latin-1", 1252 ); - - langassignlongvalue( cSetsTable, "\x0c" "windows-1253", 1253 ); /* code page 1253 */ - langassignlongvalue( cSetsTable, "\x0c" "windows-1254", 1254 ); /* code page 1254, Turkish */ - langassignlongvalue( cSetsTable, "\x0c" "windows-1255", 1255 ); /* code page 1255 */ - langassignlongvalue( cSetsTable, "\x0c" "windows-1256", 1256 ); /* code page 1256 */ - langassignlongvalue( cSetsTable, "\x0c" "windows-1257", 1257 ); /* code page 1257 */ - langassignlongvalue( cSetsTable, "\x0c" "windows-1258", 1258 ); /* code page 1258 */ - langassignlongvalue( cSetsTable, "\x0c" "windows-1361", 1361 ); /* code page 1361, for Windows NT */ - - langassignlongvalue( cSetsTable, "\x05" "UTF-7", 65000 ); - langassignlongvalue( cSetsTable, "\x05" "UTF-8", 65001 ); - - langassignlongvalue( cSetsTable, "\x06" "UTF-16", 0 ); /* not a real code page. 0 for special case handling in Frontier */ - - langassignlongvalue( cSetsTable, "\x08" "UTF-16le", 1200 ); - langassignlongvalue( cSetsTable, "\x08" "UTF-16be", 1201 ); -#endif - - return (true); +#endif } /* initCharsetsTable */ Modified: Frontier/branches/Conversant/Common/source/process.c =================================================================== --- Frontier/branches/Conversant/Common/source/process.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/process.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -1387,6 +1387,11 @@ listunlink ((hdllinkedlist) processthreadlist, (hdllinkedlist) hg); if (hg == hthreadglobals) { + + #ifdef WIN95VERSION + if ( flcominitialized ) + shutdownCOM(); + #endif disposehandle ((Handle) hashtablestack); @@ -1451,6 +1456,12 @@ (**hg).timesliceticks = processonehottimeslice; + /* + 2006-04-24 smd + has COM been initialized in this thread? + */ + (**hg).flcominitialized = false; + #ifdef landinclude id = getprocesscreator (); @@ -1580,6 +1591,12 @@ (**hg).tryerror = tryerror; (**hg).tryerrorstack = tryerrorstack; + + /* + 2006-04-24 smd + has COM been initialized in this thread? + */ + (**hg).flcominitialized = flcominitialized; } (**hg).langcallbacks = langcallbacks; Modified: Frontier/branches/Conversant/Common/source/shell.c =================================================================== --- Frontier/branches/Conversant/Common/source/shell.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/shell.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -256,7 +256,7 @@ fileshutdown(); UnregisterAppearanceClient(); #endif - + exittooperatingsystem (); /*doesn't return*/ return (true); /*satisfy the compiler -- not a void function*/ Modified: Frontier/branches/Conversant/Common/source/strings.c =================================================================== --- Frontier/branches/Conversant/Common/source/strings.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/strings.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -28,6 +28,10 @@ #include "frontier.h" #include "standard.h" +#ifdef WIN95VERSION + #include "FrontierWinMain.h" +#endif + #include "font.h" #include "memory.h" #include "quickdraw.h" @@ -56,8 +60,19 @@ static byte bshexprefix [] = STR_hexprefix; +/* declarations */ +static boolean converttextencoding( Handle, Handle, const long, const long ); +static boolean getTextEncodingID( bigstring, long * ); +#ifdef WIN95VERSION + static HRESULT UnicodeToAnsi(Handle, Handle, unsigned long); + static HRESULT AnsiToUnicode(Handle, Handle, unsigned long); +#endif + + +/* definitions */ + boolean equalstrings (const bigstring bs1, const bigstring bs2) { /* @@ -1667,6 +1682,42 @@ } /*parsenumberstring*/ + +#ifdef WIN95VERSION +boolean copyWideToPString( const wchar_t * inString, bigstring bs ) +{ + HRESULT err; + size_t lenOut; + + err = wcstombs_s( &lenOut, bs, 255, inString, _TRUNCATE ); + + if ( FAILED( err ) ) + return (false); + + convertcstring( bs ); + + return (true); +} /* copyWideToPString */ + +boolean copyPStringToWide( bigstring bs, long * lenResult, wchar_t * outString ) +{ + HRESULT err; + size_t lenOut; + + convertpstring( bs ); + + err = mbstowcs_s( &lenOut, outString, 255, (const char *) bs, _TRUNCATE ); + + if ( SUCCEEDED( err ) ) + { + *lenResult = (long) lenOut; + return (true); + } + else + return (false); +} +#endif + void convertpstring (bigstring bs) { /* @@ -2267,14 +2318,14 @@ ULONG cbAnsi, cCharacters; long lentext; - cCharacters = wcslen((const unsigned short*) *h)+1; + cCharacters = wcslen((wchar_t *) *h)+1; cbAnsi = cCharacters * 2; sethandlesize (hresult, cbAnsi); // Convert to ANSI. - lentext = WideCharToMultiByte(encoding, 0,(const unsigned short*) *h, -1, *hresult, + lentext = WideCharToMultiByte( encoding, 0,(wchar_t *) *h, -1, *hresult, cbAnsi, NULL, NULL); sethandlesize (hresult, lentext - 1); @@ -2287,13 +2338,12 @@ { /* - 7.0b42 PBS: convert from Unicode to Ansi. Borrowed from Microsoft sample code. + 7.0b42 PBS: convert from ANSI to Unicode. Borrowed from Microsoft sample code. */ ULONG cbUni, cCharacters; long lentext; - unsigned long ix; - char lastch = ' '; + // unsigned long ix; cCharacters = gethandlesize (h); @@ -2305,35 +2355,15 @@ sethandlesize (hresult, cbUni); // Convert to ANSI. - lentext = MultiByteToWideChar (encoding, 0, *h, -1, (unsigned short*) *hresult, cbUni); + lentext = MultiByteToWideChar (encoding, 0, *h, cCharacters, (wchar_t *) *hresult, cbUni); - ix = 0; + if ( lentext > 0 ) /* FIXME: what should we do if lentext is 0, which is an error condition? */ + { + sethandlesize( hresult, ( lentext + 1 ) * 2 ); + ((wchar_t *)(*hresult))[lentext] = L'\0'; + } - while (true) { /*find terminator*/ - - char ch = (*hresult) [ix]; - - if (ch == '\0') { - - if ((*hresult) [ix + 1] == '\0') { - - sethandlesize (hresult, ix + 2); - - break; - } /* if */ - - } /*if*/ - - ix += 2; - - if (ix > cbUni) - break; - - lastch = ch; - } /*while*/ - return NOERROR; - } #endif /*end Windows character conversion routines*/ @@ -2341,33 +2371,94 @@ /* convert an "internet name" for an encoding into a platform-specific id for the character set */ -boolean gettextencodingid (const Handle h, long * encodingId) { +static boolean getTextEncodingID( bigstring bsEncodingName, long * encodingId ) { #ifdef MACVERSION OSStatus err; TextEncoding oneEncoding; - bigstring ianaName; - long ct, ix = 0; - ct = gethandlesize (h); - ianaName [0] = (byte) ct; - loadfromhandle (h, &ix, ct, ianaName + 1); + err = TECGetTextEncodingFromInternetName( &oneEncoding, bsEncodingName ); - err = TECGetTextEncodingFromInternetName( &oneEncoding, ianaName ); - if ( err != noErr ) return (false); *encodingId = (long) oneEncoding; #endif + +#ifdef WIN95VERSION + + HRESULT err; + IMultiLanguage2 * pMultiLanguage; + MIMECSETINFO setInfo; + wchar_t ianaName[ 512 ]; + long lenIanaName; + + lowertext( (ptrbyte) (bsEncodingName + 1), (long) bsEncodingName[ 0 ] ); + + if ( equalstrings( bsEncodingName, BIGSTRING ("\x06" "utf-16") ) ) + { + *encodingId = 0; + return (true); + } + + initCOM(); + + err = CoCreateInstance( + &CLSID_CMultiLanguage, + NULL, + CLSCTX_INPROC_SERVER, + &IID_IMultiLanguage2, + (void **) &pMultiLanguage ); + + if ( FAILED( err ) ) + return (false); + + copyPStringToWide( bsEncodingName, &lenIanaName, ianaName ); + + // pSetInfo = (PMIMECSETINFO)CoTaskMemAlloc( sizeof(MIMECSETINFO) ); + + err = pMultiLanguage->lpVtbl->GetCharsetInfo( pMultiLanguage, ianaName, &setInfo ); + if ( FAILED( err ) ) + return (false); + + *encodingId = (long)(setInfo.uiInternetEncoding); + + pMultiLanguage->lpVtbl->Release( pMultiLanguage ); + +#endif return (true); } +/* + determine if the specified character set is recognized by the OS + bsEncodingName is an IANA-friendly name like "utf-8" , "macintosh", or "iso-8859-1" +*/ +boolean isTextEncodingAvailable( bigstring bsEncodingName ) +{ + long encodingId; + + if ( ! getTextEncodingID( bsEncodingName, &encodingId ) ) + return (false); + + #ifdef MACVERSION + + // the mac version has no encoding id 0, so this means a failure + return ( encodingId >= 0 ); + + #endif + + #ifdef WIN95VERSION + + // we use 0 to refer to UTF-16 on Windows, as it's the default character set and has no code page + return (true); + + #endif +} -boolean converttextencoding (Handle h, Handle hresult, long inputcharset, long outputcharset) { +static boolean converttextencoding( Handle h, Handle hresult, const long inputcharset, const long outputcharset) { #ifdef MACVERSION /*Mac character conversion common routine*/ @@ -2378,10 +2469,6 @@ long pullBytes = 0; long lentext = gethandlesize (h); - // sethandlesize (h, lentext + 1); - - // (*h) [lentext] = '\0'; - status = TECCreateConverter (&converter, inputcharset, outputcharset); if ( status != noErr ) { TECDisposeConverter (converter); @@ -2419,15 +2506,6 @@ } } - //old code - // if (((*h) [0] == '\xFF') || ((*h) [0] == '\xEF')) /*pop byte order mark*/ - // pullfromhandle (h, 0, 3, NULL); - - /* - if (pullBytes > 0) - pullfromhandle (h, 0, pullBytes, NULL); - */ - lentext = gethandlesize (h) - pullBytes; status = TECConvertText (converter, (ConstTextPtr)(*h + pullBytes), lentext, &ctorigbytes, (TextPtr)(*hresult), sizeoutputbuffer, &ctoutputbytes); @@ -2445,10 +2523,6 @@ return (true); - // kwchange 2005-05-23 --- commented out to see if this is the missing trailing char bug - // kwchange 2005-05-27 --- ran this the last week and have no complains - //sethandlesize (hresult, gethandlesize (hresult) - 1); /*pop trailing terminator*/ - #endif /*end Mac character conversion routine(s)*/ #ifdef WIN95VERSION @@ -2471,14 +2545,15 @@ if ((*h) [0] == '\xFF') pullfromhandle (hresult,0, 1, NULL); /* Pop off the BOM */ + return (true); + default: { lentext = gethandlesize (h); switch ( outputcharset ) { case 0: /* unicode with BOM, not handled as a code page. I Sitll Hatesk Windows (and rrrabbits) */ - if (AnsiToUnicode (h, hresult, inputcharset)) - return (false); + return (!AnsiToUnicode (h, hresult, inputcharset)); default: { Handle htemp; @@ -2517,10 +2592,42 @@ } /*converttextencoding*/ +boolean convertCharset( Handle hString, Handle hresult, bigstring charsetIn, bigstring charsetOut ) +{ +#ifdef MACVERSION + + TextEncoding teInputSet, teOutputSet; + +#endif + +#ifdef WIN95VERSION + + long teInputSet, teOutputSet; + + initCOM(); + +#endif + + if ( ! getTextEncodingID( charsetIn, (long *) &teInputSet ) ) + { + // FIXME: generate error, encoding not available + return (false); + } + + if ( ! getTextEncodingID( charsetOut, (long *) &teOutputSet ) ) + { + // FIXME: generate error, encoding not available + return (false); + } + + return ( converttextencoding( hString, hresult, (long) teInputSet, (long) teOutputSet ) ); +} + + boolean utf16toansi (Handle h, Handle hresult) { /* - 7.0b42 PBS: convert from UTF-16 to UTF-8 character sets. + 7.0b42 PBS: convert from UTF-16 to iso-8859-1 character sets. */ #ifdef WIN95VERSION @@ -2542,60 +2649,10 @@ #endif #ifdef MACVERSION -/* - if (((*h) [0] == '\xFF') || ((*h) [0] == '\xEF')) /#pop byte order mark#/ - - pullfromhandle (h, 0, 2, NULL); - - // why do we need a string starting with a 0??? - if ((*h) [0] != '\0') - - insertinhandle (h, 0, NULL, 1); -*/ + if (!converttextencoding (h, hresult, kTextEncodingUnicodeDefault, kTextEncodingWindowsLatin1)) return (false); -/* OSErr err = noErr; - - UnicodeToTextInfo utinfo; - - UnicodeMapping utmapping; - - ByteCount ctunibytes, ctansibytes; - - long lentext = gethandlesize (h); - - sethandlesize (h, lentext + 1); - - (*h) [lentext] = '\0'; - - utmapping.unicodeEncoding = kTextEncodingUnicodeDefault; - - utmapping.otherEncoding = kTextEncodingISOLatin1; - - utmapping.mappingVersion = kUnicodeUseLatestMapping; - - err = CreateUnicodeToTextInfo (&utmapping, &utinfo); - - sethandlesize (hresult, lentext * 2); - - pullfromhandle (h, 0, 2, NULL); - - insertinhandle (h, 0, NULL, 1); - - lentext = gethandlesize (h); - - err = ConvertFromUnicodeToText (utinfo, lentext, (ConstUniCharArrayPtr) *h, - kUnicodeUseFallbacksMask, - 0, NULL, NULL, NULL, - lentext * 2, &ctunibytes, &ctansibytes, *hresult); - - DisposeUnicodeToTextInfo (&utinfo); - - sethandlesize (hresult, ctansibytes); - - sethandlesize (hresult, gethandlesize (hresult) - 1); #*pop trailing terminator*/ - #endif return (true); @@ -2637,38 +2694,6 @@ if (!converttextencoding (h, hresult, kCFStringEncodingUTF8, kTextEncodingWindowsLatin1)) return (false); -/* OSErr err = noErr; - - long lentext = gethandlesize (h); - - TECObjectRef converter; - - ByteCount ctunibytes, ctansibytes, ctflushedbytes; - - sethandlesize (h, lentext + 1); - - (*h) [lentext] = '\0'; - - err = TECCreateConverter (&converter, 0x08000100, kTextEncodingWindowsLatin1); #*0x08000100 is UTF-8*/ - -/* sethandlesize (hresult, lentext * 2); - - if (((*h) [0] == '\xFF') || ((*h) [0] == '\xEF')) #*pop byte order mark*/ - -/* pullfromhandle (h, 0, 3, NULL); - - lentext = gethandlesize (h); - - err = TECConvertText (converter, *h, lentext, &ctunibytes, *hresult, lentext * 2, &ctansibytes); - - TECFlushText (converter, *hresult, lentext * 2, &ctflushedbytes); - - TECDisposeConverter (converter); - - sethandlesize (hresult, ctansibytes); - - sethandlesize (hresult, gethandlesize (hresult) - 1); #*pop trailing terminator*/ - #endif return (true); Modified: Frontier/branches/Conversant/Common/source/stringverbs.c =================================================================== --- Frontier/branches/Conversant/Common/source/stringverbs.c 2006-04-25 01:00:13 UTC (rev 1334) +++ Frontier/branches/Conversant/Common/source/stringverbs.c 2006-04-25 03:00:10 UTC (rev 1335) @@ -312,6 +312,8 @@ utf8tomacromanfunc, // 2006-02-25 creedon convertcharsetfunc, /* 2006-04-14 smd */ + + ischarsetavailablefunc, /* 2006-04-23 smd */ ctstringverbs } tystringtoken; @@ -1319,6 +1321,21 @@ } /*latintomac*/ +static boolean isCharsetAvailableVerb( hdltreenode hp1, tyvaluerecord *v ) +{ + bigstring bscharset; + + flnextparamislast = true; + + if ( !getstringvalue( hp1, 1, bscharset ) ) /* IANA names can't be longer than 40 ASCII characters, so this is safe */ + return (false); + + (*v).data.flvalue = isTextEncodingAvailable( bscharset ); + + return (true); +} + + static boolean stringfunctionvalue (short token, hdltreenode hparam1, tyvaluerecord *vreturned, bigstring bserror) { /* @@ -2302,32 +2319,39 @@ return (setheapvalue (hresult, stringvaluetype, v)); } - case convertcharsetfunc: { /* 2006-04-13 smd: convert any character set to any other character set, if the os supports it */ - + case convertcharsetfunc: /* 2006-04-13 smd: convert any character set to any other character set, if the os supports it */ + { Handle h, hresult; - long charsetIn, charsetOut; + bigstring charsetIn, charsetOut; - if (!getlongvalue (hp1, 1, &charsetIn)) + /* + the "internet names" of character sets are 40 ASCII chars or less, + so this is a safe way to get the params + */ + if ( !getstringvalue( hp1, 1, charsetIn ) ) goto error; - if (!getlongvalue (hp1, 2, &charsetOut)) + if ( !getstringvalue( hp1, 2, charsetOut ) ) goto error; flnextparamislast = true; - if (!getreadonlytextvalue (hp1, 3, &h)) + if ( !getreadonlytextvalue( hp1, 3, &h ) ) goto error; - newemptyhandle (&hresult); + newemptyhandle( &hresult ); - if (! converttextencoding (h, hresult, charsetIn, charsetOut)) + if ( !convertCharset( h, hresult, charsetIn, charsetOut ) ) goto error; - // disposehandle(h); - - return (setheapvalue (hresult, stringvaluetype, v)); - } + return ( setheapvalue( hresult, stringvaluetype, v ) ); + } + case ischarsetavailablefunc: /* 2006-04-23 smd: determine if a character set is available, based on an internet-friendly (IANA) name */ + { + return isCharsetAvailableVerb( hparam1, v ); + } + default: errornum = notimplementederror; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |