[92] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: defview.c 92 2004-05-21 15:16:36Z root $
|
---|
| 5 |
|
---|
| 6 | Copyright (c) 1993-98 M. Kimes
|
---|
| 7 | Copyright (c) 2003 Steven H.Levine
|
---|
| 8 |
|
---|
| 9 | Archive containers
|
---|
| 10 |
|
---|
| 11 | Revisions 20 Nov 03 SHL - ShowMultimedia: try to convince fmplay to not play exes (Gregg Young)
|
---|
| 12 |
|
---|
| 13 | ***********************************************************************/
|
---|
| 14 |
|
---|
[2] | 15 | #define INCL_DOS
|
---|
| 16 | #define INCL_WIN
|
---|
| 17 | #define INCL_GPI
|
---|
| 18 | #define INCL_MMIOOS2
|
---|
| 19 |
|
---|
| 20 | #include <os2.h>
|
---|
| 21 | #include <os2me.h>
|
---|
| 22 | #include <stdio.h>
|
---|
| 23 | #include <stdlib.h>
|
---|
| 24 | #include <string.h>
|
---|
| 25 | #include <ctype.h>
|
---|
| 26 | #include "fm3dll.h"
|
---|
| 27 | #include "fm3dlg.h"
|
---|
| 28 |
|
---|
| 29 | #pragma alloc_text(DEFVIEW,DefaultView,ShowMultimedia,DefaultViewKeys)
|
---|
| 30 |
|
---|
| 31 |
|
---|
[92] | 32 | BOOL ShowMultimedia (CHAR *filename)
|
---|
| 33 | {
|
---|
[2] | 34 |
|
---|
[92] | 35 | static BOOL no_mmos2 = FALSE;
|
---|
| 36 | BOOL played = FALSE;
|
---|
[2] | 37 | CHAR loaderror[CCHMAXPATH];
|
---|
[92] | 38 | HMODULE MMIOModHandle = NULLHANDLE;
|
---|
| 39 | PMMIOIDENTIFYFILE pMMIOIdentifyFile = NULL;
|
---|
| 40 | FOURCC fccStorageSystem = 0;
|
---|
[2] | 41 | MMFORMATINFO mmFormatInfo;
|
---|
| 42 | APIRET rc;
|
---|
| 43 |
|
---|
[92] | 44 | if (no_mmos2 ||
|
---|
| 45 | !filename ||
|
---|
| 46 | !*filename)
|
---|
| 47 | return played;
|
---|
[2] | 48 |
|
---|
| 49 | /* load MMPM/2, if available. */
|
---|
| 50 | *loaderror = 0;
|
---|
| 51 | rc = DosLoadModule(loaderror,
|
---|
[92] | 52 | sizeof(loaderror),
|
---|
| 53 | "MMIO",
|
---|
| 54 | &MMIOModHandle);
|
---|
| 55 | if (rc) {
|
---|
| 56 | no_mmos2 = TRUE;
|
---|
| 57 | return played;
|
---|
[2] | 58 | }
|
---|
| 59 | else {
|
---|
[92] | 60 | if (DosQueryProcAddr(MMIOModHandle,
|
---|
| 61 | 0,
|
---|
| 62 | "mmioIdentifyFile",
|
---|
| 63 | (PFN *)&pMMIOIdentifyFile)) {
|
---|
[2] | 64 | DosFreeModule(MMIOModHandle);
|
---|
[92] | 65 | no_mmos2 = TRUE;
|
---|
| 66 | return played;
|
---|
[2] | 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | /* attempt to identify the file using MMPM/2 */
|
---|
| 71 | memset(&mmFormatInfo,0,sizeof(MMFORMATINFO));
|
---|
| 72 | mmFormatInfo.ulStructLen = sizeof(MMFORMATINFO);
|
---|
[92] | 73 | rc = pMMIOIdentifyFile(filename,
|
---|
| 74 | 0L,
|
---|
| 75 | &mmFormatInfo,
|
---|
| 76 | &fccStorageSystem,
|
---|
| 77 | 0L,
|
---|
| 78 | MMIO_FORCE_IDENTIFY_FF);
|
---|
[2] | 79 | /* free module handle */
|
---|
| 80 | DosFreeModule(MMIOModHandle);
|
---|
| 81 |
|
---|
[92] | 82 | /* if identified and not FOURCC_DOS */
|
---|
| 83 | if (!rc &&
|
---|
| 84 | mmFormatInfo.fccIOProc != FOURCC_DOS) {
|
---|
| 85 | if (mmFormatInfo.ulMediaType == MMIO_MEDIATYPE_IMAGE &&
|
---|
| 86 | (mmFormatInfo.ulFlags & MMIO_CANREADTRANSLATED)) {
|
---|
| 87 | /* is an image that can be translated */
|
---|
[2] | 88 | runemf2(SEPARATE | WINDOWED,
|
---|
[92] | 89 | HWND_DESKTOP,
|
---|
| 90 | NULL,
|
---|
| 91 | NULL,
|
---|
| 92 | "%sIMAGE.EXE \"%s\"",
|
---|
| 93 | (fAddUtils) ? "UTILS\\" : NullStr,
|
---|
| 94 | filename);
|
---|
| 95 | played = TRUE;
|
---|
[2] | 96 | }
|
---|
[92] | 97 | else if (mmFormatInfo.ulMediaType != MMIO_MEDIATYPE_IMAGE) {
|
---|
| 98 | /* is a multimedia file (WAV, MID, AVI, etc.) */
|
---|
| 99 | runemf2(SEPARATE | WINDOWED,
|
---|
| 100 | HWND_DESKTOP,
|
---|
| 101 | NULL,
|
---|
| 102 | NULL,
|
---|
| 103 | "%sFM2PLAY.EXE \"%s\"",
|
---|
| 104 | (fAddUtils) ? "UTILS\\" : NullStr,
|
---|
| 105 | filename);
|
---|
| 106 | played = TRUE;
|
---|
[2] | 107 | }
|
---|
| 108 | }
|
---|
| 109 |
|
---|
[92] | 110 | return played;
|
---|
[2] | 111 | }
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | VOID DefaultViewKeys (HWND hwnd,HWND hwndFrame,HWND hwndParent,
|
---|
[92] | 115 | SWP *swp,CHAR *filename) {
|
---|
[2] | 116 |
|
---|
| 117 | if((shiftstate & (KC_CTRL | KC_SHIFT)) ==
|
---|
| 118 | (KC_CTRL | KC_SHIFT))
|
---|
| 119 | DefaultView(hwnd,
|
---|
[92] | 120 | hwndFrame,
|
---|
| 121 | hwndParent,
|
---|
| 122 | swp,
|
---|
| 123 | 4,
|
---|
| 124 | filename);
|
---|
[2] | 125 | else if(shiftstate & KC_CTRL)
|
---|
| 126 | DefaultView(hwnd,
|
---|
[92] | 127 | hwndFrame,
|
---|
| 128 | hwndParent,
|
---|
| 129 | swp,
|
---|
| 130 | 2,
|
---|
| 131 | filename);
|
---|
[2] | 132 | else if(shiftstate & KC_SHIFT)
|
---|
| 133 | DefaultView(hwnd,
|
---|
[92] | 134 | hwndFrame,
|
---|
| 135 | hwndParent,
|
---|
| 136 | swp,
|
---|
| 137 | 1,
|
---|
| 138 | filename);
|
---|
[2] | 139 | else
|
---|
| 140 | DefaultView(hwnd,
|
---|
[92] | 141 | hwndFrame,
|
---|
| 142 | hwndParent,
|
---|
| 143 | swp,
|
---|
| 144 | 0,
|
---|
| 145 | filename);
|
---|
[2] | 146 | }
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | VOID DefaultView (HWND hwnd,HWND hwndFrame,HWND hwndParent,SWP *swp,
|
---|
[92] | 150 | ULONG flags,CHAR *filename) {
|
---|
[2] | 151 |
|
---|
| 152 | /*
|
---|
| 153 | * bitmapped flags:
|
---|
| 154 | * ---------------
|
---|
| 155 | * 1 = View directly
|
---|
| 156 | * 2 = Open WPS default view
|
---|
| 157 | * 4 = Open WPS settings view
|
---|
| 158 | * 8 = Edit
|
---|
| 159 | * 16 = Info
|
---|
| 160 | * 32 = No view info
|
---|
| 161 | */
|
---|
| 162 |
|
---|
| 163 | HWND hwndArc = (HWND)0;
|
---|
| 164 | char *p,*dummy[3];
|
---|
| 165 |
|
---|
| 166 | if(!hwndParent)
|
---|
| 167 | hwndParent = HWND_DESKTOP;
|
---|
| 168 |
|
---|
| 169 | if(flags & 32) {
|
---|
| 170 | flags &= (~16);
|
---|
| 171 | if(!IsFile(filename)) {
|
---|
| 172 | DosBeep(50,100);
|
---|
| 173 | return;
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | if(flags & 1) /* directly view the file */
|
---|
| 178 | goto ViewIt;
|
---|
| 179 |
|
---|
| 180 | if(flags & 2) { /* open default WPS view of file */
|
---|
| 181 | OpenObject(filename,
|
---|
[92] | 182 | Default,
|
---|
| 183 | hwnd);
|
---|
[2] | 184 | return;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | if(flags & 4) { /* open WPS settings notebook for file */
|
---|
| 188 | OpenObject(filename,
|
---|
[92] | 189 | Settings,
|
---|
| 190 | hwnd);
|
---|
[2] | 191 | return;
|
---|
| 192 | }
|
---|
| 193 |
|
---|
| 194 | if((flags & 16) ||
|
---|
| 195 | !IsFile(filename)) { /* open info for directories */
|
---|
| 196 |
|
---|
| 197 | char fullname[CCHMAXPATH];
|
---|
| 198 |
|
---|
| 199 | if(!IsFullName(filename)) {
|
---|
| 200 | if(!DosQueryPathInfo(filename,
|
---|
[92] | 201 | FIL_QUERYFULLNAME,
|
---|
| 202 | fullname,
|
---|
| 203 | sizeof(fullname)))
|
---|
| 204 | filename = fullname;
|
---|
[2] | 205 | }
|
---|
| 206 | if(IsFullName(filename) &&
|
---|
| 207 | !(driveflags[toupper(*filename) - 'A'] & DRIVE_INVALID)) {
|
---|
| 208 | if(!IsRoot(filename)) {
|
---|
[92] | 209 | dummy[0] = filename;
|
---|
| 210 | dummy[1] = NULL;
|
---|
| 211 | WinDlgBox(HWND_DESKTOP,
|
---|
| 212 | HWND_DESKTOP,
|
---|
| 213 | FileInfoProc,
|
---|
| 214 | FM3ModHandle,
|
---|
| 215 | FLE_FRAME,
|
---|
| 216 | (PVOID)dummy);
|
---|
[2] | 217 | }
|
---|
| 218 | else
|
---|
[92] | 219 | WinDlgBox(HWND_DESKTOP,
|
---|
| 220 | HWND_DESKTOP,
|
---|
| 221 | DrvInfoProc,
|
---|
| 222 | FM3ModHandle,
|
---|
| 223 | INFO_FRAME,
|
---|
| 224 | (PVOID)filename);
|
---|
[2] | 225 | }
|
---|
| 226 | return;
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | if(flags & 8) { /* edit file */
|
---|
| 230 |
|
---|
| 231 | ULONG type = IDM_EDITTEXT;
|
---|
| 232 |
|
---|
| 233 | dummy[0] = filename;
|
---|
| 234 | dummy[1] = NULL;
|
---|
| 235 | if(TestBinary(filename))
|
---|
| 236 | type = IDM_EDITBINARY;
|
---|
| 237 | switch(type) {
|
---|
| 238 | case IDM_EDITBINARY:
|
---|
[92] | 239 | if(*bined) {
|
---|
| 240 | ExecOnList((HWND)0,
|
---|
| 241 | bined,
|
---|
| 242 | WINDOWED | SEPARATE,
|
---|
| 243 | NULL,
|
---|
| 244 | dummy,
|
---|
| 245 | NULL);
|
---|
| 246 | break;
|
---|
| 247 | }
|
---|
[2] | 248 | /* else intentional fallthru */
|
---|
| 249 | case IDM_EDITTEXT:
|
---|
[92] | 250 | if(*editor)
|
---|
| 251 | ExecOnList((HWND)0,
|
---|
| 252 | editor,
|
---|
| 253 | WINDOWED | SEPARATE,
|
---|
| 254 | NULL,
|
---|
| 255 | dummy,
|
---|
| 256 | NULL);
|
---|
| 257 | else {
|
---|
| 258 | type = (type == IDM_EDITTEXT) ? 8 :
|
---|
| 259 | (type == IDM_EDITBINARY) ? 16 :
|
---|
| 260 | 0;
|
---|
| 261 | type |= 4;
|
---|
| 262 | StartMLEEditor(hwndParent,
|
---|
| 263 | type,
|
---|
| 264 | filename,
|
---|
| 265 | hwndFrame);
|
---|
| 266 | }
|
---|
| 267 | break;
|
---|
[2] | 268 | }
|
---|
| 269 | return;
|
---|
| 270 | }
|
---|
| 271 |
|
---|
| 272 | if(ExecAssociation(hwnd,
|
---|
[92] | 273 | filename) == -1) {
|
---|
[2] | 274 | hwndArc = StartArcCnr((fExternalArcboxes || !swp ||
|
---|
[92] | 275 | strcmp(realappname,FM3Str)) ?
|
---|
| 276 | HWND_DESKTOP :
|
---|
| 277 | hwndParent,
|
---|
| 278 | hwndFrame,
|
---|
| 279 | filename,
|
---|
| 280 | 4,
|
---|
| 281 | NULL);
|
---|
[2] | 282 | if(!hwndArc) {
|
---|
| 283 | if(!fCheckMM ||
|
---|
[92] | 284 | !ShowMultimedia(filename)) {
|
---|
| 285 | if(!IsExecutable(filename) ||
|
---|
| 286 | !ExecFile(hwnd,filename)) {
|
---|
| 287 | p = strrchr(filename,'.');
|
---|
| 288 | if(!p)
|
---|
| 289 | p = ".";
|
---|
| 290 | if(stricmp(p,".INI") ||
|
---|
| 291 | !StartIniEditor(hwndParent,
|
---|
| 292 | filename,
|
---|
| 293 | 4)) {
|
---|
| 294 | if(stricmp(p,".HLP") ||
|
---|
| 295 | !ViewHelp(filename)) {
|
---|
[2] | 296 | ViewIt:
|
---|
[92] | 297 | if(*viewer) {
|
---|
| 298 | dummy[0] = filename;
|
---|
| 299 | dummy[1] = NULL;
|
---|
| 300 | ExecOnList(hwnd,
|
---|
| 301 | viewer,
|
---|
| 302 | WINDOWED | SEPARATE |
|
---|
| 303 | ((fViewChild) ? CHILD : 0),
|
---|
| 304 | NULL,
|
---|
| 305 | dummy,
|
---|
| 306 | NULL);
|
---|
| 307 | }
|
---|
| 308 | else
|
---|
| 309 | StartMLEEditor(hwndParent,
|
---|
| 310 | 5,
|
---|
| 311 | filename,
|
---|
| 312 | hwndFrame);
|
---|
| 313 | }
|
---|
| 314 | }
|
---|
| 315 | }
|
---|
[2] | 316 | }
|
---|
| 317 | }
|
---|
| 318 | else {
|
---|
| 319 | if((swp &&
|
---|
[92] | 320 | !fExternalArcboxes &&
|
---|
| 321 | !strcmp(realappname,FM3Str)) &&
|
---|
| 322 | !ParentIsDesktop(hwnd,hwndParent))
|
---|
| 323 | WinSetWindowPos(hwndArc,
|
---|
| 324 | HWND_TOP,
|
---|
| 325 | swp->x,
|
---|
| 326 | swp->y,
|
---|
| 327 | swp->cx,
|
---|
| 328 | swp->cy,
|
---|
| 329 | SWP_MOVE | SWP_SIZE | SWP_SHOW |
|
---|
| 330 | SWP_ZORDER | SWP_ACTIVATE);
|
---|
[2] | 331 | }
|
---|
| 332 | }
|
---|
| 333 | }
|
---|
| 334 |
|
---|