Ignore:
Timestamp:
Aug 7, 2001, 11:33:44 PM (24 years ago)
Author:
sandervl
Message:

Shell link updates for creating program objects on OS/2 desktop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/shelllink.c

    r5618 r6481  
    2626#include "shlobj.h"
    2727#include "wine/undocshell.h"
    28 #ifndef __WIN32OS2__
     28#ifdef __WIN32OS2__
     29#define NO_DCDATA
     30#include <winuser32.h>
     31#include <winres.h>
     32
     33#undef WARN
     34#undef TRACE
     35#ifdef DEBUG
     36#define TRACE WriteLog("SHELL32: %s", __FUNCTION__); WriteLog
     37#define WARN WriteLog("WARNING: SHELL32: %s", __FUNCTION__); WriteLog
     38#else
     39#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     40#define WARN 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     41#endif
     42
     43#else
    2944#include "bitmaps/wine.xpm"
    3045#endif
     
    235250
    236251
    237 #ifndef __WIN32OS2__
     252#ifdef __WIN32OS2__
     253static BOOL SaveIconResAsOS2ICO(GRPICONDIR *pIconDir, HINSTANCE hInstance, const char *szXPMFileName)
     254{
     255    FILE *fXPMFile;
     256    void *lpOS2Icon;
     257    DWORD ressize;
     258
     259    if (!(fXPMFile = fopen(szXPMFileName, "w")))
     260        return 0;
     261
     262    lpOS2Icon = ConvertIconGroup((void *)pIconDir, hInstance, &ressize);
     263    if(lpOS2Icon) {
     264        fwrite(lpOS2Icon, 1, ressize, fXPMFile);
     265        free(lpOS2Icon);
     266    }
     267    fclose(fXPMFile);
     268    return 1;
     269}
     270#else
    238271/* Icon extraction routines
    239272 *
     
    330363    return 0;
    331364}
     365#endif //__WIN32OS2__
    332366
    333367static BOOL CALLBACK EnumResNameProc(HANDLE hModule, const char *lpszType, char *lpszName, LONG lParam)
     
    383417    }
    384418
     419#ifdef __WIN32OS2__
     420    if(!SaveIconResAsOS2ICO(pIconDir, hModule, szXPMFileName))
     421    {
     422        TRACE("Failed saving icon as XPM, error %ld\n", GetLastError());
     423        goto error3;
     424    }
     425#else
    385426    for (i = 0; i < pIconDir->idCount; i++)
    386427        if ((pIconDir->idEntries[i].bHeight * pIconDir->idEntries[i].bWidth) > nMax)
     
    413454        goto error3;
    414455    }
    415 
     456#endif
    416457    FreeResource(hResData);
    417458    FreeLibrary(hModule);
     
    436477    void *pIcon;
    437478    int i;
     479#ifdef __WIN32OS2__
     480    int size;
     481#endif
    438482
    439483    if (!(fICOFile = fopen(szFileName, "r")))
    440484        goto error1;
     485
     486#ifdef __WIN32OS2__
     487     //TODO:
     488    dprintf(("TODO: Icon file conversion not yet supported!!"));
     489    goto error2;
     490#else
    441491
    442492    if (fread(&iconDir, sizeof (ICONDIR), 1, fICOFile) != 1)
     
    466516        goto error4;
    467517
     518#endif
    468519    free(pIcon);
    469520    free(pIconDirEntry);
     
    482533}
    483534
     535#ifndef __WIN32OS2__
    484536/* get the Unix file name for a given path, allocating the string */
    485537inline static char *get_unix_file_name( const char *dos )
     
    504556    return TRUE;
    505557}
     558#endif //__WIN32OS2__
    506559
    507560/* extract an icon from an exe or icon file; helper for IPersistFile_fnSave */
    508 static char *extract_icon( const char *path, int index )
     561#ifdef __WIN32OS2__
     562static char *extract_icon( const char *path, char *filename, int index)
     563{
     564    if (ExtractFromEXEDLL( path, index, filename )) return filename;
     565    if (ExtractFromICO( path, filename )) return filename;
     566    return NULL;
     567}
     568#else
     569static char *extract_icon( const char *path, int index)
    509570{
    510571    char *filename = HEAP_strdupA( GetProcessHeap(), 0, tmpnam(NULL) );
     
    515576    return NULL;
    516577}
    517 #endif //__WIN32OS2__
     578#endif
    518579
    519580static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFileName, BOOL fRemember)
     
    529590    BOOL bDesktop;
    530591    HKEY hkey;
     592#ifdef __WIN32OS2__
     593    char *tmp;
     594#endif
    531595
    532596    _ICOM_THIS_From_IPersistFile(IShellLinkImpl, iface);
     
    544608    /* check if ShellLinker configured */
    545609#ifdef __WIN32OS2__
    546     return NOERROR;
     610    dprintf(("IPersistFile_fnSave %ls", pszFileName));
     611    filename = link_name = NULL;
     612    bDesktop = 0;
     613
     614    if (!WideCharToMultiByte( CP_ACP, 0, pszFileName, -1, buffer, sizeof(buffer), NULL, NULL))
     615        return ERROR_UNKNOWN;
     616    GetFullPathNameA( buffer, sizeof(buff2), buff2, NULL );
     617    filename = HEAP_strdupA( GetProcessHeap(), 0, buff2 );
     618
     619    if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTUP, FALSE ))
     620    {
     621        /* ignore startup for now */
     622        if (!strncasecmp( filename, buffer, strlen(buffer) )) goto done;
     623    }
     624    if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_DESKTOPDIRECTORY, FALSE ))
     625    {
     626        if (!strncasecmp( filename, buffer, strlen(buffer) ))
     627        {
     628            link_name = filename + strlen(buffer);
     629            bDesktop = TRUE;
     630            goto found;
     631        }
     632    }
     633    if (SHGetSpecialFolderPathA( 0, buffer, CSIDL_STARTMENU, FALSE ))
     634    {
     635        if (!strncasecmp( filename, buffer, strlen(buffer) ))
     636        {
     637            link_name = filename + strlen(buffer);
     638            bDesktop = FALSE;
     639            goto found;
     640        }
     641    }
     642    goto done;
     643
     644 found:
     645
     646    icon_name = HEAP_strdupA( GetProcessHeap(), 0, filename );
     647    strupr(icon_name);
     648    tmp = strstr(icon_name, ".LNK");
     649    if(!tmp) {
     650        dprintf(("ERROR: Unexpected name %s", icon_name));
     651        goto done;
     652    }
     653    tmp[1] = 'I';
     654    tmp[2] = 'C';
     655    tmp[3] = 'O';
     656    /* extract the icon */
     657    if (!extract_icon( This->sIcoPath && strlen(This->sIcoPath) ?
     658                       This->sIcoPath : This->sPath,
     659                       icon_name, This->iIcoNdx)) goto done;
     660
     661    if(OSLibWinCreateObject(This->sPath, This->sArgs, This->sWorkDir, filename,
     662                            This->sDescription, icon_name,
     663                            This->iIcoNdx, bDesktop) == FALSE)
     664    {
     665        ret = E_ACCESSDENIED;
     666    }
     667   
     668 done:
     669    if(shell_link_app) HeapFree( GetProcessHeap(), 0, shell_link_app );
     670    if(filename) HeapFree( GetProcessHeap(), 0, filename );
     671    if(icon_name) HeapFree( GetProcessHeap(), 0, icon_name );
     672    if(path_name) HeapFree( GetProcessHeap(), 0, path_name );
     673    if(work_dir) HeapFree( GetProcessHeap(), 0, work_dir );
     674    return ret;
     675
    547676#else
    548677    buffer[0] = 0;
Note: See TracChangeset for help on using the changeset viewer.