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
  • branches/branch-1-0/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
     
    20832083 *@@added V0.9.20 (2002-08-10) [umoeller]
    20842084 *@@changed V1.0.0 (2002-08-21) [umoeller]: changed prototype to return browser
    2085  */
     2085 *@@changed WarpIN V1.0.17 (2008-03-08) [pr]: rewritten to add IAIUTIL settings
     2086*/
     2087
     2088typedef struct _URLPROTOAPP {
     2089    PCSZ    pcszProtocol;
     2090    PCSZ    pcszKeyExe;
     2091    PCSZ    pcszKeyParam;
     2092    PCSZ    pcszKeyDir;
     2093} URLPROTOAPP;
    20862094
    20872095APIRET appOpenURL(PCSZ pcszURL,           // in: URL to open
     
    20902098{
    20912099    APIRET      arc = ERROR_NO_DATA;
    2092 
    2093     CHAR        szStartupDir[CCHMAXPATH];
    20942100    XSTRING     strParameters;
     2101    PCSZ        pcszApp = "WPURLDEFAULTSETTINGS", pcszKeyExe, pcszKeyParam, pcszKeyDir;
     2102    ULONG       i;
     2103    URLPROTOAPP urlProtoApps[] = {
     2104        { "", "DefaultBrowserExe", "DefaultParameters", "DefaultWorkingDir" },
     2105        { "mailto:", "DefaultMailExe", "DefaultMailParameters", "DefaultMailWorkingDir" },
     2106        { "news:", "DefaultNewsExe", "DefaultNewsParameters", "DefaultNewsWorkingDir" },
     2107        { "ftp:", "DefaultFTPExe", "DefaultFTPParameters", "DefaultFTPWorkingDir" },
     2108        { "irc:", "DefaultIRCExe", "DefaultIRCParameters", "DefaultIRCWorkingDir" }
     2109    };
    20952110
    20962111    if (    (!pcszURL)
     
    21012116
    21022117    xstrInit(&strParameters, 0);
    2103 
    2104     if (PrfQueryProfileString(HINI_USER,
    2105                               "WPURLDEFAULTSETTINGS",
    2106                               "DefaultBrowserExe",
    2107                               "NETSCAPE.EXE",
    2108                               pszAppStarted,
    2109                               cbAppStarted))
    2110     {
    2111         PSZ     pszDefParams;
    2112         HAPP    happ;
    2113 
    2114         if (pszDefParams = prfhQueryProfileData(HINI_USER,
    2115                                                 "WPURLDEFAULTSETTINGS",
    2116                                                 "DefaultParameters",
    2117                                                 NULL))
    2118         {
    2119             xstrcpy(&strParameters, pszDefParams, 0);
    2120             xstrcatc(&strParameters, ' ');
    2121             free(pszDefParams);
    2122         }
    2123 
    2124         xstrcat(&strParameters, pcszURL, 0);
    2125 
    2126         PrfQueryProfileString(HINI_USER,
    2127                               "WPURLDEFAULTSETTINGS",
    2128                               "DefaultWorkingDir",
    2129                               "",
    2130                               szStartupDir,
    2131                               sizeof(szStartupDir));
    2132 
    2133         arc = appQuickStartApp(pszAppStarted,
    2134                                PROG_DEFAULT,
    2135                                strParameters.psz,
    2136                                szStartupDir,
    2137                                &happ,
    2138                                NULL);     // don't wait
     2118    for (i = sizeof(urlProtoApps) / sizeof(urlProtoApps[0]); i; i--)
     2119    {
     2120        if (!strnicmp(pcszURL,
     2121                      urlProtoApps[i - 1].pcszProtocol,
     2122                      strlen(urlProtoApps[i - 1].pcszProtocol)))
     2123        {
     2124            if (PrfQueryProfileString(HINI_USER,
     2125                                      (PSZ) pcszApp,
     2126                                      (PSZ) urlProtoApps[i - 1].pcszKeyExe,
     2127                                      NULL,
     2128                                      pszAppStarted,
     2129                                      cbAppStarted))
     2130            {
     2131                PSZ     pszDefParams;
     2132                CHAR    szStartupDir[CCHMAXPATH];
     2133                HAPP    happ;
     2134
     2135                if (pszDefParams = prfhQueryProfileData(HINI_USER,
     2136                                                        pcszApp,
     2137                                                        urlProtoApps[i - 1].pcszKeyParam,
     2138                                                        NULL))
     2139                {
     2140                    xstrcpy(&strParameters, pszDefParams, 0);
     2141                    xstrcatc(&strParameters, ' ');
     2142                    free(pszDefParams);
     2143                }
     2144
     2145                xstrcat(&strParameters, pcszURL, 0);
     2146                PrfQueryProfileString(HINI_USER,
     2147                                      (PSZ) pcszApp,
     2148                                      (PSZ) urlProtoApps[i - 1].pcszKeyDir,
     2149                                      "",
     2150                                      szStartupDir,
     2151                                      sizeof(szStartupDir));
     2152                arc = appQuickStartApp(pszAppStarted,
     2153                                       PROG_DEFAULT,
     2154                                       strParameters.psz,
     2155                                       szStartupDir,
     2156                                       &happ,
     2157                                       NULL);     // don't wait
     2158                break;
     2159            }
     2160        }
    21392161    }
    21402162
    21412163    xstrClear(&strParameters);
    2142 
    21432164    return arc;
    21442165}
Note: See TracChangeset for help on using the changeset viewer.