DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Header

Untracked file

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 *
 * The contents of this file are subject to the Netscape Public License
 * Version 1.0 (the "NPL"); you may not use this file except in
 * compliance with the NPL.  You may obtain a copy of the NPL at
 * http://www.mozilla.org/NPL/
 *
 * Software distributed under the NPL is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
 * for the specific language governing rights and limitations under the
 * NPL.
 *
 * The Initial Developer of this code under the NPL is Netscape
 * Communications Corporation.  Portions created by Netscape are
 * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
 * Reserved.
 */

/*
   addrbk.c	- a hack at the new address book STUFF

	       Created:    Benjie Chen - 6/8/96
	       Copied lots of code from hot.c
	       Then deleted lots of code from hot.c
	       Then deleted lots of code from here
	       Then faked bunch of code here

	       Modified:   Major changes - 7/17
	       		   - I am separating the addressing window stuff
			     from the address book stuff and putting the
			     addressing window stuff off mailcompose window
			     to allow multiple addressing windows and
			     multiple mailcompose window instances - Benjie
*/



#include "mozilla.h"
#include "xp_file.h"
#include "addrbk.h"


/* list of DIR_Server 
*/
static ABook*       AddrBook = NULL; 
extern ABook*       fe_GetABook(MWContext *); 

/*****************************************************
 * Actual code begins here 
 */
extern ABook* fe_GetABook(MWContext *context) 
{
  return AddrBook;
}

extern XP_List* FE_GetDirServers()
{
  	char tmp[256];
	XP_List* m_directories = XP_ListNew();

#ifdef MOZ_MAIL_NEWS
	/* database file is not html anymore ... 
	 */
	PR_snprintf(tmp, sizeof (tmp), "abook.nab"); 
	DIR_GetServerPreferences (&m_directories, tmp);
#endif /* MOZ_MAIL_NEWS */
	return m_directories;
}

ABook* FE_GetAddressBook(MSG_Pane *pane)
{
	return AddrBook;
}

#ifdef MOZ_MAIL_NEWS
void FE_InitAddrBook() 
{

	static XP_List *directories = NULL;
	char     *oldFile;
	XP_File  oldFp = 0;

  	char     tmp[1024];
	char	*tmp2;
  	char    *home = getenv("HOME");
  	/*DIR_Server *dir;*/

  	if (!home) home = "";

	oldFile = fe_GetConfigDirFilename("addrbook.db"); 
	if (oldFile) {
		oldFp = XP_FileOpen(oldFile, xpAddrBook, "r");
		if (oldFp) {
			char    newFile[256];
			XP_File newFp = 0;

			/* extern int XP_FileClose(XP_File file);
			 */
			XP_FileClose(oldFp);

			PR_snprintf(newFile, sizeof (newFile), "%s", "abook.nab");
			newFp = XP_FileOpen(newFile, xpAddrBookNew, "r");
			if (!newFp) {
				/* Rename file for backward compatibility reason
				 *   extern int XP_FileRename(const char * from, XP_FileType fromtype,
				 *     const char * to,   XP_FileType totype);
				 */
				XP_FileRename(oldFile, xpAddrBook,
							  newFile, xpAddrBookNew);
			}/* !newFp */
			else
				XP_FileClose(newFp);
	
		}/* if */
		free(oldFile);
	}

	/* all right, lets do the list of directories and stuff */
	directories = XP_ListNew();

	/* first the addressbook stuff */
	/* database file is not html anymore ... */
	PR_snprintf(tmp, sizeof (tmp), "abook.nab"); 

	DIR_GetServerPreferences (&directories, tmp);
	tmp2 = fe_GetConfigDirFilename("address-book.html");
	if (tmp2)
	{
		{
#ifndef MOZ_NEWADDR
			DIR_Server *pabDir = NULL;
			DIR_GetPersonalAddressBook(directories, &pabDir);
			AB_InitializeAddressBook(pabDir, &AddrBook, tmp);
#endif
		}
		free (tmp2);
	}
}

void FE_CloseAddrBook() {
#ifndef MOZ_NEWADDR
  AB_CloseAddressBook(&AddrBook);
#endif
}

#else
#if 0
/* compiler complains about definition vs. previous def at
   line 154 in file '../../include/dirprefs.h.  Dunno why, they're identical.
 */
extern XP_List* FE_GetDirServers(void)
{
  return 0 ;
}
#endif
#endif