| 1 | /*
 | 
|---|
| 2 |  * (C) Chris Wohlgemuth 2002-2004
 | 
|---|
| 3 |  *
 | 
|---|
| 4 |  */
 | 
|---|
| 5 | /*
 | 
|---|
| 6 |  * This program is free software; you can redistribute it and/or modify
 | 
|---|
| 7 |  * it under the terms of the GNU General Public License as published by
 | 
|---|
| 8 |  * the Free Software Foundation; either version 2, or (at your option)
 | 
|---|
| 9 |  * any later version.
 | 
|---|
| 10 |  *
 | 
|---|
| 11 |  * This program is distributed in the hope that it will be useful,
 | 
|---|
| 12 |  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
|---|
| 13 |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
|---|
| 14 |  * GNU General Public License for more details.
 | 
|---|
| 15 |  *
 | 
|---|
| 16 |  * You should have received a copy of the GNU General Public License
 | 
|---|
| 17 |  * along with this program; see the file COPYING.  If not, write to
 | 
|---|
| 18 |  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 | 
|---|
| 19 |  */
 | 
|---|
| 20 | /*
 | 
|---|
| 21 |  * If you need another license for your project/product contact me at
 | 
|---|
| 22 |  * 
 | 
|---|
| 23 |  * http://www.os2world.com/cdwriting
 | 
|---|
| 24 |  * http://www.geocities.com/SiliconValley/Sector/5785/
 | 
|---|
| 25 |  */
 | 
|---|
| 26 | 
 | 
|---|
| 27 | /*
 | 
|---|
| 28 |  *  This file was generated by the SOM Compiler and Emitter Framework.
 | 
|---|
| 29 |  *  Generated using: 
 | 
|---|
| 30 |  *      SOM Emitter emitctm: 2.42
 | 
|---|
| 31 |  */
 | 
|---|
| 32 | 
 | 
|---|
| 33 | #ifndef SOM_Module_cwavi_Source
 | 
|---|
| 34 | #define SOM_Module_cwavi_Source
 | 
|---|
| 35 | #endif
 | 
|---|
| 36 | #define CWAVI_Class_Source
 | 
|---|
| 37 | #define M_CWAVI_Class_Source
 | 
|---|
| 38 | 
 | 
|---|
| 39 | #define INCL_DOSFILEMGR
 | 
|---|
| 40 | #define INCL_DOSMISC
 | 
|---|
| 41 | #define INCL_PM
 | 
|---|
| 42 | #include <os2.h>
 | 
|---|
| 43 | #include <stdarg.h> 
 | 
|---|
| 44 | #include <stdio.h>
 | 
|---|
| 45 | #include "helpid.h"
 | 
|---|
| 46 | #include "cwavi.ih"
 | 
|---|
| 47 | 
 | 
|---|
| 48 | extern char chrHelpLibrary[CCHMAXPATH];
 | 
|---|
| 49 | 
 | 
|---|
| 50 | HMODULE queryResModuleHandle(void);
 | 
|---|
| 51 | HMODULE queryModuleHandle(void);
 | 
|---|
| 52 | BOOL getMessage(char* text,ULONG ulID, LONG lSizeText, HMODULE hResource,HWND hwnd);
 | 
|---|
| 53 | ULONG launchPMProg(PSZ pszTitle, PSZ wrapperExe, PSZ parameters,  CWMMDataFile *thisPtr, ULONG ulView);
 | 
|---|
| 54 | void writeLog(const char* chrFormat, ...);
 | 
|---|
| 55 | 
 | 
|---|
| 56 | /*
 | 
|---|
| 57 |  * SOM_Scope HWND  SOMLINK cwavi_wpOpen(CWAVI *somSelf, HWND hwndCnr, 
 | 
|---|
| 58 |  *                                      ULONG ulView, ULONG param)
 | 
|---|
| 59 |  */
 | 
|---|
| 60 | 
 | 
|---|
| 61 | /*
 | 
|---|
| 62 |  * The prototype for cwavi_wpOpen was replaced by the following prototype:
 | 
|---|
| 63 |  */
 | 
|---|
| 64 | SOM_Scope HWND  SOMLINK cwavi_wpOpen(MMAVI *somSelf, HWND hwndCnr, 
 | 
|---|
| 65 |                                      ULONG ulView, ULONG param)
 | 
|---|
| 66 | {
 | 
|---|
| 67 |     /* CWAVIData *somThis = CWAVIGetData(somSelf); */
 | 
|---|
| 68 |     MMAVIMethodDebug("MMAVI","cwavi_wpOpen");
 | 
|---|
| 69 | 
 | 
|---|
| 70 |     switch(ulView)
 | 
|---|
| 71 |       {
 | 
|---|
| 72 |       case ID_MENU_START:
 | 
|---|
| 73 |       case ID_MENU_PLAYER:
 | 
|---|
| 74 |         /*case 0xbbe5:   Player */
 | 
|---|
| 75 |         {
 | 
|---|
| 76 |           char chrPlayer[CCHMAXPATH]={0};
 | 
|---|
| 77 |           char chrParams[(CCHMAXPATH*2)+2]="\"";
 | 
|---|
| 78 |           char chrTempParams[(CCHMAXPATH*2)+2]={0};
 | 
|---|
| 79 |           char chrTitle[50];
 | 
|---|
| 80 |           char *chrPtr=chrParams;
 | 
|---|
| 81 |           ULONG ulSize;
 | 
|---|
| 82 |           ULONG ulRc = 0;
 | 
|---|
| 83 |           char szFullFilename[CCHMAXPATH]={0};
 | 
|---|
| 84 |           BOOL ffplay=FALSE;
 | 
|---|
| 85 |           BOOL found=FALSE;
 | 
|---|
| 86 | 
 | 
|---|
| 87 |           chrPtr++;
 | 
|---|
| 88 |           ulSize=sizeof(chrParams)-2;
 | 
|---|
| 89 |           _wpQueryRealName(somSelf, chrPtr, &ulSize, TRUE);
 | 
|---|
| 90 |           strcat(chrPtr,"\"");
 | 
|---|
| 91 |           strcpy(chrTempParams, chrParams);
 | 
|---|
| 92 |           ulSize=PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
 | 
|---|
| 93 |           if(ulSize && strstr(strlwr(chrTempParams), ".avi")) {
 | 
|---|
| 94 |             if(!PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "aviplayer", NULLHANDLE, chrPlayer,
 | 
|---|
| 95 |                                       sizeof(chrPlayer)))
 | 
|---|
| 96 |               PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "vb", "vb.exe", chrPlayer,
 | 
|---|
| 97 |                                     sizeof(chrPlayer));
 | 
|---|
| 98 |           }
 | 
|---|
| 99 |           else {
 | 
|---|
| 100 |             ULONG ulLength = PrfQueryProfileString(HINI_USERPROFILE, "CWMM", "mvidplayer", NULLHANDLE, chrPlayer,
 | 
|---|
| 101 |                                   sizeof(chrPlayer));
 | 
|---|
| 102 |             if((ulLength == 0) || (!strchr(chrPlayer, ":") && (!strstr(strlwr(chrPlayer), "smplayer") &&
 | 
|---|
| 103 |                                                                strstr(strlwr(chrPlayer), "mplayer")))) {
 | 
|---|
| 104 |               char tempFilePath[CCHMAXPATH];
 | 
|---|
| 105 |               char newPath[2048];
 | 
|---|
| 106 |               char *path;
 | 
|---|
| 107 | 
 | 
|---|
| 108 |               //Prevent us from getting the mplayer.exe in the winos2 directory
 | 
|---|
| 109 |               path=getenv("PATH");
 | 
|---|
| 110 |               strcpy(newPath, path);
 | 
|---|
| 111 |               chrPtr=strstr(strlwr(newPath), ":\\os2\\mdos\\winos2");
 | 
|---|
| 112 |               if(chrPtr)
 | 
|---|
| 113 |                 strcpy(chrPtr - 1, chrPtr + 18);
 | 
|---|
| 114 |               path = strtok(newPath, ";");
 | 
|---|
| 115 |               while(path != NULL) {
 | 
|---|
| 116 |                 strcpy(tempFilePath, path);
 | 
|---|
| 117 |                 strcat(tempFilePath, "\\mplayer.exe");
 | 
|---|
| 118 |                 if(!DosQueryPathInfo(tempFilePath, FIL_STANDARD, (PVOID)szFullFilename, (ULONG)CCHMAXPATH-1)) {
 | 
|---|
| 119 |                   strcpy(chrPlayer, tempFilePath);
 | 
|---|
| 120 |                   found=TRUE;
 | 
|---|
| 121 |                   break;
 | 
|---|
| 122 |                 }
 | 
|---|
| 123 |                 path = strtok(NULL, ";");
 | 
|---|
| 124 |               }
 | 
|---|
| 125 |             }
 | 
|---|
| 126 |             if(!ulLength && !found &&
 | 
|---|
| 127 |                !DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY, "PATH",
 | 
|---|
| 128 |                               "smplayer.exe", (PBYTE) szFullFilename, CCHMAXPATH - 1)){
 | 
|---|
| 129 |               found=TRUE;
 | 
|---|
| 130 |               strcpy(chrPlayer, szFullFilename);
 | 
|---|
| 131 |             }
 | 
|---|
| 132 |             if(!ulLength && !found &&
 | 
|---|
| 133 |                !DosSearchPath(SEARCH_IGNORENETERRS | SEARCH_ENVIRONMENT | SEARCH_CUR_DIRECTORY, "PATH",
 | 
|---|
| 134 |                                                      "ffplay.exe", (PBYTE) szFullFilename, CCHMAXPATH - 1)) {
 | 
|---|
| 135 |               found=TRUE;
 | 
|---|
| 136 |               strcpy(chrPlayer, szFullFilename);
 | 
|---|
| 137 |             }
 | 
|---|
| 138 |             if(!ulLength && !found)  {
 | 
|---|
| 139 |               char text[300];
 | 
|---|
| 140 |               sprintf(text, "No suitable video player could be found. Please install ffplay (part of ffmpeg)"\
 | 
|---|
| 141 |                       "or smplayer/mplayer somewhere in your path or in OS2.INI add the key mvidplayer"\
 | 
|---|
| 142 |                       "under CWMM application containing the full path to an appropriate video player");
 | 
|---|
| 143 |   
 | 
|---|
| 144 |               WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "Missing video player",
 | 
|---|
| 145 |                             1234, MB_OK|MB_MOVEABLE);
 | 
|---|
| 146 |               return NULLHANDLE;
 | 
|---|
| 147 |            }
 | 
|---|
| 148 |           }
 | 
|---|
| 149 |           /* Eliminate the noise with mplayer and ffplay and get them to close gracefully*/
 | 
|---|
| 150 |           if(strstr(strlwr(chrPlayer), "ffplay"))
 | 
|---|
| 151 |             ffplay = TRUE;
 | 
|---|
| 152 |           if((!strstr(strlwr(chrPlayer), "smplayer") && strstr(strlwr(chrPlayer), "mplayer")) || ffplay) {
 | 
|---|
| 153 |             strcpy(chrTempParams, " /c \"");
 | 
|---|
| 154 |             strcat(chrTempParams, chrPlayer);
 | 
|---|
| 155 |             strcat(chrTempParams, " ");
 | 
|---|
| 156 |             if(ffplay)
 | 
|---|
| 157 |               strcat(chrTempParams, "-autoexit ");
 | 
|---|
| 158 |             strcat(chrTempParams, chrParams);
 | 
|---|
| 159 |             strcat(chrTempParams, "\"");
 | 
|---|
| 160 |             strcpy(chrParams, chrTempParams);
 | 
|---|
| 161 |             strcpy(chrPlayer, "CMD.EXE");
 | 
|---|
| 162 |           }
 | 
|---|
| 163 |           /* Get the Title for the window list */
 | 
|---|
| 164 |           if(!getMessage(chrTitle, IDSTR_VIDPLAYERTITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
 | 
|---|
| 165 |             strcpy(chrTitle, "Player");
 | 
|---|
| 166 | 
 | 
|---|
| 167 |           if((ulRc=launchPMProg(chrTitle, chrPlayer, chrParams, somSelf, ulView))==NULLHANDLE) {
 | 
|---|
| 168 |             break;
 | 
|---|
| 169 |           }
 | 
|---|
| 170 |           return NULLHANDLE;
 | 
|---|
| 171 |         }
 | 
|---|
| 172 |       default:
 | 
|---|
| 173 |         break;
 | 
|---|
| 174 |       }
 | 
|---|
| 175 |     return (MMAVI_parent_MMVideo_wpOpen(somSelf, hwndCnr, ulView, param));
 | 
|---|
| 176 | }
 | 
|---|
| 177 | 
 | 
|---|
| 178 | 
 | 
|---|
| 179 | 
 | 
|---|
| 180 | /*
 | 
|---|
| 181 |  * SOM_Scope PSZ  SOMLINK cwaviM_wpclsQueryTitle(M_CWAVI *somSelf)
 | 
|---|
| 182 |  */
 | 
|---|
| 183 | 
 | 
|---|
| 184 | /*
 | 
|---|
| 185 |  * The prototype for cwaviM_wpclsQueryTitle was replaced by the following prototype:
 | 
|---|
| 186 |  */
 | 
|---|
| 187 | SOM_Scope PSZ  SOMLINK cwaviM_wpclsQueryTitle(M_MMAVI *somSelf)
 | 
|---|
| 188 | {
 | 
|---|
| 189 |   static char chrTitle[20]={0};
 | 
|---|
| 190 |     /* M_CWAVIData *somThis = M_CWAVIGetData(somSelf); */
 | 
|---|
| 191 |     M_MMAVIMethodDebug("M_MMAVI","cwaviM_wpclsQueryTitle");
 | 
|---|
| 192 | 
 | 
|---|
| 193 |     if(chrTitle[0]==0)
 | 
|---|
| 194 |       if(!getMessage(chrTitle, IDSTR_AVITITLE, sizeof(chrTitle), queryResModuleHandle(), HWND_DESKTOP))
 | 
|---|
| 195 |         strcpy(chrTitle,"AVIVideo.AVI");
 | 
|---|
| 196 |     return chrTitle;
 | 
|---|
| 197 | }
 | 
|---|
| 198 | 
 | 
|---|
| 199 | 
 | 
|---|
| 200 | 
 | 
|---|
| 201 | /*
 | 
|---|
| 202 |  * SOM_Scope PSZ  SOMLINK cwaviM_wpclsQueryInstanceType(M_CWAVI *somSelf)
 | 
|---|
| 203 |  */
 | 
|---|
| 204 | 
 | 
|---|
| 205 | /*
 | 
|---|
| 206 |  * The prototype for cwaviM_wpclsQueryInstanceType was replaced by the following prototype:
 | 
|---|
| 207 |  */
 | 
|---|
| 208 | SOM_Scope PSZ  SOMLINK cwaviM_wpclsQueryInstanceType(M_MMAVI *somSelf)
 | 
|---|
| 209 | {
 | 
|---|
| 210 |     ULONG ulSize;
 | 
|---|
| 211 | 
 | 
|---|
| 212 |     /* M_CWAVIData *somThis = M_CWAVIGetData(somSelf); */
 | 
|---|
| 213 |     M_MMAVIMethodDebug("M_MMAVI","cwaviM_wpclsQueryInstanceType");
 | 
|---|
| 214 | 
 | 
|---|
| 215 |     ulSize = PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
 | 
|---|
| 216 |     if(ulSize)
 | 
|---|
| 217 |       return "AVI";
 | 
|---|
| 218 |     else
 | 
|---|
| 219 |     return "AVI/FLV/3GP/M4V/MKV/MOV/MP4/MPEG/MTS/VOB/WMV/WEBM";
 | 
|---|
| 220 | }
 | 
|---|
| 221 | 
 | 
|---|
| 222 | 
 | 
|---|
| 223 | /*
 | 
|---|
| 224 |  * SOM_Scope PSZ  SOMLINK cwaviM_wpclsQueryInstanceFilter(M_CWAVI *somSelf)
 | 
|---|
| 225 |  */
 | 
|---|
| 226 | 
 | 
|---|
| 227 | /*
 | 
|---|
| 228 |  * The prototype for cwaviM_wpclsQueryInstanceFilter was replaced by the following prototype:
 | 
|---|
| 229 |  */
 | 
|---|
| 230 | SOM_Scope PSZ  SOMLINK cwaviM_wpclsQueryInstanceFilter(M_MMAVI *somSelf)
 | 
|---|
| 231 | {
 | 
|---|
| 232 |     ULONG ulSize;
 | 
|---|
| 233 | 
 | 
|---|
| 234 |     /* M_CWAVIData *somThis = M_CWAVIGetData(somSelf); */
 | 
|---|
| 235 |     M_MMAVIMethodDebug("M_MMAVI","cwaviM_wpclsQueryInstanceFilter");
 | 
|---|
| 236 | 
 | 
|---|
| 237 |     ulSize=PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
 | 
|---|
| 238 |     if(ulSize)
 | 
|---|
| 239 |       return "*.AVI";
 | 
|---|
| 240 |     else
 | 
|---|
| 241 |       return "*.AVI,*.FLI,*.FLC,*.FLV,*.3GP,*.M4V,*.MKV,*.MOV,*.MP4,*.MPEG,*.MTS,*.VOB,*.WMV,*.WEBM";
 | 
|---|
| 242 | }
 | 
|---|
| 243 | 
 | 
|---|
| 244 | 
 | 
|---|
| 245 | /*
 | 
|---|
| 246 |  * SOM_Scope ULONG  SOMLINK cwaviM_wpclsQueryIconData(M_CWAVI *somSelf, 
 | 
|---|
| 247 |  *                                                    PICONINFO pIconInfo)
 | 
|---|
| 248 |  */
 | 
|---|
| 249 | 
 | 
|---|
| 250 | /*
 | 
|---|
| 251 |  * The prototype for cwaviM_wpclsQueryIconData was replaced by the following prototype:
 | 
|---|
| 252 |  */
 | 
|---|
| 253 | SOM_Scope ULONG  SOMLINK cwaviM_wpclsQueryIconData(M_MMAVI *somSelf, 
 | 
|---|
| 254 |                                                    PICONINFO pIconInfo)
 | 
|---|
| 255 | {
 | 
|---|
| 256 |   HMODULE hmod;
 | 
|---|
| 257 |     /* M_CWAVIData *somThis = M_CWAVIGetData(somSelf); */
 | 
|---|
| 258 |     M_MMAVIMethodDebug("M_MMAVI","cwaviM_wpclsQueryIconData");
 | 
|---|
| 259 | 
 | 
|---|
| 260 |     hmod=queryModuleHandle();
 | 
|---|
| 261 |     if(!hmod)
 | 
|---|
| 262 |       return M_MMAVI_parent_M_MMVideo_wpclsQueryIconData(somSelf, pIconInfo);
 | 
|---|
| 263 | 
 | 
|---|
| 264 |     if(pIconInfo)   {
 | 
|---|
| 265 |       ULONG ulSize=PrfQueryProfileInt(HINI_USERPROFILE, "CWMM", "nomodvid", 0);
 | 
|---|
| 266 |       pIconInfo->fFormat = ICON_RESOURCE;
 | 
|---|
| 267 |       pIconInfo->hmod    = hmod;
 | 
|---|
| 268 |       if(ulSize)
 | 
|---|
| 269 |         pIconInfo->resid   = ID_ICONAVIFILE;
 | 
|---|
| 270 |       else
 | 
|---|
| 271 |         pIconInfo->resid   = ID_ICONCWVIDEOFILE;
 | 
|---|
| 272 |     } /* endif */
 | 
|---|
| 273 | 
 | 
|---|
| 274 |         return ( sizeof(ICONINFO) );
 | 
|---|
| 275 | }
 | 
|---|
| 276 | 
 | 
|---|
| 277 | 
 | 
|---|
| 278 | 
 | 
|---|
| 279 | /*
 | 
|---|
| 280 |  * SOM_Scope BOOL  SOMLINK cwaviM_wpclsQueryDefaultHelp(M_CWAVI *somSelf, 
 | 
|---|
| 281 |  *                                                      PULONG pHelpPanelId, 
 | 
|---|
| 282 |  *                                                      PSZ pszHelpLibrary)
 | 
|---|
| 283 |  */
 | 
|---|
| 284 | 
 | 
|---|
| 285 | /*
 | 
|---|
| 286 |  * The prototype for cwaviM_wpclsQueryDefaultHelp was replaced by the following prototype:
 | 
|---|
| 287 |  */
 | 
|---|
| 288 | SOM_Scope BOOL  SOMLINK cwaviM_wpclsQueryDefaultHelp(M_MMAVI *somSelf, 
 | 
|---|
| 289 |                                                      PULONG pHelpPanelId, 
 | 
|---|
| 290 |                                                      PSZ pszHelpLibrary)
 | 
|---|
| 291 | {
 | 
|---|
| 292 |     /* M_CWAVIData *somThis = M_CWAVIGetData(somSelf); */
 | 
|---|
| 293 |     M_MMAVIMethodDebug("M_MMAVI","cwaviM_wpclsQueryDefaultHelp");
 | 
|---|
| 294 | 
 | 
|---|
| 295 |     if(pHelpPanelId)
 | 
|---|
| 296 |       *pHelpPanelId=AVIFILE_HELP_PANEL;
 | 
|---|
| 297 |     if(pszHelpLibrary)
 | 
|---|
| 298 |       strncpy(pszHelpLibrary, chrHelpLibrary, CCHMAXPATH);
 | 
|---|
| 299 |     return TRUE; 
 | 
|---|
| 300 | }
 | 
|---|
| 301 | 
 | 
|---|