Index: af/util/xp/ut_go_file.cpp =================================================================== --- af/util/xp/ut_go_file.cpp (revision 29473) +++ af/util/xp/ut_go_file.cpp (working copy) @@ -1135,7 +1135,11 @@ *err = NULL; g_return_val_if_fail (uri != NULL, NULL); +#ifdef WIN32 + if (uri[0] != G_DIR_SEPARATOR && uri[1] == ':' && uri[2] == '\\') { +#else if (uri[0] == G_DIR_SEPARATOR) { +#endif g_warning ("Got plain filename %s in UT_go_file_open.", uri); return open_plain_file (uri, err); } Index: af/xap/win/xap_Win32Slurp.cpp =================================================================== --- af/xap/win/xap_Win32Slurp.cpp (revision 29473) +++ af/xap/win/xap_Win32Slurp.cpp (working copy) @@ -27,6 +27,7 @@ #include "ut_assert.h" #include "ut_debugmsg.h" #include "ut_string.h" +#include "UT_Win32LocaleString.h" #include "xap_Frame.h" #include "xap_Win32App.h" #include "xap_Win32Slurp.h" @@ -134,7 +135,7 @@ // Register us with the DDE Management Library (DDEML). m_idDdeServerInst = 0; - UINT nDdeRtnStatus = DdeInitialize(&m_idDdeServerInst, + UINT nDdeRtnStatus = DdeInitializeW(&m_idDdeServerInst, (PFNCALLBACK)&s_DdeServerCallback, ( APPCMD_FILTERINITS | CBF_SKIP_CONNECT_CONFIRMS @@ -195,7 +196,11 @@ } DdeGetData(hData,(LPBYTE)pBuf,bufSize+99,0); - UT_DEBUGMSG(("DDEML received command '%s'\n",pBuf)); + UT_Win32LocaleString wstr; + UT_UTF8String astr; + wstr.fromLocale((LPCWSTR)pBuf); + astr=wstr.utf8_str(); + UT_DEBUGMSG(("DDEML received command '%s'\n",astr.utf8_str())); // we expect something of the form: // [Open("")] @@ -205,7 +210,7 @@ // TODO would be nice // pointer to work through the incoming string - char * next = pBuf; + const char * next = astr.utf8_str(); // pointer used to copy into command and pathname char * dest = 0; @@ -305,7 +310,7 @@ void XAP_Win32Slurp::stuffRegistry(const char * szSuffix, const char * szApplicationName, - const char * szExePathname, + LPCWSTR szExePathname, const char * szContentType) { // load the system registry if there's no info @@ -334,11 +339,12 @@ #define CONTENT_TYPE_KEY "Content Type" #define DOCUMENT_ICON_POSITION 2 #define xx(s) ((LPBYTE)(s)),(strlen(s)+1) +#define xxw(s) ((LPBYTE)(s)),((lstrlenW(s)+1)<<1) char buf[1024]; char bufOurFoo[1024]; - char bufOurFooValue[1024]; - char bufDefaultIconValue[1024]; + WCHAR bufOurFooValue[1024]; + WCHAR bufDefaultIconValue[1024]; DWORD dType; LONG eResult; ULONG len; @@ -358,7 +364,13 @@ sprintf(bufOurFoo,"AbiSuite.%s",szApplicationName); strtok(bufOurFoo," "); // trim key at first whitespace - sprintf(bufOurFooValue,"%s Document",szApplicationName); + const XAP_StringSet *pSS = XAP_App::getApp()->getStringSet(); + const gchar *pStr = pSS->getValue(XAP_STRING_ID_DocumentType); + UT_Win32LocaleString tmpl; + char tdbuf[512]; + wsprintfA(tdbuf,pStr,szApplicationName); + tmpl.fromUTF8(tdbuf); + wcscpy(bufOurFooValue,tmpl.c_str()); /////////////////////////////////////////////////////////////////// // See if someone has claimed this suffix. @@ -370,7 +382,7 @@ case X_Error: goto CleanupMess; - case X_CreatedKey: // we are g_free to create what we want. + case X_CreatedKey: // we are free to create what we want. bCreateOrOverwrite = true; break; @@ -465,8 +477,8 @@ case X_ExistingKey: UT_ASSERT(hKeyFoo); len = G_N_ELEMENTS(buf); - eResult = RegQueryValueEx(hKeyFoo,NULL,0,&dType,(LPBYTE)buf,&len); - if ((eResult==ERROR_SUCCESS) && (dType==REG_SZ) && (g_ascii_strcasecmp(buf,bufOurFooValue)==0)) + eResult = RegQueryValueExW(hKeyFoo,NULL,0,&dType,(LPBYTE)buf,&len); + if ((eResult==ERROR_SUCCESS) && (dType==REG_SZ) && (lstrcmpiW((LPCWSTR)buf,bufOurFooValue)==0)) break; // already has correct value, no need to overwrite. /* otherwise, replace the value */ @@ -474,7 +486,7 @@ case X_CreatedKey: UT_ASSERT(hKeyFoo); - eResult = RegSetValueEx(hKeyFoo,NULL,0,REG_SZ,xx(bufOurFooValue)); + eResult = RegSetValueExW(hKeyFoo,NULL,0,REG_SZ,xxw(bufOurFooValue)); if (eResult != ERROR_SUCCESS) goto CleanupMess; break; @@ -484,9 +496,9 @@ // Inspect the command path // HKEY_CLASSES_ROOT\\shell\open\command = /////////////////////////////////////////////////////////////////// - char commandPathWithParam[1024]; - strcpy ( commandPathWithParam, szExePathname ); - strcat ( commandPathWithParam, " \"%1\"" ); + WCHAR commandPathWithParam[1024]; + wcscpy ( commandPathWithParam, szExePathname ); + wcscat ( commandPathWithParam, L" \"%1\"" ); if (_fetchKey(hKeyFoo,"shell",&hKeyShell) == X_Error) goto CleanupMess; @@ -500,13 +512,13 @@ case X_ExistingKey: UT_ASSERT(hKeyCommand); len = G_N_ELEMENTS(buf); - eResult = RegQueryValueEx(hKeyCommand,NULL,0,&dType,(LPBYTE)buf,&len); + eResult = RegQueryValueExW(hKeyCommand,NULL,0,&dType,(LPBYTE)buf,&len); if ((eResult==ERROR_SUCCESS) && (dType==REG_SZ)) { - if (g_ascii_strcasecmp(buf,commandPathWithParam) == 0) + if (lstrcmpiW((LPCWSTR)buf,commandPathWithParam) == 0) break; // already has correct value, no need to overwrite. - if(memcmp(buf, commandPathWithParam, strlen(commandPathWithParam)) == 0) + if(memcmp(buf, commandPathWithParam, lstrlenW(commandPathWithParam)<<1) == 0) { // Path name is the same but has extra at the end. // Probably "%1" @@ -527,7 +539,7 @@ case X_CreatedKey: UT_ASSERT(hKeyCommand); if (eResult != ERROR_SUCCESS) - eResult = RegSetValueEx(hKeyCommand,NULL,0,REG_SZ,xx(commandPathWithParam)); + eResult = RegSetValueExW(hKeyCommand,NULL,0,REG_SZ,xxw(commandPathWithParam)); goto CleanupMess; break; } @@ -618,10 +630,10 @@ /////////////////////////////////////////////////////////////////// // Set the default icon for the suffix (this is for Explorer et al. - // HKEY_CLASSES_ROOT\\DefaultIcon = + // HKEY_CLASSES_ROOT\\DefaultIcon = /////////////////////////////////////////////////////////////////// - sprintf(bufDefaultIconValue,"%s,%d",szExePathname,DOCUMENT_ICON_POSITION); + wsprintfW(bufDefaultIconValue,L"%s,%d",szExePathname,DOCUMENT_ICON_POSITION); switch ( _fetchKey(hKeyFoo,"DefaultIcon",&hKeyDefaultIcon) ) { case X_Error: @@ -629,9 +641,9 @@ case X_ExistingKey: UT_ASSERT(hKeyDefaultIcon); - len = G_N_ELEMENTS(buf); - eResult = RegQueryValueEx(hKeyDefaultIcon,NULL,0,&dType,(LPBYTE)buf,&len); - if ((eResult==ERROR_SUCCESS) && (dType==REG_SZ) && (g_ascii_strcasecmp(buf,bufDefaultIconValue)==0)) + len = G_N_ELEMENTS((LPWSTR)buf); + eResult = RegQueryValueExW(hKeyDefaultIcon,NULL,0,&dType,(LPBYTE)buf,&len); + if ((eResult==ERROR_SUCCESS) && (dType==REG_SZ) && (lstrcmpiW((LPWSTR)buf,bufDefaultIconValue)==0)) break; // already has correct value, no need to overwrite. /* otherwise, replace the value */ @@ -639,7 +651,7 @@ case X_CreatedKey: UT_ASSERT(hKeyDefaultIcon); - eResult = RegSetValueEx(hKeyDefaultIcon,NULL,0,REG_SZ,xx(bufDefaultIconValue)); + eResult = RegSetValueExW(hKeyDefaultIcon,NULL,0,REG_SZ,xxw(bufDefaultIconValue)); if (eResult != ERROR_SUCCESS) goto CleanupMess; break; Index: af/xap/win/xap_Win32Slurp.h =================================================================== --- af/xap/win/xap_Win32Slurp.h (revision 29473) +++ af/xap/win/xap_Win32Slurp.h (working copy) @@ -35,7 +35,7 @@ void processCommand(HDDEDATA hData); void stuffRegistry(const char * szSuffix, const char * szApplicationName, - const char * szExePathname, + LPCWSTR szExePathname, const char * szContentType); protected: Index: xap_Win32App.cpp =================================================================== --- xap_Win32App.cpp (revision 29473) +++ xap_Win32App.cpp (working copy) @@ -32,6 +32,7 @@ #include "ut_debugmsg.h" #include "ut_path.h" #include "ut_Win32Uuid.h" +#include "ut_win32localestring.h" #include "xap_Win32App.h" #include "xap_Win32Clipboard.h" #include "xap_Frame.h" @@ -167,12 +168,16 @@ m_pSlurp = new XAP_Win32Slurp(this); m_pSlurp->connectSlurper(); - char bufExePathname[4096]; - GetModuleFileNameA(NULL,bufExePathname,G_N_ELEMENTS(bufExePathname)); //!TODO Using ANSI function + WCHAR bufExePathname[2048]; + WCHAR bufDiskName[10]; + GetModuleFileNameW(NULL,bufExePathname,G_N_ELEMENTS(bufExePathname)); + lstrcpynW(bufDiskName,bufExePathname,4); - // TODO these are Application-Specific values. Move them out of here. - m_pSlurp->stuffRegistry(".abw",getApplicationName(),bufExePathname,"application/abiword"); - m_pSlurp->stuffRegistry(".zabw",getApplicationName(),bufExePathname,"application/abiword-compressed"); + if (GetDriveTypeW(bufDiskName)==DRIVE_FIXED) { + // TODO these are Application-Specific values. Move them out of here. + m_pSlurp->stuffRegistry(".abw",getApplicationName(),bufExePathname,"application/abiword"); + m_pSlurp->stuffRegistry(".zabw",getApplicationName(),bufExePathname,"application/abiword-compressed"); + } return true; }