Ignore:
Timestamp:
Mar 8, 2002, 12:01:03 PM (23 years ago)
Author:
sandervl
Message:

PH: Wine resync + OS2 integration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/shell32/shell32_odin.cpp

    r7904 r8048  
    1 /* $Id: shell32_odin.cpp,v 1.3 2002-02-14 12:10:10 sandervl Exp $ */
     1/* $Id: shell32_odin.cpp,v 1.4 2002-03-08 11:01:00 sandervl Exp $ */
    22
    33/*
     
    5555#include <ctype.h>
    5656#include <module.h>
     57
     58#include "os2_integration.h"
     59
    5760
    5861/*****************************************************************************
     
    982985                                 LPCSTR lpDirectory,
    983986                                 INT    iShowCmd )
    984 {   HINSTANCE retval=31;
    985     char old_dir[1024];
    986     char cmd[256];
    987 
    988     if (lpFile==NULL) return 0; /* should not happen */
    989     if (lpOperation==NULL) /* default is open */
    990       lpOperation="open";
    991 
    992     if (lpDirectory)
    993     { GetCurrentDirectoryA( sizeof(old_dir), old_dir );
    994         SetCurrentDirectoryA( lpDirectory );
    995     }
    996 
    997     cmd[0] = '\0';
    998     retval = SHELL_FindExecutable( lpFile, lpOperation, cmd );
    999 
    1000     if (retval > 32)  /* Found */
     987{
     988  HINSTANCE retval=31;
     989  char old_dir[1024];
     990  char cmd[256];
     991  LONG cmdlen = sizeof( cmd );
     992  LPSTR tok;
     993
     994  if (lpFile==NULL)
     995    return 0; /* should not happen */
     996 
     997  if (lpOperation==NULL) /* default is open */
     998    lpOperation="open";
     999
     1000  if (lpDirectory)
     1001  {
     1002    // @@@PH 2002-02-26 might throw whole process off track
     1003    // in case of concurrency
     1004    GetCurrentDirectoryA( sizeof(old_dir), old_dir );
     1005    SetCurrentDirectoryA( lpDirectory );
     1006  }
     1007
     1008  cmd[0] = '\0';
     1009  retval = SHELL_FindExecutable( lpFile, lpOperation, cmd );
     1010
     1011  if (retval > 32)  /* Found */
     1012  {
     1013    if (lpParameters)
    10011014    {
    1002         if (lpParameters)
    1003         {
    1004             strcat(cmd," ");
    1005             strcat(cmd,lpParameters);
    1006         }
    1007 
    1008         dprintf(("starting %s\n",cmd));
    1009         retval = WinExec( cmd, iShowCmd );
    1010     }
    1011     else if(PathIsURLA((LPSTR)lpFile))    /* File not found, check for URL */
     1015      strcat(cmd," ");
     1016      strcat(cmd,lpParameters);
     1017    }
     1018
     1019    dprintf(("starting %s\n",cmd));
     1020    retval = WinExec( cmd, iShowCmd );
     1021  }
     1022  else
     1023  {
     1024    // - path might be an URL
     1025    // - argument might be associated with some class / app
     1026
     1027    // 2002-02-26 PH
     1028    // File Extension Association is missing. We'd have to lookup
     1029    // i. e. ".doc" and create the command.
     1030    // @@@PH
     1031
     1032    // build lookup key
     1033    char lpstrShellSubkey[256] = "\\shell\\";
     1034    /* Looking for ...protocol\shell\lpOperation\command */
     1035    strcat( lpstrShellSubkey, lpOperation );
     1036    strcat( lpstrShellSubkey, "\\command" );
     1037
     1038    // First, check for URL association
     1039    if(PathIsURLA((LPSTR)lpFile))    /* File not found, check for URL */
    10121040    {
    1013       char lpstrProtocol[256];
    1014       LONG cmdlen = 512;
    10151041      LPSTR lpstrRes;
    10161042      INT iSize;
    10171043
    10181044      lpstrRes = strchr(lpFile,':');
    1019       iSize = lpstrRes - lpFile;
    1020 
    1021       /* Looking for ...protocol\shell\lpOperation\command */
    1022       strncpy(lpstrProtocol,lpFile,iSize);
    1023       lpstrProtocol[iSize]='\0';
    1024       strcat( lpstrProtocol, "\\shell\\" );
    1025       strcat( lpstrProtocol, lpOperation );
    1026       strcat( lpstrProtocol, "\\command" );
    1027 
    1028       /* Remove File Protocol from lpFile */
    1029       /* In the case file://path/file     */
    1030       if(!strnicmp(lpFile,"file",iSize))
     1045      if (NULL != lpstrRes)
    10311046      {
    1032         lpFile += iSize;
    1033         while(*lpFile == ':') lpFile++;
    1034       }
    1035 
    1036 
    1037       /* Get the application for the protocol and execute it */
    1038       if (RegQueryValueA( HKEY_CLASSES_ROOT, lpstrProtocol, cmd,
     1047        char szProtocol[256];
     1048       
     1049        iSize = lpstrRes - lpFile;
     1050 
     1051        strncpy(szProtocol,
     1052                lpFile,
     1053                min( sizeof( szProtocol ), iSize) );
     1054 
     1055        /* Remove File Protocol from lpFile */
     1056        /* In the case file://path/file     */
     1057        if(!strnicmp(lpFile,"file",iSize))
     1058        {
     1059          lpFile += iSize;
     1060          while(*lpFile == ':') lpFile++;
     1061        }
     1062 
     1063        /* Get the application for the protocol and execute it */
     1064        if (RegQueryValueA(HKEY_CLASSES_ROOT,
     1065                           szProtocol,
     1066                           cmd,
    10391067                           &cmdlen ) == ERROR_SUCCESS )
    1040       {
    1041           LPSTR tok;
     1068        {
    10421069          LPSTR tmp;
    10431070          char param[256] = "";
    10441071          LONG paramlen = 256;
    1045 
     1072 
    10461073          /* Get the parameters needed by the application
    10471074             from the associated ddeexec key */
    1048           tmp = strstr(lpstrProtocol,"command");
     1075          tmp = strstr(szProtocol,"command");
    10491076          tmp[0] = '\0';
    1050           strcat(lpstrProtocol,"ddeexec");
    1051 
    1052           if(RegQueryValueA( HKEY_CLASSES_ROOT, lpstrProtocol, param,&paramlen ) == ERROR_SUCCESS)
     1077          strcat(szProtocol,"ddeexec");
     1078 
     1079          if(RegQueryValueA(HKEY_CLASSES_ROOT,
     1080                            szProtocol,
     1081                            param,
     1082                            &paramlen ) == ERROR_SUCCESS)
    10531083          {
    10541084            strcat(cmd," ");
     
    10561086            cmdlen += paramlen;
    10571087          }
    1058 
    1059           /* Is there a replace() function anywhere? */
    1060           cmd[cmdlen]='\0';
    1061           tok=strstr( cmd, "%1" );
    1062           if (tok != NULL)
     1088        }
     1089      }
     1090    }
     1091
     1092
     1093    // Second, check for filename extension association
     1094    if (0 == cmd[0])
     1095    {
     1096      LPSTR lpstrRDot = strrchr(lpFile, '.');
     1097      if (NULL != lpstrRDot)
     1098      {
     1099        char szAssociation[256];
     1100        LONG lAssociationLen = sizeof( szAssociation );
     1101
     1102        // lookup associated application (or COM object) for
     1103        // this extension
     1104        if (RegQueryValueA(HKEY_CLASSES_ROOT,
     1105                           lpstrRDot,
     1106                           szAssociation,
     1107                           &lAssociationLen) == ERROR_SUCCESS)
     1108        {
     1109          // append the shell subkey
     1110          strcat(szAssociation, lpstrShellSubkey);
     1111          lAssociationLen = sizeof( szAssociation );
     1112
     1113          // lookup application for retrieved association
     1114          if (RegQueryValueA(HKEY_CLASSES_ROOT,
     1115                             szAssociation,
     1116                             cmd,
     1117                             &cmdlen) == ERROR_SUCCESS)
    10631118          {
    1064             tok[0]='\0'; /* truncate string at the percent */
    1065             strcat( cmd, lpFile ); /* what if no dir in xlpFile? */
    1066             tok=strstr( cmd, "%1" );
    1067             if ((tok!=NULL) && (strlen(tok)>2))
    1068             {
    1069               strcat( cmd, &tok[2] );
    1070             }
    1071           }
    1072 
    1073           retval = WinExec( cmd, iShowCmd );
     1119            // received cmd now
     1120          }
     1121        }
    10741122      }
    10751123    }
    1076     /* Check if file specified is in the form www.??????.*** */
    1077     else if(!strnicmp(lpFile,"www",3))
     1124     
     1125     
     1126#ifdef __WIN32OS2__
     1127    if (0 == cmd[0])
    10781128    {
    1079       /* if so, append lpFile http:// and call ShellExecute */
    1080       char lpstrTmpFile[256] = "http://" ;
    1081       strcat(lpstrTmpFile,lpFile);
    1082       retval = ShellExecuteA(hWnd,lpOperation,lpstrTmpFile,NULL,NULL,0);
    1083     }
     1129      // OS/2 specific addon:
     1130      // if no windows association is found, pass on to the workplace shell
     1131      // eventually.
     1132      retval = ShellExecuteOS2(hWnd,
     1133                               lpOperation,
     1134                               lpFile,
     1135                               lpParameters,
     1136                               lpDirectory,
     1137                               iShowCmd);
     1138    }
     1139#endif
     1140
     1141    if (0 != cmd[0])
     1142    {
     1143      // resolve the parameters
     1144      // @@@PH 2002-02-26 there might be more than one parameter only
     1145      /* Is there a replace() function anywhere? */
     1146      tok=strstr( cmd, "%1" );
     1147      if (tok != NULL)
     1148      {
     1149        tok[0]='\0'; /* truncate string at the percent */
     1150        strcat( cmd, lpFile ); /* what if no dir in xlpFile? */
     1151        tok=strstr( cmd, "%1" );
     1152        if ((tok!=NULL) && (strlen(tok)>2))
     1153        {
     1154          strcat( cmd, &tok[2] );
     1155        }
     1156      }
     1157    }
     1158
    10841159    /* Nothing was done yet, try to execute the cmdline directly,
    1085        maybe it's an OS/2 program */
    1086     else
     1160     maybe it's an OS/2 program */
     1161    if (0 == cmd[0])
    10871162    {
    10881163      strcpy(cmd,lpFile);
    10891164      strcat(cmd,lpParameters ? lpParameters : "");
    1090       retval = WinExec( cmd, iShowCmd );
    1091     }
    1092 
    1093     if (lpDirectory)
    1094       SetCurrentDirectoryA( old_dir );
    1095     return retval;
     1165    }
     1166     
     1167    // now launch ... something :)
     1168    retval = WinExec( cmd, iShowCmd );
     1169  }
     1170
     1171  if (lpDirectory)
     1172    SetCurrentDirectoryA( old_dir );
     1173 
     1174  return retval;
    10961175}
    10971176
Note: See TracChangeset for help on using the changeset viewer.