home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / xfe / altmail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  4.4 KB  |  171 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.  altmail.c
  20.  
  21.  Implementation for alternate mailers.
  22. **********************************************************************/
  23.  
  24. #include "altmail.h"
  25. #include "xp.h"
  26. #include "xfe.h"
  27. #include "prefapi.h"
  28. #include "nspr.h"
  29.  
  30. int (*altmail_RegisterMailClient)(void) = NULL;
  31. int (*altmail_UnRegisterMailClient)(void) = NULL;
  32. int (*altmail_OpenMailSession)(void*, void*) = NULL;
  33. int (*altmail_CloseMailSession)(void) = NULL;
  34. int (*altmail_ComposeMailMessage)(void* reserved, char* to, char* org, 
  35.                                 char* subject, char* body, char* 
  36.                                 cc, char* bcc) = NULL;
  37. int (*altmail_ShowMailBox)(void) = NULL;
  38. int (*altmail_ShowMessageCenter)(void) = NULL;
  39. char* (*altmail_GetMenuItemString)(void) = NULL;
  40. char* (*altmail_GetNewsMenuItemString)(void) = NULL;
  41. char* (*altmail_HandleNewsUrl)(char*) = NULL;
  42.  
  43.  
  44. /*
  45.  * change_resource
  46.  */
  47. static void
  48. change_resource(char* resource, char* value)
  49. {
  50.     XrmDatabase database;
  51.  
  52.     if ( resource == NULL || value == NULL ) return;
  53.  
  54.     database = XrmGetDatabase(fe_display);
  55.     XrmPutStringResource(&database, resource, value);
  56. }
  57.  
  58.  
  59. /*
  60.  * AltMailInit
  61.  */
  62. void
  63. AltMailInit(void)
  64. {
  65.     XP_Bool use_altmail = FALSE;
  66.     char* lib_name;
  67.     PRLibrary* lib;
  68.  
  69.     PREF_GetBoolPref("mail.use_altmail", &use_altmail);
  70.  
  71.     if ( use_altmail == FALSE ) return;
  72.  
  73.     PREF_CopyCharPref("mail.altmail_dll", &lib_name);
  74.  
  75.     if ( lib_name == NULL || *lib_name == '\0' ) return;
  76.  
  77.     lib = PR_LoadLibrary(lib_name);
  78.  
  79.     if ( lib == NULL ) return;
  80.  
  81.     altmail_RegisterMailClient = PR_FindSymbol(lib, "RegisterMailClient");
  82.     altmail_UnRegisterMailClient = PR_FindSymbol(lib, "UnRegisterMailClient");
  83.     altmail_OpenMailSession = PR_FindSymbol(lib, "OpenMailSession");
  84.     altmail_CloseMailSession = PR_FindSymbol(lib, "CloseMailSession");
  85.     altmail_ComposeMailMessage = PR_FindSymbol(lib, "ComposeMailMessage");
  86.     altmail_ShowMailBox = PR_FindSymbol(lib, "ShowMailBox");
  87.     altmail_ShowMessageCenter = PR_FindSymbol(lib, "ShowMessageCenter");
  88.     altmail_GetMenuItemString = PR_FindSymbol(lib, "GetMenuItemString");
  89.     altmail_GetNewsMenuItemString = PR_FindSymbol(lib, "GetNewsMenuItemString");
  90.     altmail_HandleNewsUrl = PR_FindSymbol(lib, "HandleNewsUrl");
  91.  
  92.     if ( altmail_RegisterMailClient ) {
  93.         altmail_RegisterMailClient();
  94.     }
  95.  
  96.     if ( altmail_GetMenuItemString ) {
  97.         change_resource("*menuBar*openInbox.labelString", 
  98.                         altmail_GetMenuItemString());
  99.     }
  100.  
  101.     if ( altmail_GetNewsMenuItemString ) {
  102.         change_resource("*menuBar*openNewsgroups.labelString", 
  103.                         altmail_GetNewsMenuItemString());
  104.     }
  105. }
  106.  
  107.  
  108. /*
  109.  * AltMailOpenSession
  110.  */
  111. void
  112. AltMailOpenSession(void)
  113. {
  114.     static int session_open = FALSE;
  115.  
  116.     if ( session_open == FALSE && altmail_OpenMailSession != NULL ) {
  117.         altmail_OpenMailSession(NULL, NULL);
  118.         session_open = TRUE;
  119.     }
  120. }
  121.  
  122.  
  123. /*
  124.  * AltMailExit
  125.  */
  126. void
  127. AltMailExit(void)
  128. {
  129.     if ( altmail_CloseMailSession ) {
  130.         altmail_CloseMailSession();
  131.     }
  132.     if ( altmail_UnRegisterMailClient ) {
  133.         altmail_UnRegisterMailClient();
  134.     }
  135. }
  136.  
  137.  
  138. /*
  139.  * FE_AlternateCompose
  140.  */
  141. void
  142. FE_AlternateCompose(char* from, char* reply_to, char* to, char* cc, 
  143.                     char* bcc, char* fcc, char* newsgroups, 
  144.                     char* followup_to, char* organization, char* subject, 
  145.                     char* references, char* other_random_headers, 
  146.                     char* priority, char* attachment, char* newspost_url, 
  147.                     char* body)
  148. {
  149.     if ( altmail_ComposeMailMessage ) {
  150.         altmail_ComposeMailMessage(NULL, to, organization, subject, body,
  151.                                    cc, bcc);
  152.     }
  153. }
  154.  
  155.  
  156. /*
  157.  * FE_AlternateNewsReader
  158.  */
  159. int
  160. FE_AlternateNewsReader(char* url)
  161. {
  162.     if ( altmail_HandleNewsUrl ) {
  163.         altmail_HandleNewsUrl(url);
  164.         return 1;
  165.     }
  166.  
  167.     return 0;
  168. }
  169.  
  170.  
  171.