home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / include / addrbook.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  22.9 KB  |  450 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef _AddrBook_H_
  20. #define    _AddrBook_H_
  21.  
  22. #include "xp_core.h"
  23. #include "msgcom.h"
  24. #include "abdefn.h"
  25. #include "dirprefs.h"
  26.  
  27. #ifdef XP_CPLUSPLUS
  28. class MLPane;
  29. class ABPane;
  30. class AddressPane;
  31. class ABook;
  32. #else
  33. typedef struct MLPane MLPane;
  34. typedef struct ABPane ABPane;
  35. typedef struct AddressPane AddressPane;
  36. typedef struct ABook ABook;
  37. #endif
  38.  
  39. XP_BEGIN_PROTOS
  40.  
  41. #define AB_kGromitDbFileName "da5id.nab"
  42. #define AB_CONFIG_USE_GROMIT_FILE_FORMAT 1
  43.  
  44. /****************************************************************************/
  45. /* Get the address book .*/
  46. /****************************************************************************/
  47. ABook* FE_GetAddressBook(MSG_Pane* pane);
  48.  
  49. /****************************************************************************/
  50. /* This is a callback into the FE to bring up a modal property sheet */
  51. /* for modifying an existing entry or creating a new one from a */
  52. /* person structure. If entryId != MSG_MESSAGEIDNONE then it is the */
  53. /* entryID of the entry to modify.  Each FE should Return TRUE if the user */
  54. /* hit ok return FALSE if they hit cancel and return -1 if there was a */
  55. /* problem creating the window or something */
  56. /****************************************************************************/
  57. int FE_ShowPropertySheetFor (MWContext* context, ABID entryID, 
  58.         PersonEntry* pPerson);
  59.  
  60. /****************************************************************************/
  61. /* Return whether or not to attach the users */
  62. /* vcard to outgoing messages */
  63. /****************************************************************************/
  64. XP_Bool AB_AttachUsersvCard(void);
  65.  
  66. /****************************************************************************/
  67. /* Convert the address book error code to  .*/
  68. /****************************************************************************/
  69. int AB_ConvertABErrToMKErr(uint32 err); 
  70.  
  71. /****************************************************************************/
  72. /* Create and initialize the address book pane which is the a view on an */
  73. /* address book. It will provide a sorted list of all the address book */
  74. /* entries ids . This is intended to be used in a two step */
  75. /* process of create and then initialize */
  76. /****************************************************************************/
  77. int AB_InitAddressBookPane(ABPane** ppABookPane, 
  78.                                 DIR_Server* dir,
  79.                                 ABook* pABook,
  80.                                 MWContext* context,
  81.                                 MSG_Master* master,
  82.                                 unsigned long sortBy,
  83.                                 XP_Bool sortForward);
  84.  
  85. /****************************************************************************/
  86. /* Create the address book pane which is the a view on an */
  87. /* address book. */
  88. /****************************************************************************/
  89. int AB_CreateAddressBookPane(ABPane** ppABookPane, 
  90.                                 MWContext* context,
  91.                                 MSG_Master* master);
  92.  
  93. /****************************************************************************/
  94. /* Initialize the address book pane which is the a view on an */
  95. /* address book. It will provide a sorted list of all the address book */
  96. /* entries ids .*/
  97. /****************************************************************************/
  98. int AB_InitializeAddressBookPane(ABPane* ppABookPane, 
  99.                                 DIR_Server* dir,
  100.                                 ABook* pABook,
  101.                                 unsigned long sortBy,
  102.                                 XP_Bool sortForward);
  103.  
  104. /****************************************************************************/
  105. /* Close the address book pane. Called when the view on an address book */
  106. /* is being closed */
  107. /****************************************************************************/
  108. int AB_CloseAddressBookPane(ABPane** ppABookPane);
  109.  
  110.  
  111. /****************************************************************************/
  112. /* Create and initialize a mailing list pane which is the a view on an */
  113. /* mailing list. It will provide a sorted view of all the entries in a */
  114. /* mailing list. This is intended to be used in as a one one step process */
  115. /****************************************************************************/
  116. int AB_InitMailingListPane(MLPane** ppABookPane, 
  117.                                  ABID* listID,
  118.                                 DIR_Server* dir,
  119.                                 ABook* pABook,
  120.                                 MWContext* context,
  121.                                 MSG_Master* master,
  122.                                 unsigned long sortBy,
  123.                                 XP_Bool sortForward);
  124.  
  125. /****************************************************************************/
  126. /* Create a mailing list pane which is the a view on an */
  127. /* mailing list. This is intended to be used in a two step */
  128. /* process of create and then initialize */
  129. /****************************************************************************/
  130. int AB_CreateMailingListPane(MLPane** ppABookPane, 
  131.                                 MWContext* context,
  132.                                 MSG_Master* master);
  133.  
  134. /****************************************************************************/
  135. /* Initialize a mailing list pane which is the a view on an */
  136. /* mailing list. It will provide a sorted view of all the entries in a */
  137. /* mailing list.*/
  138. /****************************************************************************/
  139. int AB_InitializeMailingListPane(MLPane* pABookPane, 
  140.                                  ABID* listID,
  141.                                 DIR_Server* dir,
  142.                                 ABook* pABook);
  143.  
  144. /****************************************************************************/
  145. /* Close the mailing list pane. Called when the view on an mailing list */
  146. /* is being closed */
  147. /****************************************************************************/
  148. int AB_CloseMailingListPane(MLPane** ppMLPane);
  149.  
  150. /****************************************************************************/
  151. /* Register a compose window with the address book */
  152. /* The composition pane should do this everytime it opens */
  153. /* so that name completion can take place */
  154. /****************************************************************************/
  155. int AB_RegisterComposeWindow(ABook* pABook, DIR_Server* directory);
  156.  
  157. /****************************************************************************/
  158. /* Unregister a compose window with the address book */
  159. /* The composition pane should do this when it is getting closed */
  160. /****************************************************************************/
  161. int AB_UnregisterComposeWindow(ABook* pABook, DIR_Server* directory);
  162.  
  163. /****************************************************************************/
  164. /* Change the Current directory */
  165. /****************************************************************************/
  166. int AB_ChangeDirectory(ABPane* pABookPane, DIR_Server* directory);
  167.  
  168. /****************************************************************************/
  169. /* Begin a search on the LDAP directory */
  170. /****************************************************************************/
  171. int AB_SearchDirectory(ABPane* pABookPane, char* searchString);
  172.  
  173. /****************************************************************************/
  174. /* Process LDAP search results*/
  175. /****************************************************************************/
  176. int AB_LDAPSearchResults(ABPane* pABookPane, MSG_ViewIndex index, int32 num);
  177.  
  178. /****************************************************************************/
  179. /* Finish an LDAP search */
  180. /****************************************************************************/
  181. int AB_FinishSearch(ABPane* pABookPane, MWContext* context);
  182.  
  183. /****************************************************************************/
  184. /* Create and initialize the address book database */
  185. /****************************************************************************/
  186. int AB_InitAddressBook(DIR_Server* directory, ABook** ppABook);
  187.  
  188.  
  189. /****************************************************************************/
  190. /* Create and initialize the address book database */
  191. /* upgrading the old html address book if we need to*/
  192. /****************************************************************************/
  193. int AB_InitializeAddressBook(DIR_Server* directory, ABook** ppABook,
  194.     const char * pOldHTMLBook);
  195.  
  196.  
  197. /****************************************************************************/
  198. /* Close the address book database */
  199. /****************************************************************************/
  200. int AB_CloseAddressBook(ABook** ppABook);
  201.  
  202. /****************************************************************************/
  203. /* Add a person entry to the database */
  204. /****************************************************************************/
  205. int AB_AddUser(DIR_Server* dir, ABook* pABook, PersonEntry* pPerson, 
  206.                ABID* entryID);
  207. int AB_AddUserWithUI (MWContext *context, PersonEntry *person,
  208.                       DIR_Server *pab, XP_Bool lastOneToAdd);
  209.  
  210. /****************************************************************************/
  211. /* Add an entry to the database from a url*/
  212. /****************************************************************************/
  213. int AB_AddSenderToAddBook(ABook* pABook, MWContext* context, char* author, 
  214.                           char* url);
  215.  
  216. /****************************************************************************/
  217. /* Add a mailing list to the database */
  218. /****************************************************************************/
  219. int AB_AddMailingList(DIR_Server* dir, ABook* pABook, 
  220.                       MailingListEntry* pABList, ABID* entryID);
  221.  
  222. /****************************************************************************/
  223. /* Perform a command on the selected indices */
  224. /* Right now this will only work on delete and mail to */
  225. /****************************************************************************/
  226. int AB_Command (ABPane* pane, AB_CommandType command,
  227.                  MSG_ViewIndex* indices, int32 numindices);
  228.  
  229. /****************************************************************************/
  230. /* Before the front end displays any menu (each time), it should call this */
  231. /* function for each command on that menu to determine how it should be */
  232. /* displayed. */
  233. /****************************************************************************/
  234.  int AB_CommandStatus (ABPane* pane,
  235.                           AB_CommandType command,
  236.                           MSG_ViewIndex* indices, int32 numindices,
  237.                           XP_Bool *selectable_p,
  238.                           MSG_COMMAND_CHECK_STATE *selected_p,
  239.                           const char **display_string,
  240.                           XP_Bool *plural_p);
  241.  
  242. /****************************************************************************/
  243. /* Get and Set how full names are constructed for people entries */
  244. /* first last or last first */
  245. /****************************************************************************/
  246. XP_Bool AB_GetSortByFirstName(ABook* pABook);
  247. void    AB_SetSortByFirstName(ABook* pABook, XP_Bool sortby);
  248.  
  249. /****************************************************************************/
  250. /* Import Export various formats that will prompt for filename */
  251. /****************************************************************************/
  252. int AB_ImportFromFile(ABPane* pABookPane, MWContext* context);
  253. int AB_ExportToFile(ABPane* pABookPane, MWContext* context);
  254.  
  255. /****************************************************************************/
  256. /* This is only used right now for drop/paste of a vcard */
  257. /****************************************************************************/
  258. int AB_ImportFromVcard(AddressPane* pABookPane, const char* pVcard);
  259.  
  260. /****************************************************************************/
  261. /* This is only used right now for drop of a vcard */
  262. /* It it a helper function that can be called by the FE to */
  263. /* convert a vcard to an valid rfc822 address that can be used */
  264. /* in the address widget of the compose window */
  265. /****************************************************************************/
  266. int AB_ConvertVCardsToExpandedName(ABook* pABook, const char* vCardString, 
  267.         XP_List ** ppEntries, int32 * numEntries);
  268.  
  269. /****************************************************************************/
  270. /* Import Export various formats that wont do any prompting */
  271. /* This is needed for the command line interface and automatic upgrading */
  272. /****************************************************************************/
  273. int AB_ImportFromFileNamed(ABook* pABook, char* filename);
  274. int AB_ExportToFileNamed(ABook* pABook, char* filename);
  275.  
  276. /****************************************************************************/
  277. /* This function is only called from the backend. */
  278. /* It is used to process the addbook url that is only used in mimevcrd.c */
  279. /* It probably will never be called by an FE */
  280. /****************************************************************************/
  281. int AB_ImportFromVcardURL(ABook* pABook, MWContext* context, const char* pVcard);
  282.  
  283. /****************************************************************************/
  284. /* This will create a buffer with a vcard in it.  It is used for constructing */
  285. /* a buffer that can be used in drag/drop or copy to the clipboard */
  286. /****************************************************************************/
  287. int AB_ExportToVCard(ABook* pABook, DIR_Server* dir, ABID entryID, 
  288.                      char** ppVcard);
  289. int AB_ExportToVCardFromPerson(ABook* pABook, PersonEntry* pPerson, 
  290.                      char** ppVcard);
  291.  
  292. /****************************************************************************/
  293. /* This will create a temp file for a vcard.  This function is only called */
  294. /* from the backend compose window for constructing a vcard attachment */
  295. /* It probably will never be called by an FE */
  296. /****************************************************************************/
  297. int AB_ExportToVCardTempFile(ABook* pABook, DIR_Server* dir, ABID entryID, 
  298.                              char** filename);
  299.  
  300. /****************************************************************************/
  301. /* Operations on panes/view */
  302. /****************************************************************************/
  303.  
  304. /****************************************************************************/
  305. /* Get the unique database id at a particular pane index */
  306. /****************************************************************************/
  307. ABID    AB_GetEntryIDAt(AddressPane* pABookPane, uint32 index);
  308. uint32    AB_GetIndexOfEntryID (AddressPane* pABookPane, ABID entryID);
  309. int        AB_GetEntryLine (ABPane * pABookPane, uint32 index,
  310.                      AB_EntryLine * pEntryLine);
  311.  
  312. /****************************************************************************/
  313. /* Get info about how a pane is sorted */
  314. /****************************************************************************/
  315. XP_Bool AB_GetPaneSortedAscending(ABPane * pABookPane);
  316. ABID AB_GetPaneSortedBy(ABPane * pABookPane);
  317.  
  318. /****************************************************************************/
  319. /* Get number of entries */
  320. /* For the address book you can ask for ALL, people, or mailing lists */
  321. /* For mailing list panes you will only be returned ALL */
  322. /****************************************************************************/
  323. int AB_GetEntryCount(DIR_Server* dir, ABook* pABook, uint32* count, 
  324.                        ABID etype, ABID listID);
  325.  
  326. /****************************************************************************/
  327. /* Modify information for an entry (person or mailing list) */
  328. /****************************************************************************/
  329. int AB_ModifyUser(DIR_Server* dir, ABook* pABook, ABID entryID, PersonEntry* pPerson);
  330. int AB_ModifyMailingList(DIR_Server* dir, ABook* pABook, ABID entryID, 
  331.                          MailingListEntry* pEntry);
  332.  
  333.  
  334. /****************************************************************************/
  335. /* Modify information for a mailing list that has been modified */
  336. /* but not committed in a mailing list pane */
  337. /****************************************************************************/
  338. int AB_ModifyMailingListAndEntries(MLPane* pMLPane, MailingListEntry* pABList);
  339.  
  340. /****************************************************************************/
  341. /* Modify information for a mailing list that has been modified */
  342. /* but not committed in a mailing list pane.  Some of the error checking */
  343. /* that was perfomed in add/replace in a mailing list had to be moved to */
  344. /* here.  The fe's should be calling this function instead of the one above */
  345. /****************************************************************************/
  346. int AB_ModifyMailingListAndEntriesWithChecks(MLPane* pMLPane, MailingListEntry* pList,
  347.     MSG_ViewIndex *index, MSG_ViewIndex begIndex);
  348.  
  349. /****************************************************************************/
  350. /* Get information for every entry (person or mailing list) */
  351. /****************************************************************************/
  352. int AB_GetType(DIR_Server* dir, ABook* pABook, ABID entryID, ABID* type);
  353. int AB_GetFullName(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  354. int AB_GetNickname(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  355.  
  356. /****************************************************************************/
  357. /* Get information for every person entry */
  358. /****************************************************************************/
  359. int AB_GetGivenName(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  360. int AB_GetMiddleName(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  361. int AB_GetFamilyName(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  362. int AB_GetCompanyName(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  363. int AB_GetLocality(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  364. int AB_GetRegion(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  365. int AB_GetEmailAddress(DIR_Server* dir, ABook* pABook, ABID entryID, char* paddress);
  366. int AB_GetInfo(DIR_Server* dir, ABook* pABook, ABID entryID, char* pinfo);
  367. int AB_GetHTMLMail(DIR_Server* dir, ABook* pABook, ABID entryID, XP_Bool* pHTML);
  368. int AB_GetExpandedName(DIR_Server* dir, ABook* pABook, ABID entryID, char** pname);
  369. int AB_GetTitle(DIR_Server* dir, ABook* pABook, ABID entryID, char* ptitle);
  370. int AB_GetPOAddress(DIR_Server* dir, ABook* pABook, ABID entryID, char* ppoaddress);
  371. int AB_GetStreetAddress(DIR_Server* dir, ABook* pABook, ABID entryID, char* pstreet);
  372. int AB_GetZipCode(DIR_Server* dir, ABook* pABook, ABID entryID, char* pzip);
  373. int AB_GetCountry(DIR_Server* dir, ABook* pABook, ABID entryID, char* pcountry);
  374. int AB_GetWorkPhone(DIR_Server* dir, ABook* pABook, ABID entryID, char* pphone);
  375. int AB_GetFaxPhone(DIR_Server* dir, ABook* pABook, ABID entryID, char* pphone);
  376. int AB_GetHomePhone(DIR_Server* dir, ABook* pABook, ABID entryID, char* pphone);
  377. int AB_GetDistName(DIR_Server* dir, ABook* pABook, ABID entryID, char* pname);
  378. int AB_GetSecurity(DIR_Server* dir, ABook* pABook, ABID entryID, short* security);
  379. int AB_GetCoolAddress(DIR_Server* dir, ABook* pABook, ABID entryID, char* paddress);
  380. int AB_GetUseServer(DIR_Server* dir, ABook* pABook, ABID entryID, short* use);
  381.  
  382. int AB_GetEntryIDForPerson(DIR_Server* dir, ABook* pABook, ABID* entryID, 
  383.                            PersonEntry* pPerson);
  384.  
  385. /****************************************************************************/
  386. /* Add/Remove entries for a mailing list */
  387. /****************************************************************************/
  388. int AB_GetEntryCountInMailingList(MLPane* pMLPane, uint32* count);
  389. int AB_AddIDToMailingListAt(MLPane* pMLPane, ABID entryID, MSG_ViewIndex index);
  390. int AB_RemoveIDFromMailingListAt(MLPane* pMLPane, MSG_ViewIndex index);
  391. int AB_ReplaceIDInMailingListAt(MLPane* pMLPane, ABID entryID, MSG_ViewIndex index);
  392. int AB_AddPersonToMailingListAt(MLPane* pMLPane, PersonEntry* person, 
  393.                                 MSG_ViewIndex index, ABID* entryID);
  394.  
  395. /****************************************************************************/
  396. /* Find index to first entry in a pane that matches the typedown */
  397. /****************************************************************************/
  398. int AB_GetIndexMatchingTypedown(ABPane* pABookPane, 
  399.     MSG_ViewIndex* index, const char* aValue, MSG_ViewIndex startIndex);
  400.  
  401. /****************************************************************************/
  402. /* Return the id of the name/nickname entries that match a string.  If we */
  403. /* find a nickname that uniquely matches then return otherwise check the */
  404. /* full name field. */
  405. /****************************************************************************/
  406. int AB_GetIDForNameCompletion(ABook* pABook, DIR_Server* dir, ABID* entryID, 
  407.                              ABID* field, const char* aValue);
  408.  
  409. /****************************************************************************/
  410. /* Return a string of expanded addresses from the address book */
  411. /****************************************************************************/
  412. char* AB_ExpandHeaderString(ABook* pABook, const char* addresses, 
  413.                               XP_Bool expandfull);
  414.  
  415. /****************************************************************************/
  416. /* Return the ids of mailing lists that a entry is a member of */
  417. /* This was mentioned at one time as a requirement in the ui but it may */
  418. /* go away */
  419. /****************************************************************************/
  420. int AB_GetMailingListsContainingID(ABook* pABook, MSG_ViewIndex* plist, 
  421.                                      ABID entryID);
  422.  
  423. /****************************************************************************/
  424. /* This should not be called by any of the fes.  I placed it here so it */
  425. /* could be called in the backend by other functions such as those in libmsg */
  426. /* This allows for an increase in performance when adding a bunch of entries */
  427. /* to the database */
  428. /****************************************************************************/
  429. int AB_SetIsImporting(ABook* pABook, XP_Bool isImporting);
  430.  
  431. /****************************************************************************/
  432. /* This should not be called by any of the fes.  I placed it here so it */
  433. /* could be called in the backend by other functions in libmsg */
  434. /* This will set the wantsHTML boolean to be set for all address book */
  435. /* entries with that match the name and email address. */
  436. /****************************************************************************/
  437. int AB_SetHTMLForPerson(DIR_Server* dir, ABook* pABook, PersonEntry* pPerson);
  438.  
  439. /****************************************************************************/
  440. /* This should not be called by any of the fes.  I placed it here so it */
  441. /* could be called in the backend by other functions in libmsg */
  442. /* This will break a name apart into first name and last name. */
  443. /* Be sure and set the WinCSID in the person structure */
  444. /****************************************************************************/
  445. int AB_BreakApartFirstName (ABook* pABook, PersonEntry* pPerson);
  446.  
  447. XP_END_PROTOS
  448.  
  449. #endif
  450.