home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / lib / libnet / mkalert.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  7.2 KB  |  294 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. #include "mkutils.h"
  19. #include "mkgeturl.h"
  20.  
  21. #include <stdio.h>
  22. #include <ctype.h>
  23. #include <stdarg.h>
  24.  
  25. PUBLIC Bool
  26. FE_SecurityDialog(MWContext * context, int message)
  27. {
  28.    switch(message)
  29.      {
  30.         case SD_INSECURE_POST_FROM_SECURE_DOC:
  31.         case SD_INSECURE_POST_FROM_INSECURE_DOC:
  32.         case SD_ENTERING_SECURE_SPACE:
  33.         case SD_LEAVING_SECURE_SPACE:
  34.         case SD_INSECURE_DOCS_WITHIN_SECURE_DOCS_NOT_SHOWN:
  35.         case SD_REDIRECTION_TO_INSECURE_DOC:
  36.         case SD_REDIRECTION_TO_SECURE_SITE:
  37.         printf("Security message: %d", message);
  38.     }
  39. }
  40.  
  41. void
  42. TESTFE_AllConnectionsComplete(MWContext * context)
  43. {
  44. }
  45.  
  46. void
  47. TESTFE_EnableClicking(MWContext * context)
  48. {
  49. }
  50.  
  51. void 
  52. XFE_SetProgressBarPercent(MWContext * context, int percent)
  53. {
  54. }
  55.  
  56. PUBLIC const char * 
  57. FE_UsersMailAddress(void)
  58. {
  59.     return("montulli@netscape.com");
  60. }
  61.  
  62. PUBLIC const char * 
  63. FE_UsersFullName(void)
  64. {
  65.     return(NULL);
  66. }
  67.  
  68. extern void sample_exit_routine(URL_Struct *URL_s,int status,MWContext *window_id);
  69.  
  70. PUBLIC void 
  71. FE_EditMailMessage (MWContext *context,
  72.                                const char * to_address,
  73.                                const char * subject,
  74.                                const char * newsgroups,
  75.                                const char * references,
  76.                                const char * news_url)
  77. {
  78. #if 0
  79.     URL_Struct * URL_s;
  80.     char buffer[356];
  81.  
  82.     XP_SPRINTF(buffer, "mailto:%.256s", to_address);
  83.  
  84.     URL_s = NET_CreateURLStruct(buffer, FALSE);
  85.  
  86.     StrAllocCopy(URL_s->post_headers,"Subject: This is a test\r\nX-URL: http://bogus\r\n");
  87.     StrAllocCopy(URL_s->post_data,"This is a test, this is only a test\n");
  88.     URL_s->method = URL_POST_METHOD;
  89.  
  90.     NET_GetURL(URL_s, FO_CACHE_AND_PRESENT, (MWContext *)0 ,sample_exit_routine);
  91.  
  92.     return;
  93. #endif
  94. }
  95.  
  96.  
  97. PUBLIC void
  98. FE_ConnectToRemoteHost(MWContext * window_id, int url_type, char * hostname, char * port, char * username)
  99. {
  100. }
  101.  
  102.  
  103. extern NET_StreamClass *
  104. IL_NewStream             (int         format_out,
  105.                           void       *data_obj,
  106.                           URL_Struct *URL_s,
  107.                           MWContext  *context)
  108. {
  109. return(NULL);
  110. }
  111.  
  112. fe_MakeViewSourceStream (int         format_out,
  113.                           void       *data_obj,
  114.                           URL_Struct *URL_s,
  115.                           MWContext  *context)
  116. {
  117. return(NULL);
  118. }
  119.  
  120. fe_MakeMailToStream (int         format_out,
  121.                           void       *data_obj,
  122.                           URL_Struct *URL_s,
  123.                           MWContext  *context)
  124. {
  125. return(NULL);
  126. }
  127.  
  128.  
  129. fe_MakePPMStream      (int         format_out,
  130.                           void       *data_obj,
  131.                           URL_Struct *URL_s,
  132.                           MWContext  *context)
  133. {
  134. return(NULL);
  135. }
  136.  
  137. Bool
  138. TESTFE_ShowAllNewsArticles(MWContext * window_id)
  139. {
  140. return(FALSE);
  141. }
  142.  
  143.  
  144. intn
  145. LO_Format(void * data_object, PA_Tag *tag, intn status)
  146. {
  147. return(0);
  148. }
  149.  
  150.  
  151. void
  152. XP_Trace (const char* message, ...)
  153. {
  154.     int actualLen;
  155.     static char xp_Buffer[2048];
  156.     va_list stack;
  157.  
  158.     va_start (stack, message);
  159.     actualLen = vsprintf (xp_Buffer, message, stack);
  160.     va_end (stack);
  161.  
  162.     fwrite(xp_Buffer, 1, strlen(xp_Buffer), stderr);
  163.     fprintf (stderr, "\n");
  164. }
  165.  
  166.  
  167.  
  168. PUBLIC int32 FE_GetContextID(MWContext * window_id)
  169. {
  170.    return((int) window_id);
  171. }
  172.  
  173. PUBLIC int TESTFE_FileSortMethod(MWContext * window_id)
  174. {
  175.    return(SORT_BY_NAME);
  176. }
  177.  
  178. PUBLIC Bool TESTFE_UseFancyNewsgroupListing (MWContext * window_id)
  179. {
  180.    return(TRUE);
  181. }
  182.  
  183. PUBLIC Bool TESTFE_UseFancyFTP(MWContext * window_id)
  184. {
  185.    return(1);
  186. }
  187.  
  188. PUBLIC int TESTFE_CheckForInterrupt(void * window_id)
  189. {
  190.    /* check check check check and check again */
  191.    return(0);
  192. }
  193.  
  194. PUBLIC void TESTFE_Spinner (MWContext * window_id)
  195. {
  196.   /* big wheel keep on rolling. Proud Mary keep on.... */
  197. }
  198.  
  199. PUBLIC void TESTFE_Alert (MWContext * window_id, CONST char * mess)
  200. {
  201.     TRACEMSG(("WWW Alert:  %s\n", mess));
  202. }
  203.  
  204. PUBLIC void TESTFE_Progress (MWContext * window_id, CONST char * mess)
  205. {
  206.     TRACEMSG(("   %s ...\n", mess));
  207. }
  208.  
  209. PUBLIC void TESTFE_GraphProgressInit (MWContext * window_id, URL_Struct *url, int32 total_length)
  210. {
  211.     TRACEMSG(("  GraphInit: %s is %d long...\n", url->address, total_length));
  212. }
  213.  
  214. PUBLIC void TESTFE_GraphProgressDestroy (MWContext * window_id, URL_Struct *url, int32 bytes_transferred, int32 total_length)
  215. {
  216.     TRACEMSG(("  GraphDestroy: %s is %d long...\n", url->address, total_length));
  217. }
  218.  
  219. PUBLIC void TESTFE_GraphProgress (MWContext * window_id, URL_Struct *url, int32 cur_length,  int32 length_delta, int32 total_length)
  220. {
  221.     TRACEMSG(("  GraphProgress: %d of %d ...\n", cur_length, total_length));
  222. }
  223.  
  224. PUBLIC Bool TESTFE_Confirm (MWContext * window_id, CONST char * mess)
  225. {
  226.   char Reply[4];
  227.   char *URep;
  228.   
  229.   fprintf(stderr, "WWW: %s (y/n) ", mess);
  230.                       
  231.  
  232.   fgets(Reply, 4, stdin); /* get reply, max 3 characters */
  233.   URep=Reply;
  234.   while (*URep) {
  235.     if (*URep == '\n') {
  236.     *URep = (char)0;    /* Overwrite newline */
  237.     break;
  238.     }
  239.     *URep=toupper(*URep);
  240.     URep++;    /* This was previously embedded in the TOUPPER */
  241.                 /* call an it became evaluated twice because   */
  242.   }
  243.  
  244.   if ((XP_STRCMP(Reply,"YES")==0) || (XP_STRCMP(Reply,"Y")==0))
  245.     return(YES);
  246.   else
  247.     return(NO);
  248. }
  249.  
  250. /*    Prompt for answer and get text back
  251. */
  252. PUBLIC char * TESTFE_Prompt (MWContext * window_id, CONST char * mess, CONST char * deflt)
  253. {
  254.     char temp[512];
  255.     char * t_string = 0;
  256.  
  257.     fprintf(stderr, "Prompt: %s", mess);
  258.     if (deflt) fprintf(stderr, " (RETURN for [%s]) ", deflt);
  259.     
  260.     fgets(temp, 200, stdin);
  261.     temp[XP_STRLEN(temp)-1] = (char)0;    /* Overwrite newline */
  262.    
  263.     StrAllocCopy(t_string, *temp ? temp : deflt);
  264.     return t_string;
  265. }
  266.  
  267.  
  268. /*    Prompt for password without echoing the reply
  269. */
  270. PUBLIC char * TESTFE_PromptPassword (MWContext * window_id, CONST char * mess)
  271. {
  272.     char *result = NULL;
  273.     char pw[80];
  274.  
  275.     printf("%s",mess ? mess : "Type your password:");
  276.     scanf("%s",pw);
  277.  
  278.     StrAllocCopy(result, pw);
  279.     return result;
  280. }
  281.  
  282.  
  283. PUBLIC void TESTFE_PromptUsernameAndPassword (MWContext * window_id, 
  284.                       CONST char *    mess,
  285.                       char **        username,
  286.                       char **        password)
  287. {
  288.     if (mess)
  289.     fprintf(stderr, "WWW: %s\n", mess);
  290.     *username = TESTFE_Prompt(window_id, "Username: ", *username);
  291.     *password = TESTFE_PromptPassword(window_id, "Password: ");
  292. }
  293.  
  294.