示例#1
0
BOOL CNamePage::OnInitDialog()
{
	BOOL ret;
	char * pString = NULL;
	
	ret = CNetscapePropertyPage::OnInitDialog();

	if (m_pParent->m_bUpgrade) {
		// if we aren't creating a new profile, we are updating an existing one
		CString csUserAddr = theApp.GetProfileString("User","User_Addr","DefaultUser");
		CString csFullName = theApp.GetProfileString("User","User_Name","");

		m_pParent->m_pUserAddr = csUserAddr;
		m_pParent->m_pFullName = csFullName;
	} else {
		char buffer[256];
		int nLen = 255;

		if (PREF_NOERROR == PREF_GetCharPref("mail.identity.username", buffer, &nLen))
			m_pParent->m_pFullName = buffer;
		if (PREF_NOERROR == PREF_GetCharPref("mail.identity.useremail", buffer, &nLen))
			m_pParent->m_pUserAddr = buffer;
	}

	SetDlgItemText(IDC_USER_NAME, m_pParent->m_pFullName);
	SetDlgItemText(IDC_EMAIL_ADDR, m_pParent->m_pUserAddr);

	if(theApp.m_bPEEnabled)
		ShowHideEmailName();

	return ret;
}
示例#2
0
/* Pref for proxy autodiscovery url */
MODULE_PRIVATE int PR_CALLBACK 
net_PadPacURLPrefChanged(const char *pref, void *data) {
	char s[128];
    int len = sizeof(s);
	XP_MEMSET(s, 0, len);

    PREF_GetCharPref(pref_padPacURL, s, &len);
	NET_SetPadPacURL(s);
    return PREF_NOERROR;
}
示例#3
0
/* called from mkgeturl.c, NET_InitNetLib(). 
 * Initializes the pad variables and registers pad callbacks */
PUBLIC void
NET_RegisterPadPrefCallbacks(void) {
	XP_Bool x;
    char s[128];
    int len=sizeof(s);
	XP_MEMSET(s, 0, len);

	PREF_GetBoolPref(pref_enablePad, &x);
	MK_PadEnabled=x;
	PREF_RegisterCallback(pref_enablePad, net_EnablePadPrefChanged, NULL);

	PREF_GetCharPref(pref_padPacURL, s, &len);
	NET_SetPadPacURL(s);
	PREF_RegisterCallback(pref_padPacURL, net_PadPacURLPrefChanged, NULL);
}
/* NativeGetDirectoryPath
 * gets a platform-specific directory path
 * stores it in urlPath
 */
int nsFolderSpec::NativeGetDirectoryPath()
{
  su_DirSpecID folderDirSpecID;
  char*	folderPath = NULL;

  /* Get the name of the package to prompt for */

  folderDirSpecID = MapNameToEnum(folderID);
  switch (folderDirSpecID) 
    {
    case eBadFolder:
      return SUERR_INVALID_PATH_ERR;

    case eCurrentUserFolder:
      {
        char dir[MAX_PATH];
        int len = MAX_PATH;
        if ( PREF_GetCharPref("profile.directory", dir, &len) == PREF_NOERROR)      
          {
            char * platformDir = WH_FileName(dir, xpURL);
            if (platformDir)
              folderPath = AppendSlashToDirPath(platformDir);
            XP_FREEIF(platformDir);
          }
      }
    break;

    default:
      /* Get the FE path */
      folderPath = FE_GetDirectoryPath(folderDirSpecID);
      break;
    }


  /* Store it in the object */
  if (folderPath != NULL) {
    urlPath = NULL;
    urlPath = XP_STRDUP(folderPath);
    XP_FREE(folderPath);
    return 0;
  }

  return SUERR_INVALID_PATH_ERR;
}
示例#5
0
/* returns a unmalloced static string
 * that is only available for temporary use.
 */
PUBLIC char *
xp_FileName (const char *name, XP_FileType type, char* buf, char* configBuf)
{
    const char *conf_dir = xp_unix_config_directory(configBuf);

    switch (type)
    {
    case xpSARCacheIndex:
    {
        const char *sar_cache_dir = FE_SARCacheDir;
        if (!sar_cache_dir || !*sar_cache_dir)
            sar_cache_dir = conf_dir;
        if (sar_cache_dir [strlen (sar_cache_dir) - 1] == '/')
            sprintf (buf, "%.900sarchive.fat", sar_cache_dir);
        else
            sprintf (buf, "%.900s/archive.fat", sar_cache_dir);

        name = buf;
        break;
    }
    case xpSARCache:
    {
        /* WH_TempName() returns relative pathnames for the cache files,
           so that relative paths get written into the cacheFAT database.
           WH_FileName() converts them to absolute if they aren't already
           so that the logic of XP_FileOpen() and XP_FileRename() and who
           knows what else is simpler.
         */
        if (name != NULL && *name == '/')
            break ;

        {
            char *tmp = FE_SARCacheDir;
            if (!tmp || !*tmp) tmp = "/tmp";
            if (tmp [strlen (tmp) - 1] == '/')
                sprintf (buf, "%.500s%.500s", tmp, name);
            else
                sprintf (buf, "%.500s/%.500s", tmp, name);
            name = buf;
        }
        break;
    }
    case xpCacheFAT:
    {
        const char *cache_dir = FE_CacheDir;
        if (!cache_dir || !*cache_dir)
            cache_dir = conf_dir;
        if (cache_dir [strlen (cache_dir) - 1] == '/')
            sprintf (buf, "%.900sindex.db", cache_dir);
        else
            sprintf (buf, "%.900s/index.db", cache_dir);

        name = buf;
        break;
    }
    case xpCache:
    {
        /* WH_TempName() returns relative pathnames for the cache files,
           so that relative paths get written into the cacheFAT database.
           WH_FileName() converts them to absolute if they aren't already
           so that the logic of XP_FileOpen() and XP_FileRename() and who
           knows what else is simpler.
         */
        if (*name != '/')
        {
            char *tmp = FE_CacheDir;
            if (!tmp || !*tmp) tmp = "/tmp";
            if (tmp [strlen (tmp) - 1] == '/')
                sprintf (buf, "%.500s%.500s", tmp, name);
            else
                sprintf (buf, "%.500s/%.500s", tmp, name);
            name = buf;
        }
        break;
    }

    case xpHTTPCookie:
    {
#ifndef OLD_UNIX_FILES
        sprintf (buf, "%.900s/cookies", conf_dir);
#else  /* OLD_UNIX_FILES */
        sprintf (buf, "%.900s/.netscape-cookies", conf_dir);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;
    }
    case xpRegistry:
    {
        if ( name == NULL || *name == '\0' ) {
#ifndef OLD_UNIX_FILES
            sprintf (buf, "%.900s/registry", conf_dir);
#else  /* OLD_UNIX_FILES */
            sprintf (buf, "%.900s/.netscape-registry", conf_dir);
#endif /* OLD_UNIX_FILES */
            name = buf;
        }
        else {
            XP_ASSERT( name[0] == '/' );
        }
        break;
    }
    case xpProxyConfig:
    {
        sprintf(buf, "%.900s/proxyconf", conf_dir);
        name = buf;
        break;
    }
    case xpTemporary:
    {
        if (*name != '/')
        {
            char *tmp = FE_TempDir;
            if (!tmp || !*tmp) tmp = "/tmp";
            if (tmp [strlen (tmp) - 1] == '/')
                sprintf (buf, "%.500s%.500s", tmp, name);
            else
                sprintf (buf, "%.500s/%.500s", tmp, name);
            name = buf;
        }
        break;
    }
    case xpNewsRC:
    case xpSNewsRC:
    case xpTemporaryNewsRC:
    {
        /* In this case, `name' is "" or "host" or "host:port". */

        char *home = getenv ("HOME");
        const char *newsrc_dir = ((FE_UserNewsRC && *FE_UserNewsRC)
                                  ? FE_UserNewsRC
                                  : (home ? home : ""));
        const char *basename = (type == xpSNewsRC ? ".snewsrc" : ".newsrc");
        const char *suffix = (type == xpTemporaryNewsRC ? ".tmp" : "");
        if (*name)
            sprintf (buf, "%.800s%.1s%.8s-%.128s%.4s",
                     newsrc_dir,
                     (newsrc_dir[XP_STRLEN(newsrc_dir)-1] == '/' ? "" : "/"),
                     basename, name, suffix);
        else
            sprintf (buf, "%.800s%.1s%.128s%.4s",
                     newsrc_dir,
                     (newsrc_dir[XP_STRLEN(newsrc_dir)-1] == '/' ? "" : "/"),
                     basename, suffix);

        name = buf;
        break;
    }
    case xpNewsgroups:
    case xpSNewsgroups:
    {
#ifndef OLD_UNIX_FILES
        sprintf (buf, "%.800s/%snewsgroups-%.128s",
                 conf_dir,
                 type == xpSNewsgroups ? "s" : "",
                 name);
#else  /* OLD_UNIX_FILES */
        sprintf (buf, "%.800s/.netscape-%snewsgroups-%.128s",
                 conf_dir,
                 type == xpSNewsgroups ? "s" : "",
                 name);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;
    }

    case xpExtCacheIndex:
#ifndef OLD_UNIX_FILES
        sprintf (buf, "%.900s/cachelist", conf_dir);
#else  /* OLD_UNIX_FILES */
        sprintf (buf, "%.900s/.netscape-cache-list", conf_dir);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;

    case xpGlobalHistory:
        name = FE_GlobalHist;
        break;

    case xpCertDB:
#ifndef OLD_UNIX_FILES
        if ( name ) {
            sprintf (buf, "%.900s/cert%s.db", conf_dir, name);
        } else {
            sprintf (buf, "%.900s/cert.db", conf_dir);
        }
#else  /* OLD_UNIX_FILES */
        sprintf (buf, "%.900s/.netscape-certdb", conf_dir);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;
    case xpCertDBNameIDX:
#ifndef OLD_UNIX_FILES
        sprintf (buf, "%.900s/cert-nameidx.db", conf_dir);
#else  /* OLD_UNIX_FILES */
        sprintf (buf, "%.900s/.netscape-certdb-nameidx", conf_dir);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;
    case xpKeyDB:
#ifndef OLD_UNIX_FILES
        if ( name ) {
            sprintf (buf, "%.900s/key%s.db", conf_dir, name);
        } else {
            sprintf (buf, "%.900s/key.db", conf_dir);
        }
#else  /* OLD_UNIX_FILES */
        sprintf (buf, "%.900s/.netscape-keydb", conf_dir);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;
    case xpSecModuleDB:
        sprintf (buf, "%.900s/secmodule.db", conf_dir);
        name = buf;
        break;

    case xpSignedAppletDB:
    {
#ifndef OLD_UNIX_FILES
        if ( name ) {
            sprintf (buf, "%.900s/signedapplet%s.db", conf_dir, name);
        } else {
            sprintf (buf, "%.900s./signedapplet.db", conf_dir);
        }
#else  /* OLD_UNIX_FILES */
        sprintf (buf, "%.900s/.netscape-signedappletdb", conf_dir);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;
    }

    case xpFileToPost:
    case xpSignature:
        /* These are always absolute pathnames.
         * BUT, the user can type in whatever so
         * we can't assert if it doesn't begin
         * with a slash
         */
        break;

    case xpExtCache:
    case xpKeyChain:
    case xpURL:
    case xpHotlist:
    case xpBookmarks:
    case xpMimeTypes:
    case xpSocksConfig:
    case xpMailFolder:
#ifdef BSDI
        /* In bsdi, mkdir fails if the directory name is terminated
         * with a '/'. - dp
         */
        if (name[strlen(name)-1] == '/') {
            strcpy(buf, name);
            buf[strlen(buf)-1] = '\0';
            name = buf;
        }
#endif
#ifndef MCC_PROXY
        /*
         * These are always absolute pathnames for the Navigator.
         * Only the proxy (servers) may have pathnames relative
         * to their current working directory (the servers chdir
         * to their admin/config directory on startup.
         *
         */
        if (name) XP_ASSERT (name[0] == '/');
#endif	/* ! MCC_PROXY */

        break;

    case xpMailFolderSummary:
        /* Convert /a/b/c/foo to /a/b/c/.foo.summary (note leading dot) */
    {
        const char *slash;
        slash = strrchr (name, '/');
        if (name) XP_ASSERT (name[0] == '/');
        XP_ASSERT (slash);
        if (!slash) return 0;
        XP_MEMCPY (buf, name, slash - name + 1);
        buf [slash - name + 1] = '.';
        XP_STRCPY (buf + (slash - name) + 2, slash + 1);
        XP_STRCAT (buf, ".summary");
        name = buf;
        break;
    }

    case xpAddrBookNew:
        /* Convert foo.db to /a/b/c/foo.db */
    {
        if ( name ) {
            sprintf (buf, "%.900s/%s", conf_dir, name);
        } else {
            sprintf (buf, "%.900s/abook.nab", conf_dir);
        }
#if defined(DEBUG_tao)
        printf("\n  xpAddrBookNew, xp_FileName, buf=%s\n", buf);
#endif
        name = buf;

        break;
    }

    case xpAddrBook:
        /* Convert /a/b/c/foo to /a/b/c/foo.db (note leading dot) */
    {
        /* Tao_27jan97
         */
        char *dot = NULL;
        int len = 0;
        const char *base = NULL;

        if (name)
            XP_ASSERT (name[0] == '/');

        dot = XP_STRRCHR(name, '.');
        if (dot) {

            len = dot - name + 1;
            XP_STRNCPY_SAFE(buf, name, len);
        }/* if */

        XP_STRCAT (buf, ".nab");


        /* Tao_02jun97 don't convert addrbook.db
         * reuse len, dot
         */
        base = XP_STRRCHR(name, '/');
        if (base && *base == '/')
            base++;

#if defined(DEBUG_tao)
        printf("\n++++  xpAddrBook, before xp_FileName=%s\n", name);
#endif

        if (!base || XP_STRCMP(base, "addrbook.db"))
            /* not old addrbook.db file
             */
            name = buf;
#if defined(DEBUG_tao)
        printf("\n  xpAddrBook, xp_FileName=%s\n", name);
#endif
        break;
    }

    case xpVCardFile:
        /* Convert /a/b/c/foo to /a/b/c/foo.vcf (note leading dot) */
    {
#if 1
        /* Tao_27jan97
         */
        char *dot = NULL;
        int len = 0;

        if (name)
            XP_ASSERT (name[0] == '/');

        dot = XP_STRRCHR(name, '.');
        if (dot) {
            len = dot - name + 1;
            XP_STRNCPY_SAFE(buf, name, len);
        }/* if */

        XP_STRCAT (buf, ".vcf");
        name = buf;
#if defined(DEBUG_tao_)
        printf("\n  xp_FileName=%s\n", name);
#endif
#else
        const char *slash;
        slash = strrchr (name, '/');
        if (name) XP_ASSERT (name[0] == '/');
        XP_ASSERT (slash);
        if (!slash) return 0;
        XP_MEMCPY (buf, name, slash - name + 1);
        XP_STRCAT (buf, ".vcf");
        name = buf;
#endif
        break;
    }

    case xpLDIFFile:
        /* Convert /a/b/c/foo to /a/b/c/foo.ldif (note leading dot) */
    {
#if 1
        /* Tao_27jan97
         */
        char *dot = NULL;
        int len = 0;

        if (name)
            XP_ASSERT (name[0] == '/');

        dot = XP_STRRCHR(name, '.');
        if (dot) {
            len = dot - name + 1;
            XP_STRNCPY_SAFE(buf, name, len);
        }/* if */

        XP_STRCAT (buf, ".ldif");
        name = buf;
#if defined(DEBUG_tao_)
        printf("\n  xp_FileName=%s\n", name);
#endif

#else
        const char *slash;
        slash = strrchr (name, '/');
        if (name) XP_ASSERT (name[0] == '/');
        XP_ASSERT (slash);
        if (!slash) return 0;
        XP_MEMCPY (buf, name, slash - name + 1);
        XP_STRCAT (buf, ".ldif");
        name = buf;
#endif
        break;
    }

    case xpJSMailFilters:
        sprintf(buf, "%.900s/filters.js", conf_dir);
        name = buf;
        break;

    case xpJSHTMLFilters:
        sprintf(buf, "%.900s/hook.js", conf_dir);
        name = buf;
        break;

    case xpNewsSort:
        sprintf(buf, "%.800s/xover-cache/%.128snetscape-newsrule", conf_dir, name);
        break;
    case xpMailSort:
#ifndef OLD_UNIX_FILES
        sprintf(buf, "%.900s/mailrule", conf_dir);
#else  /* OLD_UNIX_FILES */
        sprintf(buf, "%.900s/.netscape-mailrule", conf_dir);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;
    case xpMailPopState:
#ifndef OLD_UNIX_FILES
        sprintf(buf, "%.900s/popstate", conf_dir);
#else  /* OLD_UNIX_FILES */
        sprintf(buf, "%.900s/.netscape-popstate", conf_dir);
#endif /* OLD_UNIX_FILES */
        name = buf;
        break;
    case xpMailFilterLog:
        sprintf(buf, "%.900s/.netscape-mailfilterlog", conf_dir);
        name = buf;
        break;
    case xpNewsFilterLog:
        sprintf(buf, "%.900s/.netscape-newsfilterlog", conf_dir);
        name = buf;
        break;
    case xpMailSubdirectory:
    {
        char * pEnd = strrchr(name, '/');
        strcpy(buf, name);

        /* strip off the extension */
        if(!pEnd)
            pEnd = buf;

        pEnd = strchr(pEnd, '.');
        if(pEnd)
            *pEnd = '\0';
        strcat(buf, ".sbd/");
        name = buf;
    }
    break;
    case xpXoverCache:
        sprintf(buf, "%.800s/xover-cache/%.128s", conf_dir, name);
        name = buf;
        break;

    case xpNewsHostDatabase:
        sprintf(buf, "%.800s/newsdb", conf_dir);
        name = buf;
        break;

    case xpImapRootDirectory:
    {
        char prefbuf[1024];
        int len = sizeof prefbuf / sizeof *prefbuf;
        if ((PREF_GetCharPref("mail.imap.root_dir",
                              prefbuf, &len) == PREF_NOERROR)
                && *prefbuf == '/')
            /* guard against assert: line 806, file xp_file.c */
            XP_STRNCPY_SAFE(buf, prefbuf, len);
        /* Copy back to the buffer that was passed in.
         * We couldn't have PREF_GetCharPref() just put it there
         * initially because the size of buf wasn't passed in
         * (it happens to be 1024) and PREF_GetCharPref() insists
         * on having a size. Sigh.
         */
        else
        {
            char *home = getenv ("HOME");
            sprintf(buf, "%s/ns_imap", (home ? home : ""));
        }
        name = buf;
        break;
    }

    case xpImapServerDirectory:
    {
        char prefbuf[1024];
        int len = sizeof prefbuf / sizeof *prefbuf;
        if ((PREF_GetCharPref("mail.imap.root_dir",
                              prefbuf, &len) == PREF_NOERROR)
                && *prefbuf == '/')
            /* guard against assert: line 806, file xp_file.c */
            sprintf(buf, "%s/%s", prefbuf, name);
        else
        {
            char *home = getenv ("HOME");
            sprintf(buf, "%s/ns_imap/%s", (home ? home : ""), name);
        }
        name = buf;
        break;
    }

    case xpFolderCache:
        sprintf (buf, "%s/summary.dat", conf_dir);
        name = buf;
        break;

    case xpCryptoPolicy:
    {
        extern void fe_GetProgramDirectory(char *path, int len);
        char *policyFN = "moz40p3";
        char *mozHome  = getenv("MOZILLA_HOME");
        char *lang     = getenv("LANG");
        int   result;
        char  dirName[1024];

        name = buf;
        if (!xp_unix_sprintf_stat(buf, conf_dir, lang, policyFN))
            break;
        if (!xp_unix_sprintf_stat(buf, mozHome, lang, policyFN))
            break;
        fe_GetProgramDirectory(dirName, sizeof dirName);
        if (!xp_unix_sprintf_stat(buf, dirName, lang, policyFN))
            break;

        /* couldn't find it, but must leave a valid file name in buf */
        sprintf(buf, "%.900s/%s", conf_dir, policyFN);
        break;
    }

    case xpPKCS12File:
        /* Convert /a/b/c/foo to /a/b/c/foo.p12 (note leading dot) */
    {
        int len = 0;

        if(name) {
            XP_ASSERT(name[0] == '/');

            /* only append if there is enough space in the buffer */
            /* this should be changed if the size of the buf changes */
            if((XP_STRLEN(name) + 4) <= 1020) {

                /* include NULL in length */
                len = XP_STRLEN(name) + 1;
                XP_STRNCPY_SAFE(buf, name, len);

                /* we want to concatenate ".p12" if it is not the
                 * last 4 characters of the name already.
                 * If len is less than 5 (including the terminating
                 * NULL), it is not ".p12".
                 * If the len is > 5 it may have the .p12, so we want
                 * to check and only append .p12 if the name
                 * specified does not end in .p12.
                 * only side effect -- this allows for the filename
                 * ".p12" which is fine.
                 */
                if((len >= 5) && XP_STRCASECMP(&(name[len-4-1]), ".p12")) {
                    XP_STRCAT(buf, ".p12");
                } else if(len < 5) {
                    /* can't be ".p12", so we append ".p12" */
                    XP_STRCAT(buf, ".p12");
                }
                name = buf;
            }
        }

        break;
    }

    case xpJSCookieFilters:
    {
        sprintf(buf, "%.900s/cookies.js", conf_dir);
        name = buf;
        break;
    }

    case xpLIPrefs:
    {
        sprintf(buf, "%.900s/liprefs.js", conf_dir);
        name = buf;
        break;
    }

    default:
        abort ();
    }

    return (char *) name;
}