Changeset 906 for trunk/dll/notebook.c


Ignore:
Timestamp:
Jan 6, 2008, 5:21:14 AM (18 years ago)
Author:
Gregg Young
Message:

The basic program quoting code and some mailto cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/notebook.c

    r898 r906  
    198198    PrfWriteProfileString(fmprof, appname, "DefArc", szDefArc);
    199199    {
    200       CHAR szBuf[CCHMAXPATH], buf[10] = "\"%-/";
     200      CHAR szBuf[CCHMAXPATH], *psz;
    201201
    202202      WinQueryDlgItemText(hwnd, CFGA_VIRUS, CCHMAXPATH, szBuf);
    203203      szBuf[CCHMAXPATH - 1] = 0;
     204      if (strcmp(szBuf, virus)){
     205        psz = CheckApp_QuoteAddExe(szBuf);
     206        memcpy(virus, psz, strlen(psz) + 1);
     207        if (!strchr(virus, '%') && strlen(virus) > 3)
     208          strcat(virus, " %p");
     209      }
     210      if (!*virus)
     211        strcpy(virus, "OS2SCAN.EXE %p /SUB /A");
     212      WinQueryDlgItemText(hwnd, CFGA_EXTRACTPATH, CCHMAXPATH, szBuf);
     213      szBuf[CCHMAXPATH - 1] = 0;
    204214      bstrip(szBuf);
    205       if (!strcspn(szBuf, buf))
    206         BldQuotedFileName(virus, szBuf);
    207       else
    208         memcpy(virus, szBuf, strlen(szBuf) + 1);
    209       if (!strchr(virus, '%') && strlen(virus) > 3)
    210         strcat(virus, " %p");
    211     }
    212     if (!*virus)
    213       strcpy(virus, "OS2SCAN.EXE %p /SUB /A");
    214     WinQueryDlgItemText(hwnd, CFGA_EXTRACTPATH, CCHMAXPATH, extractpath);
    215     extractpath[CCHMAXPATH - 1] = 0;
    216     bstrip(extractpath);
    217     if (*extractpath) {
    218       if (strcmp(extractpath, "*")) {
    219 
    220         MakeFullName(extractpath);
    221         if (IsFile(extractpath)) {
    222           ulResult = saymsg(MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON1, HWND_DESKTOP,
    223                             GetPString(IDS_WARNINGTEXT),
    224                             GetPString(IDS_EXTPATHNOTVALIDTEXT),
    225                             extractpath);
    226           if (ulResult == MBID_YES)
    227             *extractpath = 0;
    228           if (ulResult == MBID_CANCEL){
    229             WinDlgBox(HWND_DESKTOP,
    230                       hwnd, CfgDlgProc,
    231                       FM3ModHandle, CFG_FRAME,
    232                       (PVOID) "Archive");
    233             break;
     215
     216      if (strcmp(extractpath, szBuf)) {
     217        memcpy(extractpath, szBuf, strlen(szBuf) + 1);
     218        if (*extractpath){
     219          MakeFullName(extractpath);
     220          if (IsFile(extractpath)) {
     221            ulResult = saymsg(MB_YESNOCANCEL | MB_ICONQUESTION | MB_DEFBUTTON1, HWND_DESKTOP,
     222                              GetPString(IDS_WARNINGTEXT),
     223                              GetPString(IDS_EXTPATHNOTVALIDTEXT),
     224                              extractpath);
     225            if (ulResult == MBID_YES)
     226              *extractpath = 0;
     227            if (ulResult == MBID_CANCEL){
     228              WinDlgBox(HWND_DESKTOP,
     229                        hwnd, CfgDlgProc,
     230                        FM3ModHandle, CFG_FRAME,
     231                        MPFROMP("Archive"));
     232              break;
     233            }
    234234          }
    235         }
     235        }
    236236      }
    237237    }
     
    239239    PrfWriteProfileString(fmprof, appname, "ExtractPath", extractpath);
    240240    break;
     241  }
     242  if (fCancelAction){
     243    fCancelAction = FALSE;
     244    WinDlgBox(HWND_DESKTOP,
     245              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMP("Archive"));
    241246  }
    242247  return WinDefDlgProc(hwnd, msg, mp1, mp2);
     
    450455  case WM_CLOSE:
    451456    {
    452       CHAR szBuf[CCHMAXPATH], buf[10] = "\"%-/";
     457      CHAR szBuf[CCHMAXPATH], *psz;
    453458
    454459      WinQueryDlgItemText(hwnd, CFGV_VIEWER, CCHMAXPATH, szBuf);
    455460      szBuf[CCHMAXPATH - 1] = 0;
    456       bstrip(szBuf);
    457       if (!strcspn(szBuf, buf))
    458         BldQuotedFileName(viewer, szBuf);
    459       else
    460         memcpy(viewer, szBuf, strlen(szBuf) + 1);
    461       if (!strchr(viewer, '%') && strlen(viewer) > 3)
    462         strcat(viewer, " %a");
     461      if (strcmp(szBuf, viewer)){
     462        psz = CheckApp_QuoteAddExe(szBuf);
     463        memcpy(viewer, psz, strlen(psz) + 1);
     464        if (!strchr(viewer, '%') && strlen(viewer) > 3)
     465          strcat(viewer, " %a");
     466      }
    463467      WinQueryDlgItemText(hwnd, CFGV_EDITOR, CCHMAXPATH, szBuf);
    464468      szBuf[CCHMAXPATH - 1] = 0;
    465       bstrip(szBuf);
    466       if (!strcspn(szBuf, buf))
    467         BldQuotedFileName(editor, szBuf);
    468       else
    469         memcpy(editor, szBuf, strlen(szBuf) + 1);
    470       if (!strchr(editor, '%') && strlen(editor) > 3)
    471         strcat(editor, " %a");
     469      if (strcmp(szBuf, editor)){
     470        psz = CheckApp_QuoteAddExe(szBuf);
     471        memcpy(editor, psz, strlen(psz) + 1);
     472        if (!strchr(editor, '%') && strlen(editor) > 3)
     473          strcat(editor, " %a");
     474      }
    472475      WinQueryDlgItemText(hwnd, CFGV_BINVIEW, CCHMAXPATH, szBuf);
    473476      szBuf[CCHMAXPATH - 1] = 0;
    474       bstrip(szBuf);
    475       if (!strcspn(szBuf, buf))
    476         BldQuotedFileName(binview, szBuf);
    477       else
    478         memcpy(binview, szBuf, strlen(szBuf) + 1);
    479       if (!strchr(binview, '%') && strlen(binview) > 3)
    480         strcat(binview, " %a");
     477      if (strcmp(szBuf, binview)){
     478        psz = CheckApp_QuoteAddExe(szBuf);
     479        memcpy(binview, psz, strlen(psz) + 1);
     480        if (!strchr(binview, '%') && strlen(binview) > 3)
     481          strcat(binview, " %a");
     482      }
    481483      WinQueryDlgItemText(hwnd, CFGV_BINED, CCHMAXPATH, szBuf);
    482484      szBuf[CCHMAXPATH - 1] = 0;
    483       bstrip(szBuf);
    484       if (!strcspn(szBuf, buf))
    485         BldQuotedFileName(bined, szBuf);
    486       else
    487         memcpy(bined, szBuf, strlen(szBuf) + 1);
    488       if (!strchr(bined, '%') && strlen(bined) > 3)
    489         strcat(bined, " %a");
    490       else
    491         memcpy(bined, szBuf, strlen(szBuf) + 1);
     485      if (strcmp(szBuf, bined)){
     486        psz = CheckApp_QuoteAddExe(szBuf);
     487        memcpy(bined, psz, strlen(psz) + 1);
     488        if (!strchr(bined, '%') && strlen(bined) > 3)
     489          strcat(bined, " %a");
     490      }
    492491      PrfWriteProfileString(fmprof, appname, "Viewer", viewer);
    493492      PrfWriteProfileString(fmprof, appname, "Editor", editor);
     
    508507      break;
    509508    }
     509  }
     510  if (fCancelAction){
     511    fCancelAction = FALSE;
     512    WinDlgBox(HWND_DESKTOP,
     513              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMP("Viewer1"));
    510514  }
    511515  return WinDefDlgProc(hwnd, msg, mp1, mp2);
     
    637641
    638642  case WM_CLOSE:
    639     {
    640       CHAR szBuf[CCHMAXPATH], buf[10] = "\"%-/";
     643    { // fixme these strings can be longer than CCHMAXPATH since
     644      // they contain args.
     645      CHAR szBuf[CCHMAXPATH], *psz;
    641646
    642647      WinQueryDlgItemText(hwnd, CFGH_RUNHTTPWORKDIR, CCHMAXPATH, szBuf);
    643648      szBuf[CCHMAXPATH - 1] = 0;
    644649      bstrip(szBuf);
    645       if (!strcspn(szBuf, buf))
    646         BldQuotedFileName(httprundir, szBuf);
    647       else
    648         memcpy(httprundir, szBuf, strlen(szBuf) + 1);
     650      memcpy(httprundir, szBuf, strlen(szBuf) + 1);
    649651      WinQueryDlgItemText(hwnd, CFGH_RUNFTPWORKDIR, CCHMAXPATH, szBuf);
    650652      szBuf[CCHMAXPATH - 1] = 0;
    651653      bstrip(szBuf);
    652       if (!strcspn(szBuf, buf))
    653         BldQuotedFileName(ftprundir, szBuf);
    654       else
    655         memcpy(ftprundir, szBuf, strlen(szBuf) + 1);
     654      memcpy(ftprundir, szBuf, strlen(szBuf) + 1);
    656655      WinQueryDlgItemText(hwnd, CFGH_RUNMAILWORKDIR, CCHMAXPATH, szBuf);
    657656      szBuf[CCHMAXPATH - 1] = 0;
    658657      bstrip(szBuf);
    659       if (!strcspn(szBuf, buf))
    660         BldQuotedFileName(mailrundir, szBuf);
    661       else
    662         memcpy(mailrundir, szBuf, strlen(szBuf) + 1);
     658      memcpy(mailrundir, szBuf, strlen(szBuf) + 1);
    663659      WinQueryDlgItemText(hwnd, CFGH_FTPRUN, CCHMAXPATH, szBuf);
    664660      szBuf[CCHMAXPATH - 1] = 0;
    665       bstrip(szBuf);
    666       if (!strchr(szBuf, '"'))
    667         BldQuotedFileName(ftprun, szBuf);
    668       else
    669         memcpy(ftprun, szBuf, strlen(szBuf) + 1);
     661      if (strcmp(szBuf, ftprun)){
     662        psz = CheckApp_QuoteAddExe(szBuf);
     663        memcpy(ftprun, psz, strlen(psz) + 1);
     664      }
    670665      WinQueryDlgItemText(hwnd, CFGH_HTTPRUN, CCHMAXPATH, szBuf);
    671666      szBuf[CCHMAXPATH - 1] = 0;
    672       bstrip(szBuf);
    673       if (!strchr(szBuf, '"'))
    674         BldQuotedFileName(httprun, szBuf);
    675       else
    676         memcpy(httprun, szBuf, strlen(szBuf) + 1);
     667      if (strcmp(szBuf, httprun)){
     668        psz = CheckApp_QuoteAddExe(szBuf);
     669        memcpy(httprun, psz, strlen(psz) + 1);
     670      }
    677671      WinQueryDlgItemText(hwnd, CFGH_MAILRUN, CCHMAXPATH, szBuf);
    678672      szBuf[CCHMAXPATH - 1] = 0;
    679       bstrip(szBuf);
    680       if (!strcspn(szBuf, buf))
    681         BldQuotedFileName(mailrun, szBuf);
    682       else
    683         memcpy(mailrun, szBuf, strlen(szBuf) + 1);
     673      if (strcmp(szBuf, mailrun)){
     674        psz = CheckApp_QuoteAddExe(szBuf);
     675        memcpy(mailrun, psz, strlen(psz) + 1);
     676      }
    684677      PrfWriteProfileString(fmprof, appname, "HttpRunDir", httprundir);
    685678      PrfWriteProfileString(fmprof, appname, "FtpRunDir", ftprundir);
     
    708701      break;
    709702    }
     703  }
     704  if (fCancelAction){
     705    fCancelAction = FALSE;
     706    WinDlgBox(HWND_DESKTOP,
     707              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMP("Viewer2"));
    710708  }
    711709  return WinDefDlgProc(hwnd, msg, mp1, mp2);
     
    12491247  case WM_CLOSE:
    12501248    {
    1251       CHAR szBuf[CCHMAXPATH], buf[10] = "\"%-/";
     1249      CHAR szBuf[CCHMAXPATH], *psz;
    12521250
    12531251      WinQueryDlgItemText(hwnd, CFGC_DIRCOMPARE, CCHMAXPATH, szBuf);
    12541252        szBuf[CCHMAXPATH - 1] = 0;
    1255         bstrip(szBuf);
    1256         if (!strcspn(szBuf, buf))
    1257           BldQuotedFileName(dircompare, szBuf);
    1258         else
    1259           memcpy(dircompare, szBuf, strlen(szBuf) + 1);
    1260         if (!strchr(dircompare, '%') && strlen(dircompare) > 3)
    1261           strcat(dircompare, " %a");
     1253        if (strcmp(szBuf, dircompare)){
     1254          psz = CheckApp_QuoteAddExe(szBuf);
     1255          memcpy(dircompare, psz, strlen(psz) + 1);
     1256          if (!strchr(dircompare, '%') && strlen(dircompare) > 3)
     1257            strcat(dircompare, " %a");
     1258        }
    12621259      PrfWriteProfileString(fmprof, appname, "DirCompare", dircompare);
    12631260      WinQueryDlgItemText(hwnd, CFGC_COMPARE, CCHMAXPATH, szBuf);
    12641261        szBuf[CCHMAXPATH - 1] = 0;
    1265         bstrip(szBuf);
    1266         if (!strcspn(szBuf, buf))
    1267           BldQuotedFileName(compare, szBuf);
    1268         else
    1269           memcpy(compare, szBuf, strlen(szBuf) + 1);
    1270         if (!strchr(compare, '%') && strlen(compare) > 3)
    1271           strcat(compare, " %a");
     1262        if (strcmp(szBuf, compare)){
     1263          psz = CheckApp_QuoteAddExe(szBuf);
     1264          memcpy(compare, psz, strlen(psz) + 1);
     1265          if (!strchr(compare, '%') && strlen(compare) > 3)
     1266            strcat(compare, " %a");
     1267        }
    12721268      PrfWriteProfileString(fmprof, appname, "Compare", compare);
    12731269      break;
    12741270    }
     1271  }
     1272  if (fCancelAction){
     1273    fCancelAction = FALSE;
     1274    WinDlgBox(HWND_DESKTOP,
     1275              hwnd, CfgDlgProc, FM3ModHandle, CFG_FRAME, MPFROMP("Compare"));
    12751276  }
    12761277  return WinDefDlgProc(hwnd, msg, mp1, mp2);
     
    31113112      }
    31123113    }
     3114    if (mp2 && !strcmp((CHAR *) mp2, "Viewer2"))
     3115      PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
     3116              BKM_TURNTOPAGE, MPFROMLONG(np[9].pageID), MPVOID);
     3117    else if (mp2 && !strcmp((CHAR *) mp2, "Viewer1"))
     3118           PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
     3119                   BKM_TURNTOPAGE, MPFROMLONG(np[8].pageID), MPVOID);
     3120    else if (mp2 && !strcmp((CHAR *) mp2, "Compare"))
     3121           PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
     3122                   BKM_TURNTOPAGE, MPFROMLONG(np[10].pageID), MPVOID);
     3123    else if (mp2 && !strcmp((CHAR *) mp2, "Archive"))
     3124           PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
     3125                   BKM_TURNTOPAGE, MPFROMLONG(np[5].pageID), MPVOID);
     3126    else if (mp2 && !strcmp((CHAR *) mp2, "Tree"))
     3127           PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
     3128                   BKM_TURNTOPAGE, MPFROMLONG(np[6].pageID), MPVOID);
     3129    else if (mp2 && !strcmp((CHAR *) mp2, "Collector"))
     3130           PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
     3131                   BKM_TURNTOPAGE, MPFROMLONG(np[3].pageID), MPVOID);
    31133132    /* see if we've been asked to display quick cfg page */
    3114     if (!mp2 ||
    3115         strcmp((CHAR *) mp2, "First Time") ||
    3116         !x || !np[x - 1].hwnd || !np[x - 1].pageID) {
    3117       PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
    3118               BKM_TURNTOPAGE, MPFROMLONG(np[0].pageID), MPVOID);
    3119     }
     3133    else if (!mp2 || strcmp((CHAR *) mp2, "First Time") ||
     3134             !x || !np[x - 1].hwnd || !np[x - 1].pageID)
     3135           PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
     3136                   BKM_TURNTOPAGE, MPFROMLONG(np[0].pageID), MPVOID);
    31203137    else {
    31213138      PostMsg(MainObjectHwnd, UM_SETDIR, MPFROMLONG(1L), MPVOID);
    31223139      PostMsg(WinWindowFromID(hwnd, CFG_NOTEBOOK),
    3123               BKM_TURNTOPAGE, MPFROMLONG(np[x - 1].pageID), MPVOID);
     3140              BKM_TURNTOPAGE, MPFROMLONG(np[x - 1].pageID), MPVOID);
    31243141      PostMsg(hwnd, UM_FOCUSME, MPFROMLONG(np[x - 1].hwnd), MPVOID);
    31253142      PostMsg(np[x - 1].hwnd, WM_COMMAND, MPFROM2SHORT(IDM_HELP, 0), MPVOID);
    31263143    }
    3127     break;
     3144
     3145  break;
    31283146
    31293147  case UM_FOCUSME:
Note: See TracChangeset for help on using the changeset viewer.