зеркало из https://github.com/mozilla/pjs.git
added Pop3 protocol implementation
This commit is contained in:
Родитель
7edf71fe93
Коммит
694dd06bf6
|
@ -27,6 +27,9 @@ LIBRARY_NAME=localmail
|
|||
|
||||
CPPSRCS = \
|
||||
nsMSGFolderDataSource.cpp \
|
||||
nsPop3Protocol.cpp \
|
||||
nsPop3URL.cpp \
|
||||
nsPop3Sink.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/config.mk
|
||||
|
|
|
@ -20,29 +20,42 @@ IGNORE_MANIFEST=1
|
|||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
LIBRARY_NAME=msglocal_s
|
||||
LIBRARY_NAME=msglocal
|
||||
MODULE= mailnews
|
||||
REQUIRES=xpcom nspr rdf
|
||||
|
||||
DEFINES=-D_IMPL_NS_HTML -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS= nsMSGFolderDataSource.cpp \
|
||||
$(NULL)
|
||||
CPPSRCS= \
|
||||
nsMSGFolderDataSource.cpp \
|
||||
nsPop3Protocol.cpp \
|
||||
nsPop3URL.cpp \
|
||||
nsPop3Sink.cpp \
|
||||
$(NULL)
|
||||
|
||||
CPP_OBJS= .\$(OBJDIR)\nsMSGFolderDataSource.obj \
|
||||
$(NULL)
|
||||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsMSGFolderDataSource.obj \
|
||||
.\$(OBJDIR)\nsPop3Protocol.obj \
|
||||
.\$(OBJDIR)\nsPop3URL.obj \
|
||||
.\$(OBJDIR)\nsPop3Sink.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
EXPORTS= \
|
||||
$(NULL)
|
||||
nsPop3Protocol.h \
|
||||
nsPop3URL.h \
|
||||
nsPop3Sink.h \
|
||||
$(NULL)
|
||||
|
||||
LINCS= -I$(PUBLIC)\xpcom \
|
||||
-I$(PUBLIC)\mailnews \
|
||||
-I$(PUBLIC)\raptor \
|
||||
-I$(PUBLIC)\netlib \
|
||||
-I$(PUBLIC)\security \
|
||||
-I$(PUBLIC)\rdf \
|
||||
$(NULL)
|
||||
|
||||
MYLIBS = $(DIST)\lib\msgcore_s.lib
|
||||
MYLIBS = $(DIST)\lib\msgcore.lib
|
||||
|
||||
LCFLAGS = \
|
||||
$(LCFLAGS) \
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,413 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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.
|
||||
*/
|
||||
|
||||
#ifndef nsPop3Protocol_h__
|
||||
#define nsPop3Protocol_h__
|
||||
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsITransport.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIPop3URL.h"
|
||||
#include "nsIPop3Sink.h"
|
||||
|
||||
#include "rosetta.h"
|
||||
#include HG09893
|
||||
#include HG47233
|
||||
|
||||
#include "prerror.h"
|
||||
#include "xp_hash.h"
|
||||
#include "xpgetstr.h"
|
||||
|
||||
/* A more guaranteed way of making sure that we never get duplicate messages
|
||||
is to always get each message's UIDL (if the server supports it)
|
||||
and use these for storing up deletes which were not committed on the
|
||||
server. Based on our experience, it looks like we do NOT need to
|
||||
do this (it has performance tradeoffs, etc.). To turn it on, three
|
||||
things need to happen: #define POP_ALWAYS_USE_UIDL_FOR_DUPLICATES, verify that
|
||||
the uidl's are correctly getting added when the delete response is received,
|
||||
and change the POP3_QUIT_RESPONSE state to flush the newly committed deletes. */
|
||||
|
||||
/*
|
||||
* Cannot have the following line uncommented. It is defined.
|
||||
* #ifdef POP_ALWAYS_USE_UIDL_FOR_DUPLICATES will always be evaluated
|
||||
* as TRUE.
|
||||
*
|
||||
#define POP_ALWAYS_USE_UIDL_FOR_DUPLICATES 0
|
||||
*
|
||||
*/
|
||||
|
||||
// Temporary implementation
|
||||
#if 0
|
||||
extern int MK_OUT_OF_MEMORY;
|
||||
extern int MK_POP3_DELE_FAILURE;
|
||||
extern int MK_POP3_LIST_FAILURE;
|
||||
extern int MK_POP3_MESSAGE_WRITE_ERROR;
|
||||
extern int MK_POP3_NO_MESSAGES;
|
||||
extern int MK_POP3_OUT_OF_DISK_SPACE;
|
||||
extern int MK_POP3_PASSWORD_FAILURE;
|
||||
extern int MK_POP3_PASSWORD_UNDEFINED;
|
||||
extern int MK_POP3_RETR_FAILURE;
|
||||
extern int MK_POP3_SERVER_ERROR;
|
||||
extern int MK_POP3_USERNAME_FAILURE;
|
||||
extern int MK_POP3_USERNAME_UNDEFINED;
|
||||
extern int MK_TCP_READ_ERROR;
|
||||
extern int MK_TCP_WRITE_ERROR;
|
||||
extern int XP_ERRNO_EWOULDBLOCK;
|
||||
extern int XP_NO_ANSWER;
|
||||
extern int XP_THE_POP3_SERVER_DOES_NOT_SUPPORT_UIDL_ETC;
|
||||
extern int XP_RECEIVING_MESSAGE_OF;
|
||||
extern int XP_THE_POP3_SERVER_DOES_NOT_SUPPORT_THE_TOP_COMMAND;
|
||||
extern int XP_THE_PREVIOUSLY_ENTERED_PASSWORD_IS_INVALID_ETC;
|
||||
extern int XP_CONNECT_HOST_CONTACTED_SENDING_LOGIN_INFORMATION;
|
||||
extern int XP_PASSWORD_FOR_POP3_USER;
|
||||
extern int MK_MSG_DOWNLOAD_COUNT;
|
||||
extern int MK_UNABLE_TO_CONNECT;
|
||||
extern int MK_CONNECTION_REFUSED;
|
||||
extern int MK_CONNECTION_TIMED_OUT;
|
||||
#else
|
||||
#define MK_OUT_OF_MEMORY -207
|
||||
#define MK_POP3_DELE_FAILURE -320
|
||||
#define MK_POP3_LIST_FAILURE -317
|
||||
#define MK_POP3_MESSAGE_WRITE_ERROR -322
|
||||
#define MK_POP3_NO_MESSAGES -316
|
||||
#define MK_POP3_OUT_OF_DISK_SPACE -321
|
||||
#define MK_POP3_PASSWORD_FAILURE -315
|
||||
#define MK_POP3_PASSWORD_UNDEFINED -313
|
||||
#define MK_POP3_RETR_FAILURE -319
|
||||
#define MK_POP3_SERVER_ERROR -311
|
||||
#define MK_POP3_USERNAME_FAILURE -314
|
||||
#define MK_POP3_USERNAME_UNDEFINED -312
|
||||
#define MK_TCP_READ_ERROR -252
|
||||
#define MK_TCP_WRITE_ERROR -236
|
||||
#define XP_ERRNO_EWOULDBLOCK WSAEWOULDBLOCK
|
||||
#define XP_NO_ANSWER 14401
|
||||
#define XP_THE_POP3_SERVER_DOES_NOT_SUPPORT_UIDL_ETC 14402
|
||||
#define XP_RECEIVING_MESSAGE_OF 14403
|
||||
#define XP_THE_POP3_SERVER_DOES_NOT_SUPPORT_THE_TOP_COMMAND 14404
|
||||
#define XP_THE_PREVIOUSLY_ENTERED_PASSWORD_IS_INVALID_ETC 14405
|
||||
#define XP_CONNECT_HOST_CONTACTED_SENDING_LOGIN_INFORMATION 14406
|
||||
#define XP_PASSWORD_FOR_POP3_USER 14590
|
||||
#define MK_MSG_DOWNLOAD_COUNT 14734
|
||||
#define MK_UNABLE_TO_CONNECT -281
|
||||
#define MK_CONNECTION_REFUSED -242
|
||||
#define MK_CONNECTION_TIMED_OUT -241
|
||||
#endif
|
||||
|
||||
#define POP3_PORT 110 // The IANA port for Pop3
|
||||
#define OUTPUT_BUFFER_SIZE 512 // maximum size of command string
|
||||
|
||||
/* structure to hold data pertaining to the active state of
|
||||
* a transfer in progress.
|
||||
*
|
||||
*/
|
||||
|
||||
enum Pop3CapabilityEnum {
|
||||
POP3_CAPABILITY_UNDEFINED = 0x00000000,
|
||||
POP3_AUTH_LOGIN_UNDEFINED = 0x00000001,
|
||||
POP3_HAS_AUTH_LOGIN = 0x00000002,
|
||||
POP3_XSENDER_UNDEFINED = 0x00000004,
|
||||
POP3_HAS_XSENDER = 0x00000008,
|
||||
POP3_GURL_UNDEFINED = 0x00000010,
|
||||
POP3_HAS_GURL = 0x00000020,
|
||||
POP3_UIDL_UNDEFINED = 0x00000040,
|
||||
POP3_HAS_UIDL = 0x00000080,
|
||||
POP3_XTND_XLST_UNDEFINED = 0x00000100,
|
||||
POP3_HAS_XTND_XLST = 0x00000200,
|
||||
POP3_TOP_UNDEFINED = 0x00000400,
|
||||
POP3_HAS_TOP = 0x00000800
|
||||
};
|
||||
|
||||
enum Pop3StatesEnum {
|
||||
POP3_READ_PASSWORD,
|
||||
POP3_START_CONNECT,
|
||||
POP3_FINISH_CONNECT,
|
||||
POP3_WAIT_FOR_RESPONSE,
|
||||
POP3_WAIT_FOR_START_OF_CONNECTION_RESPONSE,
|
||||
POP3_SEND_USERNAME,
|
||||
POP3_SEND_PASSWORD,
|
||||
POP3_SEND_STAT,
|
||||
POP3_GET_STAT,
|
||||
POP3_SEND_LIST,
|
||||
POP3_GET_LIST,
|
||||
POP3_SEND_UIDL_LIST,
|
||||
POP3_GET_UIDL_LIST,
|
||||
POP3_SEND_XTND_XLST_MSGID,
|
||||
POP3_GET_XTND_XLST_MSGID,
|
||||
POP3_GET_MSG,
|
||||
POP3_SEND_TOP,
|
||||
POP3_TOP_RESPONSE,
|
||||
POP3_SEND_RETR,
|
||||
POP3_RETR_RESPONSE,
|
||||
POP3_SEND_DELE,
|
||||
POP3_DELE_RESPONSE,
|
||||
POP3_SEND_QUIT,
|
||||
POP3_DONE,
|
||||
POP3_ERROR_DONE,
|
||||
POP3_FREE,
|
||||
/* The following 3 states support the use of the 'TOP' command instead of UIDL
|
||||
for leaving mail on the pop server -km */
|
||||
POP3_START_USE_TOP_FOR_FAKE_UIDL,
|
||||
POP3_SEND_FAKE_UIDL_TOP,
|
||||
POP3_GET_FAKE_UIDL_TOP,
|
||||
POP3_SEND_AUTH,
|
||||
POP3_AUTH_RESPONSE,
|
||||
POP3_AUTH_LOGIN,
|
||||
POP3_AUTH_LOGIN_RESPONSE,
|
||||
POP3_SEND_XSENDER,
|
||||
POP3_XSENDER_RESPONSE,
|
||||
POP3_SEND_GURL,
|
||||
POP3_GURL_RESPONSE,
|
||||
#ifdef POP_ALWAYS_USE_UIDL_FOR_DUPLICATES
|
||||
POP3_QUIT_RESPONSE,
|
||||
#endif
|
||||
POP3_INTERRUPTED
|
||||
};
|
||||
|
||||
enum MsgBiffState {
|
||||
MSG_BIFF_UNKNOWN,
|
||||
MSG_BIFF_NEWMAIL,
|
||||
MSG_BIFF_NOMAIL
|
||||
};
|
||||
|
||||
#define KEEP 'k' /* If we want to keep this item on server. */
|
||||
#define DELETE_CHAR 'd' /* If we want to delete this item. */
|
||||
#define TOO_BIG 'b' /* item left on server because it was too big */
|
||||
|
||||
typedef struct Pop3AllocedString { /* Need this silliness as a place to
|
||||
keep the strings that are allocated
|
||||
for the keys in the hash table. ### */
|
||||
char* str;
|
||||
struct Pop3AllocedString* next;
|
||||
} Pop3AllocedString;
|
||||
|
||||
typedef struct Pop3UidlHost {
|
||||
char* host;
|
||||
char* user;
|
||||
XP_HashTable hash;
|
||||
Pop3AllocedString* strings;
|
||||
struct Pop3UidlHost* next;
|
||||
} Pop3UidlHost;
|
||||
|
||||
typedef struct Pop3MsgInfo {
|
||||
PRInt32 size;
|
||||
char* uidl;
|
||||
} Pop3MsgInfo;
|
||||
|
||||
typedef struct _Pop3ConData {
|
||||
// MSG_Pane* pane; /* msglib pane object. */
|
||||
|
||||
PRBool leave_on_server; /* Whether we're supposed to leave messages
|
||||
on server. */
|
||||
PRInt32 size_limit; /* Leave messages bigger than this on the
|
||||
server and only download a partial
|
||||
message. */
|
||||
|
||||
Pop3StatesEnum next_state; /* the next state or action to be taken */
|
||||
Pop3StatesEnum next_state_after_response;
|
||||
PRBool pause_for_read; /* Pause now for next read? */
|
||||
|
||||
PRBool command_succeeded; /* did the last command succeed? */
|
||||
char *command_response; /* text of last response */
|
||||
PRInt32 first_msg;
|
||||
// TCP_ConData *tcp_con_data; /* Data pointer for tcp connect state machine */
|
||||
char *data_buffer;
|
||||
PRUint32 data_buffer_size;
|
||||
|
||||
char *obuffer; /* line buffer for output to msglib */
|
||||
PRUint32 obuffer_size;
|
||||
PRUint32 obuffer_fp;
|
||||
|
||||
PRInt32 really_new_messages;
|
||||
PRInt32 real_new_counter;
|
||||
PRInt32 number_of_messages;
|
||||
Pop3MsgInfo *msg_info; /* Message sizes and uidls (used only if we
|
||||
are playing games that involve leaving
|
||||
messages on the server). */
|
||||
PRInt32 last_accessed_msg;
|
||||
PRInt32 cur_msg_size;
|
||||
char *output_buffer;
|
||||
PRBool truncating_cur_msg; /* are we using top and uidl? */
|
||||
PRBool msg_del_started; /* True if MSG_BeginMailDel...
|
||||
* called
|
||||
*/
|
||||
PRBool only_check_for_new_mail;
|
||||
MsgBiffState biffstate; /* If just checking for, what the answer is. */
|
||||
|
||||
PRBool password_failed; /* flag for password querying */
|
||||
void *msg_closure;
|
||||
PRInt32 bytes_received_in_message;
|
||||
PRInt32 total_folder_size;
|
||||
|
||||
PRInt32 total_download_size; /* Number of bytes we're going to
|
||||
download. Might be much less
|
||||
than the total_folder_size. */
|
||||
|
||||
PRBool graph_progress_bytes_p; /* whether we should display info about
|
||||
the bytes transferred (usually we
|
||||
display info about the number of
|
||||
messages instead.) */
|
||||
|
||||
Pop3UidlHost *uidlinfo;
|
||||
XP_HashTable newuidl;
|
||||
char *only_uidl; /* If non-NULL, then load only this UIDL. */
|
||||
|
||||
/* the following three fields support the
|
||||
use of the 'TOP' command instead of UIDL
|
||||
for leaving mail on the pop server -km */
|
||||
|
||||
/* the current message that we are retrieving
|
||||
with the TOP command */
|
||||
PRInt32 current_msg_to_top;
|
||||
|
||||
/* we will download this many in
|
||||
POP3_GET_MSG */
|
||||
PRInt32 number_of_messages_not_seen_before;
|
||||
/* reached when we have TOPped
|
||||
all of the new messages */
|
||||
PRBool found_new_message_boundary;
|
||||
|
||||
/* if this is true then we don't stop
|
||||
at new message boundary, we have to
|
||||
TOP em all to delete some */
|
||||
PRBool delete_server_message_during_top_traversal;
|
||||
PRBool get_url;
|
||||
PRBool seenFromHeader;
|
||||
char *sender_info;
|
||||
} Pop3ConData;
|
||||
|
||||
class nsPop3Protocol : public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
nsPop3Protocol(nsIURL* aURL, nsITransport* aTransport);
|
||||
|
||||
virtual ~nsPop3Protocol();
|
||||
|
||||
PRInt32 Load(nsIURL *aURL);
|
||||
PRBool IsRunning() { return m_isRunning; };
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamListener interface
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
NS_IMETHOD GetBindInfo(nsIURL* aURL, nsStreamBindingInfo* aInfo)
|
||||
{ return NS_OK;}; // for now
|
||||
NS_IMETHOD OnDataAvailable(nsIURL* aURL, nsIInputStream* aInputStream,
|
||||
PRUint32 aLength);
|
||||
NS_IMETHOD OnStartBinding(nsIURL* aURL, const char* aContentType);
|
||||
NS_IMETHOD OnStopBinding(nsIURL* aURL, nsresult aStatus, const PRUnichar*
|
||||
aMsg);
|
||||
|
||||
NS_IMETHOD OnProgress(nsIURL* aURL, PRUint32 pProgress, PRUint32
|
||||
aProgressMax)
|
||||
{ return NS_OK; };
|
||||
NS_IMETHOD OnStatus(nsIURL* aURL, const PRUnichar* aMsg)
|
||||
{ return NS_OK; };
|
||||
|
||||
public:
|
||||
|
||||
const char* GetUsername() { return m_username; };
|
||||
void SetUsername(const char* name);
|
||||
|
||||
const char* GetPassword() { return m_password; };
|
||||
void SetPassword(const char* password);
|
||||
|
||||
private:
|
||||
|
||||
PRUint32 m_pop3CapabilityFlags;
|
||||
char* m_username;
|
||||
char* m_password;
|
||||
Pop3ConData* m_pop3ConData;
|
||||
nsIPop3URL* m_nsIPop3URL;
|
||||
nsITransport* m_transport;
|
||||
nsIOutputStream* m_outputStream; // from the transport
|
||||
nsIStreamListener* m_outputConsumer; // from the transport
|
||||
nsIPop3Sink* m_nsIPop3Sink;
|
||||
PRBool m_isRunning;
|
||||
|
||||
/**********************************************************************
|
||||
* sounds like the following do not need to be included in the protocol
|
||||
* instance
|
||||
static PRInt8 uidl_cmp (const void* obj1, const void* obj2);
|
||||
static void put_hash(Pop3UidlHost* host, XP_HashTable table, const char*
|
||||
key, char value);
|
||||
static PRBool hash_empty_mapper(XP_HashTable hash, const void* key, void*
|
||||
value, void* closure);
|
||||
static PRBool hash_empty(XP_HashTable hash);
|
||||
|
||||
Pop3UidlHost* net_pop3_load_state(const char* host, const char* user);
|
||||
PRBool net_pop3_write_mapper(XP_HashTable hash, const void* key, void*
|
||||
value, void* closure);
|
||||
|
||||
void net_pop3_write_state(Pop3UidlHost* host);
|
||||
***********************************************************************/
|
||||
PRInt32 ReadLine(nsIInputStream* inputStream, PRUint32 length, char
|
||||
**line);
|
||||
PRInt32 Read(nsIInputStream* inputStream, PRUint32 length, char** buffer);
|
||||
|
||||
void FreeMsgInfo();
|
||||
PRInt32 WaitForStartOfConnectionResponse(nsIInputStream* inputStream,
|
||||
PRUint32 length);
|
||||
PRInt32 WaitForResponse(nsIInputStream* inputStream,
|
||||
PRUint32 length);
|
||||
PRInt32 Error(int err_code);
|
||||
PRInt32 SendCommand(const char * command);
|
||||
PRInt32 SendAuth();
|
||||
PRInt32 AuthResponse(nsIInputStream* inputStream,
|
||||
PRUint32 length);
|
||||
PRInt32 AuthLogin();
|
||||
PRInt32 AuthLoginResponse();
|
||||
PRInt32 SendUsername();
|
||||
PRInt32 SendPassword();
|
||||
PRInt32 SendStatOrGurl(PRBool sendStat);
|
||||
PRInt32 SendStat();
|
||||
PRInt32 GetStat();
|
||||
PRInt32 SendGurl();
|
||||
PRInt32 GurlResponse();
|
||||
PRInt32 SendList();
|
||||
PRInt32 GetList(nsIInputStream* inputStream,
|
||||
PRUint32 length);
|
||||
PRInt32 SendFakeUidlTop();
|
||||
PRInt32 StartUseTopForFakeUidl();
|
||||
PRInt32 GetFakeUidlTop(nsIInputStream* inputStream,
|
||||
PRUint32 length);
|
||||
PRInt32 SendXtndXlstMsgid();
|
||||
PRInt32 GetXtndXlstMsgid(nsIInputStream* inputStream,
|
||||
PRUint32 length);
|
||||
PRInt32 SendUidlList();
|
||||
PRInt32 GetUidlList(nsIInputStream* inputStream,
|
||||
PRUint32 length);
|
||||
PRInt32 GetMsg();
|
||||
PRInt32 SendTop();
|
||||
PRInt32 SendXsender();
|
||||
PRInt32 XsenderResponse();
|
||||
PRInt32 SendRetr();
|
||||
static PRInt32 RetrHandleLine(char *line, PRUint32 line_length, void* closure);
|
||||
|
||||
PRInt32 RetrResponse(nsIInputStream* inputStream,
|
||||
PRUint32 length);
|
||||
PRInt32 TopResponse(nsIInputStream* inputStream, PRUint32 length);
|
||||
PRInt32 SendDele();
|
||||
PRInt32 DeleResponse();
|
||||
PRInt32 CommitState(PRBool remove_last_entry);
|
||||
PRInt32 ProcessPop3State(nsIURL* aURL, nsIInputStream* aInputStream,
|
||||
PRUint32 aLength);
|
||||
};
|
||||
|
||||
#endif /* nsPop3Protocol_h__ */
|
|
@ -0,0 +1,302 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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.
|
||||
*/
|
||||
#include "nsPop3Sink.h"
|
||||
#include "prprf.h"
|
||||
#include "prlog.h"
|
||||
#include "nscore.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kIPop3SinkIID, NS_IPOP3SINK_IID);
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsPop3Sink, kIPop3SinkIID);
|
||||
|
||||
nsPop3Sink::nsPop3Sink()
|
||||
{
|
||||
m_authed = PR_FALSE;
|
||||
m_accountUrl = nsnull;
|
||||
m_biffState = 0;
|
||||
m_senderAuthed = PR_FALSE;
|
||||
m_outputBuffer = nsnull;
|
||||
m_outputBufferSize = 0;
|
||||
m_mailDirectory = 0;
|
||||
m_fileCounter = 0;
|
||||
}
|
||||
|
||||
nsPop3Sink::~nsPop3Sink()
|
||||
{
|
||||
PR_FREEIF(m_accountUrl);
|
||||
PR_FREEIF(m_outputBuffer);
|
||||
PR_FREEIF(m_mailDirectory);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::SetUserAuthenticated(PRBool authed)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (authed)
|
||||
printf("User is authenticated. \n");
|
||||
else
|
||||
printf("User is NOT authenticated. \n");
|
||||
#endif
|
||||
m_authed = authed;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::SetSenderAuthedFlag(void* closure, PRBool authed)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
if (authed)
|
||||
printf("Sender is authenticated. \n");
|
||||
else
|
||||
printf("Sender is NOT authenticated. \n");
|
||||
#endif
|
||||
m_authed = authed;
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::SetMailAccountURL(const char* urlString)
|
||||
{
|
||||
if (urlString)
|
||||
{
|
||||
PR_FREEIF(m_accountUrl);
|
||||
#ifdef DEBUG
|
||||
printf("Mail account URL: %s\n", urlString);
|
||||
#endif
|
||||
m_accountUrl = PL_strdup(urlString);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Null mail account URL.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::BeginMailDelivery(PRBool* aBool)
|
||||
{
|
||||
char *path = PR_smprintf("%s\\Inbox", m_mailDirectory);
|
||||
#ifdef DEBUG
|
||||
m_fileCounter++;
|
||||
#endif
|
||||
nsFilePath filePath(path);
|
||||
m_outFileStream = new nsOutputFileStream(filePath,
|
||||
PR_WRONLY | PR_CREATE_FILE | PR_APPEND);
|
||||
PR_FREEIF(path);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Begin mail message delivery.\n");
|
||||
#endif
|
||||
if (aBool)
|
||||
*aBool = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::EndMailDelivery()
|
||||
{
|
||||
if (m_outFileStream)
|
||||
{
|
||||
m_outFileStream->close();
|
||||
delete m_outFileStream;
|
||||
m_outFileStream = 0;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("End mail message delivery.\n");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::AbortMailDelivery()
|
||||
{
|
||||
if (m_outFileStream)
|
||||
{
|
||||
m_outFileStream->close();
|
||||
delete m_outFileStream;
|
||||
m_outFileStream = 0;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("Abort mail message delivery.\n");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::IncorporateBegin(const char* uidlString,
|
||||
nsIURL* aURL,
|
||||
PRUint32 flags,
|
||||
void** closure)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Incorporate message begin:\n");
|
||||
if (uidlString)
|
||||
printf("uidl string: %s\n", uidlString);
|
||||
#endif
|
||||
if (closure)
|
||||
*closure = (void*) this;
|
||||
PR_ASSERT(m_mailDirectory);
|
||||
|
||||
char *dummyEnvelope = GetDummyEnvelope();
|
||||
|
||||
*m_outFileStream << dummyEnvelope;
|
||||
*m_outFileStream << "X-Mozilla-Status: 8000\r\n";
|
||||
*m_outFileStream << "X-Mozilla-Status2: 00000000\r\n";
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::SetMailDirectory(const char* path)
|
||||
{
|
||||
PR_FREEIF(m_mailDirectory);
|
||||
if (path)
|
||||
m_mailDirectory = PL_strdup(path);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::GetMailDirectory(const char** path)
|
||||
{
|
||||
if (path)
|
||||
*path = m_mailDirectory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifndef CR
|
||||
#define CR '\r'
|
||||
#define LF '\n'
|
||||
#define LINEBREAK "\r\n"
|
||||
#define LINEBREAK_LEN 2
|
||||
#endif
|
||||
|
||||
char*
|
||||
nsPop3Sink::GetDummyEnvelope(void)
|
||||
{
|
||||
static char result[75];
|
||||
char *ct;
|
||||
time_t now = time ((time_t *) 0);
|
||||
#if defined (XP_WIN)
|
||||
if (now < 0 || now > 0x7FFFFFFF)
|
||||
now = 0x7FFFFFFF;
|
||||
#endif
|
||||
ct = ctime(&now);
|
||||
PR_ASSERT(ct[24] == CR || ct[24] == LF);
|
||||
ct[24] = 0;
|
||||
/* This value must be in ctime() format, with English abbreviations.
|
||||
strftime("... %c ...") is no good, because it is localized. */
|
||||
PL_strcpy(result, "From - ");
|
||||
PL_strcpy(result + 7, ct);
|
||||
PL_strcpy(result + 7 + 24, LINEBREAK);
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::IncorporateWrite(void* closure,
|
||||
const char* block,
|
||||
PRInt32 length)
|
||||
{
|
||||
if(length > 1 && *block == '.' &&
|
||||
(*(block+1) == '\r' || *(block+1) == '\n')) return NS_OK;
|
||||
|
||||
if (!m_outputBuffer || length > m_outputBufferSize)
|
||||
{
|
||||
if (!m_outputBuffer)
|
||||
m_outputBuffer = (char*) PR_MALLOC(length+1);
|
||||
else
|
||||
m_outputBuffer = (char*) PR_REALLOC(m_outputBuffer, length+1);
|
||||
|
||||
m_outputBufferSize = length;
|
||||
}
|
||||
if (m_outputBuffer)
|
||||
{
|
||||
memcpy(m_outputBuffer, block, length);
|
||||
*(m_outputBuffer + length) = 0;
|
||||
#ifdef DEBUG
|
||||
printf("%s\n", m_outputBuffer);
|
||||
#endif
|
||||
if (m_outFileStream)
|
||||
*m_outFileStream << m_outputBuffer;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::IncorporateComplete(void* closure)
|
||||
{
|
||||
if (m_outFileStream)
|
||||
*m_outFileStream << LINEBREAK;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Incorporate message complete.\n");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::IncorporateAbort(void* closure, PRInt32 status)
|
||||
{
|
||||
if (m_outFileStream)
|
||||
*m_outFileStream << LINEBREAK;
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Incorporate message abort.\n");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::BiffGetNewMail()
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Biff get new mail.\n");
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPop3Sink::SetBiffStateAndUpdateFE(PRUint32 aBiffState)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf("Set biff state: %d\n", aBiffState);
|
||||
#endif
|
||||
m_biffState = aBiffState;
|
||||
#ifdef DEBUG
|
||||
switch (aBiffState)
|
||||
{
|
||||
case 0:
|
||||
default:
|
||||
printf("Excuse me, Sir. I have no idea.\n");
|
||||
break;
|
||||
case 1:
|
||||
printf("You have got mail!\n");
|
||||
break;
|
||||
case 2:
|
||||
printf("You have no mail.\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/* -*- Mode: C++; tab-width: 2; 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.
|
||||
*/
|
||||
#ifndef nsPop3Sink_h__
|
||||
#define nsPop3Sink_h__
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIPop3Sink.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "prmem.h"
|
||||
#include "prio.h"
|
||||
#include "plstr.h"
|
||||
#include "prenv.h"
|
||||
|
||||
class nsPop3Sink : public nsIPop3Sink
|
||||
{
|
||||
public:
|
||||
nsPop3Sink();
|
||||
virtual ~nsPop3Sink();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD SetUserAuthenticated(PRBool authed);
|
||||
NS_IMETHOD SetMailAccountURL(const char* urlString);
|
||||
NS_IMETHOD BeginMailDelivery(PRBool *aBool);
|
||||
NS_IMETHOD EndMailDelivery();
|
||||
NS_IMETHOD AbortMailDelivery();
|
||||
NS_IMETHOD IncorporateBegin(const char* uidlString, nsIURL* aURL,
|
||||
PRUint32 flags, void** closure);
|
||||
NS_IMETHOD IncorporateWrite(void* closure, const char* block,
|
||||
PRInt32 length);
|
||||
NS_IMETHOD IncorporateComplete(void* closure);
|
||||
NS_IMETHOD IncorporateAbort(void* closure, PRInt32 status);
|
||||
NS_IMETHOD BiffGetNewMail();
|
||||
NS_IMETHOD SetBiffStateAndUpdateFE(PRUint32 aBiffState);
|
||||
NS_IMETHOD SetSenderAuthedFlag(void* closure, PRBool authed);
|
||||
NS_IMETHOD SetMailDirectory(const char* mailDirectory);
|
||||
NS_IMETHOD GetMailDirectory(const char** mailDirectory);
|
||||
|
||||
static char* GetDummyEnvelope(void);
|
||||
|
||||
protected:
|
||||
PRBool m_authed;
|
||||
char* m_accountUrl;
|
||||
PRUint32 m_biffState;
|
||||
PRBool m_senderAuthed;
|
||||
char* m_outputBuffer;
|
||||
PRInt32 m_outputBufferSize;
|
||||
char* m_mailDirectory;
|
||||
#ifdef DEBUG
|
||||
PRInt32 m_fileCounter;
|
||||
#endif
|
||||
nsOutputFileStream* m_outFileStream;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,797 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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) 1999 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifdef XP_PC
|
||||
#include <windows.h> // for InterlockedIncrement
|
||||
#endif
|
||||
|
||||
#include "nsIURL.h"
|
||||
#include "nsPop3URL.h"
|
||||
|
||||
#include "nsINetService.h" /* XXX: NS_FALSE */
|
||||
|
||||
#include "nsString.h"
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "prprf.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIPop3URLIID, NS_IPOP3URL_IID);
|
||||
static NS_DEFINE_IID(kIURLIID, NS_IURL_IID);
|
||||
|
||||
nsPop3URL::nsPop3URL(nsISupports* aContainer, nsIURLGroup* aGroup)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
// nsIPop3URL specific code...
|
||||
m_pop3Sink = nsnull;
|
||||
|
||||
m_errorMessage = nsnull;
|
||||
|
||||
// nsINetLibUrl specific state
|
||||
m_URL_s = nsnull;
|
||||
|
||||
// nsIURL specific state
|
||||
m_protocol = nsnull;
|
||||
m_host = nsnull;
|
||||
m_file = nsnull;
|
||||
m_ref = nsnull;
|
||||
m_port = -1;
|
||||
m_spec = nsnull;
|
||||
m_search = nsnull;
|
||||
|
||||
m_container = aContainer;
|
||||
NS_IF_ADDREF(m_container);
|
||||
// ParseURL(aSpec, aURL); // XXX whh
|
||||
}
|
||||
|
||||
nsPop3URL::~nsPop3URL()
|
||||
{
|
||||
NS_IF_RELEASE(m_container);
|
||||
|
||||
PR_FREEIF(m_errorMessage);
|
||||
|
||||
PR_FREEIF(m_spec);
|
||||
PR_FREEIF(m_protocol);
|
||||
PR_FREEIF(m_host);
|
||||
PR_FREEIF(m_file);
|
||||
PR_FREEIF(m_ref);
|
||||
PR_FREEIF(m_search);
|
||||
if (nsnull != m_URL_s)
|
||||
{
|
||||
// NET_DropURLStruct(m_URL_s);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_THREADSAFE_ADDREF(nsPop3URL);
|
||||
NS_IMPL_THREADSAFE_RELEASE(nsPop3URL);
|
||||
|
||||
nsresult nsPop3URL::QueryInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kINetlibURLIID, NS_INETLIBURL_IID);
|
||||
if (aIID.Equals(kIPop3URLIID) || aIID.Equals(kISupportsIID)) {
|
||||
*aInstancePtr = (void*) ((nsIPop3URL*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kIURLIID)) {
|
||||
*aInstancePtr = (void*) ((nsIURL*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kINetlibURLIID)) {
|
||||
*aInstancePtr = (void*) ((nsINetlibURL*)this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if defined(NS_DEBUG)
|
||||
/*
|
||||
* Check for the debug-only interface indicating thread-safety
|
||||
*/
|
||||
static NS_DEFINE_IID(kIsThreadsafeIID, NS_ISTHREADSAFE_IID);
|
||||
if (aIID.Equals(kIsThreadsafeIID)) {
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Begin nsIPop3URL specific support
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult nsPop3URL::SetPop3Sink(nsIPop3Sink* aPop3Sink)
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
if (aPop3Sink)
|
||||
{
|
||||
NS_IF_RELEASE(m_pop3Sink);
|
||||
m_pop3Sink = aPop3Sink;
|
||||
NS_ADDREF(m_pop3Sink);
|
||||
}
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetPop3Sink(nsIPop3Sink** aPop3Sink) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
if (aPop3Sink)
|
||||
{
|
||||
*aPop3Sink = m_pop3Sink;
|
||||
NS_IF_ADDREF(m_pop3Sink);
|
||||
}
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetErrorMessage (char * errorMessage)
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
if (errorMessage)
|
||||
{
|
||||
PR_FREEIF(m_errorMessage);
|
||||
m_errorMessage = errorMessage;
|
||||
}
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// caller must free using PR_FREE
|
||||
nsresult nsPop3URL::GetErrorMessage (char ** errorMessage) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
if (errorMessage)
|
||||
{
|
||||
if (m_errorMessage)
|
||||
*errorMessage = nsCRT::strdup(m_errorMessage);
|
||||
else
|
||||
*errorMessage = nsnull;
|
||||
}
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// End nsIPop3URL specific support
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Begin nsINetlibURL support
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
NS_METHOD nsPop3URL::SetURLInfo(URL_Struct *URL_s)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
/* Hook us up with the world. */
|
||||
m_URL_s = URL_s;
|
||||
// NET_HoldURLStruct(URL_s);
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD nsPop3URL::GetURLInfo(URL_Struct_** aResult) const
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (nsnull == aResult) {
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
} else {
|
||||
/* XXX: Should the URL be reference counted here?? */
|
||||
*aResult = m_URL_s;
|
||||
rv = NS_OK;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// End nsINetlibURL support
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// XXX recode to use nsString api's
|
||||
// XXX don't bother with port numbers
|
||||
// XXX don't bother with ref's
|
||||
// XXX null pointer checks are incomplete
|
||||
|
||||
nsresult nsPop3URL::ParseURL(const nsString& aSpec, const nsIURL* aURL)
|
||||
{
|
||||
// XXX hack!
|
||||
char* cSpec = aSpec.ToNewCString();
|
||||
|
||||
const char* uProtocol = nsnull;
|
||||
const char* uHost = nsnull;
|
||||
const char* uFile = nsnull;
|
||||
PRUint32 uPort;
|
||||
if (nsnull != aURL) {
|
||||
nsresult rslt = aURL->GetProtocol(&uProtocol);
|
||||
if (rslt != NS_OK) return rslt;
|
||||
rslt = aURL->GetHost(&uHost);
|
||||
if (rslt != NS_OK) return rslt;
|
||||
rslt = aURL->GetFile(&uFile);
|
||||
if (rslt != NS_OK) return rslt;
|
||||
rslt = aURL->GetHostPort(&uPort);
|
||||
if (rslt != NS_OK) return rslt;
|
||||
}
|
||||
|
||||
NS_LOCK_INSTANCE();
|
||||
|
||||
PR_FREEIF(m_protocol);
|
||||
PR_FREEIF(m_host);
|
||||
PR_FREEIF(m_file);
|
||||
PR_FREEIF(m_ref);
|
||||
PR_FREEIF(m_search);
|
||||
m_port = -1;
|
||||
|
||||
if (nsnull == cSpec) {
|
||||
if (nsnull == aURL) {
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
m_protocol = (nsnull != uProtocol) ? PL_strdup(uProtocol) : nsnull;
|
||||
m_host = (nsnull != uHost) ? PL_strdup(uHost) : nsnull;
|
||||
m_port = uPort;
|
||||
m_file = (nsnull != uFile) ? PL_strdup(uFile) : nsnull;
|
||||
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Strip out reference and search info
|
||||
char* ref = strpbrk(cSpec, "#?");
|
||||
if (nsnull != ref) {
|
||||
char* search = nsnull;
|
||||
if ('#' == *ref) {
|
||||
search = PL_strchr(ref + 1, '?');
|
||||
if (nsnull != search) {
|
||||
*search++ = '\0';
|
||||
}
|
||||
|
||||
PRIntn hashLen = PL_strlen(ref + 1);
|
||||
if (0 != hashLen) {
|
||||
m_ref = (char*) PR_Malloc(hashLen + 1);
|
||||
PL_strcpy(m_ref, ref + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
search = ref + 1;
|
||||
}
|
||||
|
||||
if (nsnull != search) {
|
||||
// The rest is the search
|
||||
PRIntn searchLen = PL_strlen(search);
|
||||
if (0 != searchLen) {
|
||||
m_search = (char*) PR_Malloc(searchLen + 1);
|
||||
PL_strcpy(m_search, search);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Terminate string at start of reference or search
|
||||
*ref = '\0';
|
||||
}
|
||||
|
||||
// The URL is considered absolute if and only if it begins with a
|
||||
// protocol spec. A protocol spec is an alphanumeric string of 1 or
|
||||
// more characters that is terminated with a colon.
|
||||
PRBool isAbsolute = PR_FALSE;
|
||||
char* cp;
|
||||
char* ap = cSpec;
|
||||
char ch;
|
||||
while (0 != (ch = *ap)) {
|
||||
if (((ch >= 'a') && (ch <= 'z')) ||
|
||||
((ch >= 'A') && (ch <= 'Z')) ||
|
||||
((ch >= '0') && (ch <= '9'))) {
|
||||
ap++;
|
||||
continue;
|
||||
}
|
||||
if ((ch == ':') && (ap - cSpec >= 2)) {
|
||||
isAbsolute = PR_TRUE;
|
||||
cp = ap;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isAbsolute) {
|
||||
// relative spec
|
||||
if (nsnull == aURL) {
|
||||
delete cSpec;
|
||||
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
// keep protocol and host
|
||||
m_protocol = (nsnull != uProtocol) ? PL_strdup(uProtocol) : nsnull;
|
||||
m_host = (nsnull != uHost) ? PL_strdup(uHost) : nsnull;
|
||||
m_port = uPort;
|
||||
|
||||
// figure out file name
|
||||
PRInt32 len = PL_strlen(cSpec) + 1;
|
||||
if ((len > 1) && (cSpec[0] == '/')) {
|
||||
// Relative spec is absolute to the server
|
||||
m_file = PL_strdup(cSpec);
|
||||
} else {
|
||||
if (cSpec[0] != '\0') {
|
||||
// Strip out old tail component and put in the new one
|
||||
char* dp = PL_strrchr(uFile, '/');
|
||||
if (!dp) {
|
||||
delete cSpec;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
PRInt32 dirlen = (dp + 1) - uFile;
|
||||
m_file = (char*) PR_Malloc(dirlen + len);
|
||||
PL_strncpy(m_file, uFile, dirlen);
|
||||
PL_strcpy(m_file + dirlen, cSpec);
|
||||
}
|
||||
else {
|
||||
m_file = PL_strdup(uFile);
|
||||
}
|
||||
}
|
||||
|
||||
/* Stolen from netlib's mkparse.c.
|
||||
*
|
||||
* modifies a url of the form /foo/../foo1 -> /foo1
|
||||
* and /foo/./foo1 -> /foo/foo1
|
||||
*/
|
||||
char *fwdPtr = m_file;
|
||||
char *urlPtr = m_file;
|
||||
|
||||
for(; *fwdPtr != '\0'; fwdPtr++)
|
||||
{
|
||||
|
||||
if(*fwdPtr == '/' && *(fwdPtr+1) == '.' && *(fwdPtr+2) == '/')
|
||||
{
|
||||
/* remove ./
|
||||
*/
|
||||
fwdPtr += 1;
|
||||
}
|
||||
else if(*fwdPtr == '/' && *(fwdPtr+1) == '.' && *(fwdPtr+2) == '.' &&
|
||||
(*(fwdPtr+3) == '/' || *(fwdPtr+3) == '\0'))
|
||||
{
|
||||
/* remove foo/..
|
||||
*/
|
||||
/* reverse the urlPtr to the previous slash
|
||||
*/
|
||||
if(urlPtr != m_file)
|
||||
urlPtr--; /* we must be going back at least one */
|
||||
for(;*urlPtr != '/' && urlPtr != m_file; urlPtr--)
|
||||
; /* null body */
|
||||
|
||||
/* forward the fwd_prt past the ../
|
||||
*/
|
||||
fwdPtr += 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* copy the url incrementaly
|
||||
*/
|
||||
*urlPtr++ = *fwdPtr;
|
||||
}
|
||||
}
|
||||
|
||||
*urlPtr = '\0'; /* terminate the url */
|
||||
|
||||
// Now that we've resolved the relative URL, we need to reconstruct
|
||||
// a URL spec from the components.
|
||||
ReconstructSpec();
|
||||
} else {
|
||||
// absolute spec
|
||||
|
||||
PR_FREEIF(m_spec);
|
||||
PRInt32 slen = aSpec.Length();
|
||||
m_spec = (char *) PR_Malloc(slen + 1);
|
||||
aSpec.ToCString(m_spec, slen+1);
|
||||
|
||||
// get protocol first
|
||||
PRInt32 plen = cp - cSpec;
|
||||
m_protocol = (char*) PR_Malloc(plen + 1);
|
||||
PL_strncpy(m_protocol, cSpec, plen);
|
||||
m_protocol[plen] = 0;
|
||||
cp++; // eat : in protocol
|
||||
|
||||
// skip over one, two or three slashes
|
||||
if (*cp == '/') {
|
||||
cp++;
|
||||
if (*cp == '/') {
|
||||
cp++;
|
||||
if (*cp == '/') {
|
||||
cp++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
delete cSpec;
|
||||
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
|
||||
#if defined(XP_UNIX) || defined (XP_MAC)
|
||||
// Always leave the top level slash for absolute file paths under Mac and UNIX.
|
||||
// The code above sometimes results in stripping all of slashes
|
||||
// off. This only happens when a previously stripped url is asked to be
|
||||
// parsed again. Under Win32 this is not a problem since file urls begin
|
||||
// with a drive letter not a slash. This problem show's itself when
|
||||
// nested documents such as iframes within iframes are parsed.
|
||||
|
||||
if (PL_strcmp(m_protocol, "file") == 0) {
|
||||
if (*cp != '/') {
|
||||
cp--;
|
||||
}
|
||||
}
|
||||
#endif /* XP_UNIX */
|
||||
|
||||
const char* cp0 = cp;
|
||||
if ((PL_strcmp(m_protocol, "resource") == 0) ||
|
||||
(PL_strcmp(m_protocol, "file") == 0)) {
|
||||
// resource/file url's do not have host names.
|
||||
// The remainder of the string is the file name
|
||||
PRInt32 flen = PL_strlen(cp);
|
||||
m_file = (char*) PR_Malloc(flen + 1);
|
||||
PL_strcpy(m_file, cp);
|
||||
|
||||
#ifdef NS_WIN32
|
||||
if (PL_strcmp(m_protocol, "file") == 0) {
|
||||
// If the filename starts with a "x|" where is an single
|
||||
// character then we assume it's a drive name and change the
|
||||
// vertical bar back to a ":"
|
||||
if ((flen >= 2) && (m_file[1] == '|')) {
|
||||
m_file[1] = ':';
|
||||
}
|
||||
}
|
||||
#endif /* NS_WIN32 */
|
||||
} else {
|
||||
// Host name follows protocol for http style urls
|
||||
cp = PL_strpbrk(cp, "/:");
|
||||
|
||||
if (nsnull == cp) {
|
||||
// There is only a host name
|
||||
PRInt32 hlen = PL_strlen(cp0);
|
||||
m_host = (char*) PR_Malloc(hlen + 1);
|
||||
PL_strcpy(m_host, cp0);
|
||||
}
|
||||
else {
|
||||
PRInt32 hlen = cp - cp0;
|
||||
m_host = (char*) PR_Malloc(hlen + 1);
|
||||
PL_strncpy(m_host, cp0, hlen);
|
||||
m_host[hlen] = 0;
|
||||
|
||||
if (':' == *cp) {
|
||||
// We have a port number
|
||||
cp0 = cp+1;
|
||||
cp = PL_strchr(cp, '/');
|
||||
m_port = strtol(cp0, (char **)nsnull, 10);
|
||||
}
|
||||
}
|
||||
|
||||
if (nsnull == cp) {
|
||||
// There is no file name
|
||||
// Set filename to "/"
|
||||
m_file = (char*) PR_Malloc(2);
|
||||
m_file[0] = '/';
|
||||
m_file[1] = 0;
|
||||
}
|
||||
else {
|
||||
// The rest is the file name
|
||||
PRInt32 flen = PL_strlen(cp);
|
||||
m_file = (char*) PR_Malloc(flen + 1);
|
||||
PL_strcpy(m_file, cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//printf("protocol='%s' host='%s' file='%s'\n", m_protocol, m_host, m_file);
|
||||
delete cSpec;
|
||||
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsPop3URL::ReconstructSpec(void)
|
||||
{
|
||||
PR_FREEIF(m_spec);
|
||||
|
||||
char portBuffer[10];
|
||||
if (-1 != m_port) {
|
||||
PR_snprintf(portBuffer, 10, ":%d", m_port);
|
||||
}
|
||||
else {
|
||||
portBuffer[0] = '\0';
|
||||
}
|
||||
|
||||
PRInt32 plen = PL_strlen(m_protocol) + PL_strlen(m_host) +
|
||||
PL_strlen(portBuffer) + PL_strlen(m_file) + 4;
|
||||
if (m_ref) {
|
||||
plen += 1 + PL_strlen(m_ref);
|
||||
}
|
||||
if (m_search) {
|
||||
plen += 1 + PL_strlen(m_search);
|
||||
}
|
||||
|
||||
m_spec = (char *) PR_Malloc(plen + 1);
|
||||
PR_snprintf(m_spec, plen, "%s://%s%s%s",
|
||||
m_protocol, ((nsnull != m_host) ? m_host : ""), portBuffer,
|
||||
m_file);
|
||||
|
||||
if (m_ref) {
|
||||
PL_strcat(m_spec, "#");
|
||||
PL_strcat(m_spec, m_ref);
|
||||
}
|
||||
if (m_search) {
|
||||
PL_strcat(m_spec, "?");
|
||||
PL_strcat(m_spec, m_search);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PRBool nsPop3URL::Equals(const nsIURL* aURL) const
|
||||
{
|
||||
PRBool bIsEqual;
|
||||
nsPop3URL* other;
|
||||
NS_LOCK_INSTANCE();
|
||||
// are they both Pop3 urls?? if yes...for now just compare the pointers until
|
||||
// I figure out if we need to check any of the guts for equality....
|
||||
if (((nsIURL*)aURL)->QueryInterface(kIPop3URLIID, (void**)&other) == NS_OK) {
|
||||
bIsEqual = other == this; // compare the pointers...
|
||||
}
|
||||
else
|
||||
bIsEqual = PR_FALSE;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return bIsEqual;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetProtocol(const char* *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = m_protocol;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetProtocol(const char *aNewProtocol)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
NS_LOCK_INSTANCE();
|
||||
m_protocol = nsCRT::strdup(aNewProtocol);
|
||||
ReconstructSpec();
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetHost(const char* *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = m_host;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetHost(const char *aNewHost)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
NS_LOCK_INSTANCE();
|
||||
m_host = nsCRT::strdup(aNewHost);
|
||||
ReconstructSpec();
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetFile(const char* *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = m_file;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetFile(const char *aNewFile)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
NS_LOCK_INSTANCE();
|
||||
m_file = nsCRT::strdup(aNewFile);
|
||||
ReconstructSpec();
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetSpec(const char* *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = m_spec;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetSpec(const char *aNewSpec)
|
||||
{
|
||||
// XXX is this right, or should we call ParseURL?
|
||||
nsresult rv = NS_OK;
|
||||
// NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
NS_LOCK_INSTANCE();
|
||||
rv = ParseURL(aNewSpec);
|
||||
#if 0
|
||||
PR_FREEIF(m_spec);
|
||||
m_spec = nsCRT::strdup(aNewSpec);
|
||||
#endif
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetRef(const char* *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = m_ref;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetRef(const char *aNewRef)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
NS_LOCK_INSTANCE();
|
||||
m_ref = nsCRT::strdup(aNewRef);
|
||||
ReconstructSpec();
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetHostPort(PRUint32 *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = m_port;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetHostPort(PRUint32 aNewPort)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
NS_LOCK_INSTANCE();
|
||||
m_port = aNewPort;
|
||||
ReconstructSpec();
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetSearch(const char* *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = m_search;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetSearch(const char *aNewSearch)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
NS_LOCK_INSTANCE();
|
||||
m_search = nsCRT::strdup(aNewSearch);
|
||||
ReconstructSpec();
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetContainer(nsISupports* *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = m_container;
|
||||
NS_IF_ADDREF(m_container);
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetContainer(nsISupports* container)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
NS_LOCK_INSTANCE();
|
||||
NS_IF_RELEASE(m_container);
|
||||
m_container = container;
|
||||
NS_IF_ADDREF(m_container);
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetContentLength(PRInt32 *len)
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*len = m_URL_s->content_length;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// End of nsIURL support
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// The following set of functions should become obsolete once we take them out of
|
||||
// nsIURL.....
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
nsresult nsPop3URL::GetLoadAttribs(nsILoadAttribs* *result) const
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*result = NULL;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetLoadAttribs(nsILoadAttribs* aLoadAttribs)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetPostHeader(const char* name, const char* value)
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
// XXX
|
||||
PR_ASSERT(0);
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetPostData(nsIInputStream* input)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetURLGroup(nsIURLGroup* *result) const
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::SetURLGroup(nsIURLGroup* group)
|
||||
{
|
||||
NS_ASSERTION(m_URL_s == nsnull, "URL has already been opened");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::GetServerStatus(PRInt32 *status)
|
||||
{
|
||||
NS_LOCK_INSTANCE();
|
||||
*status = m_URL_s->server_status;
|
||||
NS_UNLOCK_INSTANCE();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsPop3URL::ToString(PRUnichar* *aString) const
|
||||
{
|
||||
if (aString)
|
||||
*aString = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// End of functions which should be made obsolete after modifying nsIURL
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
|
@ -0,0 +1,105 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef nsPop3URL_h__
|
||||
#define nsPop3URL_h__
|
||||
|
||||
#include "nsIPop3URL.h"
|
||||
#include "nsINetlibURL.h" /* this should be temporary until Network N2 project lands */
|
||||
|
||||
class nsPop3URL : public nsIPop3URL, public nsINetlibURL
|
||||
{
|
||||
public:
|
||||
// from nsIURL:
|
||||
|
||||
// mscott: some of these we won't need to implement..as part of the netlib re-write we'll be removing them
|
||||
// from nsIURL and then we can remove them from here as well....
|
||||
NS_IMETHOD_(PRBool) Equals(const nsIURL *aURL) const;
|
||||
NS_IMETHOD GetSpec(const char* *result) const;
|
||||
NS_IMETHOD SetSpec(const char* spec);
|
||||
NS_IMETHOD GetProtocol(const char* *result) const;
|
||||
NS_IMETHOD SetProtocol(const char* protocol);
|
||||
NS_IMETHOD GetHost(const char* *result) const;
|
||||
NS_IMETHOD SetHost(const char* host);
|
||||
NS_IMETHOD GetHostPort(PRUint32 *result) const;
|
||||
NS_IMETHOD SetHostPort(PRUint32 port);
|
||||
NS_IMETHOD GetFile(const char* *result) const;
|
||||
NS_IMETHOD SetFile(const char* file);
|
||||
NS_IMETHOD GetRef(const char* *result) const;
|
||||
NS_IMETHOD SetRef(const char* ref);
|
||||
NS_IMETHOD GetSearch(const char* *result) const;
|
||||
NS_IMETHOD SetSearch(const char* search);
|
||||
NS_IMETHOD GetContainer(nsISupports* *result) const;
|
||||
NS_IMETHOD SetContainer(nsISupports* container);
|
||||
NS_IMETHOD GetLoadAttribs(nsILoadAttribs* *result) const; // make obsolete
|
||||
NS_IMETHOD SetLoadAttribs(nsILoadAttribs* loadAttribs); // make obsolete
|
||||
NS_IMETHOD GetURLGroup(nsIURLGroup* *result) const; // make obsolete
|
||||
NS_IMETHOD SetURLGroup(nsIURLGroup* group); // make obsolete
|
||||
NS_IMETHOD SetPostHeader(const char* name, const char* value); // make obsolete
|
||||
NS_IMETHOD SetPostData(nsIInputStream* input); // make obsolete
|
||||
NS_IMETHOD GetContentLength(PRInt32 *len);
|
||||
NS_IMETHOD GetServerStatus(PRInt32 *status); // make obsolete
|
||||
NS_IMETHOD ToString(PRUnichar* *aString) const;
|
||||
|
||||
// from nsINetlibURL:
|
||||
|
||||
NS_IMETHOD GetURLInfo(URL_Struct_ **aResult) const;
|
||||
NS_IMETHOD SetURLInfo(URL_Struct_ *URL_s);
|
||||
|
||||
// From nsIPop3URL
|
||||
|
||||
NS_IMETHOD SetPop3Sink(nsIPop3Sink* aPop3Sink);
|
||||
NS_IMETHOD GetPop3Sink(nsIPop3Sink** aPop3Sink) const;
|
||||
|
||||
NS_IMETHOD SetErrorMessage (char * errorMessage);
|
||||
// caller must free using PR_FREE
|
||||
NS_IMETHOD GetErrorMessage (char ** errorMessage) const;
|
||||
|
||||
// nsPop3URL
|
||||
|
||||
nsPop3URL(nsISupports* aContainer, nsIURLGroup* aGroup);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// protocol specific code to parse a url...
|
||||
nsresult ParseURL(const nsString& aSpec, const nsIURL* aURL = nsnull);
|
||||
|
||||
protected:
|
||||
virtual ~nsPop3URL();
|
||||
|
||||
/* Here's our link to the netlib world.... */
|
||||
URL_Struct *m_URL_s;
|
||||
|
||||
char *m_spec;
|
||||
char *m_protocol;
|
||||
char *m_host;
|
||||
char *m_file;
|
||||
char *m_ref;
|
||||
char *m_search;
|
||||
char *m_errorMessage;
|
||||
|
||||
PRInt32 m_port;
|
||||
nsISupports* m_container;
|
||||
|
||||
/* Pop3 specific event sinks */
|
||||
nsIPop3Sink* m_pop3Sink;
|
||||
|
||||
void ReconstructSpec(void);
|
||||
};
|
||||
|
||||
#endif // nsPop3URL_h__
|
Загрузка…
Ссылка в новой задаче