Ignore:
Timestamp:
Mar 13, 2008, 1:29:15 AM (17 years ago)
Author:
pr
Message:

Add IAIUtil settings to appOpenURL.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/helpers/apps.c

    r297 r361  
    1515
    1616/*
    17  *      Copyright (C) 1997-2005 Ulrich M”ller.
     17 *      Copyright (C) 1997-2008 Ulrich M”ller.
    1818 *      This file is part of the "XWorkplace helpers" source package.
    1919 *      This is free software; you can redistribute it and/or modify
     
    20022002 *@@added V0.9.20 (2002-08-10) [umoeller]
    20032003 *@@changed V1.0.0 (2002-08-21) [umoeller]: changed prototype to return browser
    2004  */
     2004 *@@changed WarpIN V1.0.17 (2008-03-08) [pr]: rewritten to add IAIUTIL settings
     2005*/
     2006
     2007typedef struct _URLPROTOAPP {
     2008    PCSZ    pcszProtocol;
     2009    PCSZ    pcszKeyExe;
     2010    PCSZ    pcszKeyParam;
     2011    PCSZ    pcszKeyDir;
     2012} URLPROTOAPP;
    20052013
    20062014APIRET appOpenURL(PCSZ pcszURL,           // in: URL to open
     
    20092017{
    20102018    APIRET      arc = ERROR_NO_DATA;
    2011 
    2012     CHAR        szStartupDir[CCHMAXPATH];
    20132019    XSTRING     strParameters;
     2020    PCSZ        pcszApp = "WPURLDEFAULTSETTINGS", pcszKeyExe, pcszKeyParam, pcszKeyDir;
     2021    ULONG       i;
     2022    URLPROTOAPP urlProtoApps[] = {
     2023        { "", "DefaultBrowserExe", "DefaultParameters", "DefaultWorkingDir" },
     2024        { "mailto:", "DefaultMailExe", "DefaultMailParameters", "DefaultMailWorkingDir" },
     2025        { "news:", "DefaultNewsExe", "DefaultNewsParameters", "DefaultNewsWorkingDir" },
     2026        { "ftp:", "DefaultFTPExe", "DefaultFTPParameters", "DefaultFTPWorkingDir" },
     2027        { "irc:", "DefaultIRCExe", "DefaultIRCParameters", "DefaultIRCWorkingDir" }
     2028    };
    20142029
    20152030    if (    (!pcszURL)
     
    20202035
    20212036    xstrInit(&strParameters, 0);
    2022 
    2023     if (PrfQueryProfileString(HINI_USER,
    2024                               "WPURLDEFAULTSETTINGS",
    2025                               "DefaultBrowserExe",
    2026                               "NETSCAPE.EXE",
    2027                               pszAppStarted,
    2028                               cbAppStarted))
    2029     {
    2030         PSZ     pszDefParams;
    2031         HAPP    happ;
    2032 
    2033         if (pszDefParams = prfhQueryProfileData(HINI_USER,
    2034                                                 "WPURLDEFAULTSETTINGS",
    2035                                                 "DefaultParameters",
    2036                                                 NULL))
    2037         {
    2038             xstrcpy(&strParameters, pszDefParams, 0);
    2039             xstrcatc(&strParameters, ' ');
    2040             free(pszDefParams);
    2041         }
    2042 
    2043         xstrcat(&strParameters, pcszURL, 0);
    2044 
    2045         PrfQueryProfileString(HINI_USER,
    2046                               "WPURLDEFAULTSETTINGS",
    2047                               "DefaultWorkingDir",
    2048                               "",
    2049                               szStartupDir,
    2050                               sizeof(szStartupDir));
    2051 
    2052         arc = appQuickStartApp(pszAppStarted,
    2053                                PROG_DEFAULT,
    2054                                strParameters.psz,
    2055                                szStartupDir,
    2056                                &happ,
    2057                                NULL);     // don't wait
     2037    for (i = sizeof(urlProtoApps) / sizeof(urlProtoApps[0]); i; i--)
     2038    {
     2039        if (!strnicmp(pcszURL,
     2040                      urlProtoApps[i - 1].pcszProtocol,
     2041                      strlen(urlProtoApps[i - 1].pcszProtocol)))
     2042        {
     2043            if (PrfQueryProfileString(HINI_USER,
     2044                                      (PSZ) pcszApp,
     2045                                      (PSZ) urlProtoApps[i - 1].pcszKeyExe,
     2046                                      NULL,
     2047                                      pszAppStarted,
     2048                                      cbAppStarted))
     2049            {
     2050                PSZ     pszDefParams;
     2051                CHAR    szStartupDir[CCHMAXPATH];
     2052                HAPP    happ;
     2053
     2054                if (pszDefParams = prfhQueryProfileData(HINI_USER,
     2055                                                        pcszApp,
     2056                                                        urlProtoApps[i - 1].pcszKeyParam,
     2057                                                        NULL))
     2058                {
     2059                    xstrcpy(&strParameters, pszDefParams, 0);
     2060                    xstrcatc(&strParameters, ' ');
     2061                    free(pszDefParams);
     2062                }
     2063
     2064                xstrcat(&strParameters, pcszURL, 0);
     2065                PrfQueryProfileString(HINI_USER,
     2066                                      (PSZ) pcszApp,
     2067                                      (PSZ) urlProtoApps[i - 1].pcszKeyDir,
     2068                                      "",
     2069                                      szStartupDir,
     2070                                      sizeof(szStartupDir));
     2071                arc = appQuickStartApp(pszAppStarted,
     2072                                       PROG_DEFAULT,
     2073                                       strParameters.psz,
     2074                                       szStartupDir,
     2075                                       &happ,
     2076                                       NULL);     // don't wait
     2077                break;
     2078            }
     2079        }
    20582080    }
    20592081
    20602082    xstrClear(&strParameters);
    2061 
    20622083    return arc;
    20632084}
Note: See TracChangeset for help on using the changeset viewer.