gecko-dev/cmd/xfe/addrbk.c

158 строки
3.8 KiB
C
Исходник Обычный вид История

1998-03-28 05:44:41 +03:00
/* -*- 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
1998-03-28 05:44:41 +03:00
/* database file is not html anymore ...
*/
PR_snprintf(tmp, sizeof (tmp), "abook.nab");
DIR_GetServerPreferences (&m_directories, tmp);
#endif /* MOZ_MAIL_NEWS */
1998-03-28 05:44:41 +03:00
return m_directories;
}
ABook* FE_GetAddressBook(MSG_Pane *pane)
{
return AddrBook;
}
#ifdef MOZ_MAIL_NEWS
1998-03-28 05:44:41 +03:00
void FE_InitAddrBook()
{
static XP_List *directories = NULL;
char *oldFile;
1998-03-28 05:44:41 +03:00
XP_File oldFp = 0;
char tmp[1024];
char *tmp2;
1998-03-28 05:44:41 +03:00
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);
1998-03-28 05:44:41 +03:00
*/
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);
1998-03-28 05:44:41 +03:00
}/* if */
free(oldFile);
}
1998-03-28 05:44:41 +03:00
/* 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)
1998-03-28 05:44:41 +03:00
{
{
1998-06-25 09:50:45 +04:00
#ifndef MOZ_NEWADDR
DIR_Server *pabDir = NULL;
DIR_GetPersonalAddressBook(directories, &pabDir);
AB_InitializeAddressBook(pabDir, &AddrBook, tmp);
1998-06-25 09:50:45 +04:00
#endif
}
free (tmp2);
1998-03-28 05:44:41 +03:00
}
}
void FE_CloseAddrBook() {
1998-06-25 09:50:45 +04:00
#ifndef MOZ_NEWADDR
1998-03-28 05:44:41 +03:00
AB_CloseAddressBook(&AddrBook);
1998-06-25 09:50:45 +04:00
#endif
1998-03-28 05:44:41 +03:00
}
1998-06-23 01:19:46 +04:00
#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)
1998-06-23 01:19:46 +04:00
{
return 0 ;
}
#endif
1998-06-23 01:19:46 +04:00
#endif