summaryrefslogtreecommitdiffstats
path: root/mailnews/imap/src/nsImapService.h
blob: dc6f1921ace644ff0cb619d3b93dd2057bee6a0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef nsImapService_h___
#define nsImapService_h___

#include "nsIImapService.h"
#include "nsIMsgMessageService.h"
#include "nsCOMPtr.h"
#include "nsIFile.h"
#include "nsIProtocolHandler.h"
#include "nsIMsgProtocolInfo.h"
#include "nsIContentHandler.h"
#include "nsICacheStorage.h"

class nsIImapHostSessionList; 
class nsCString;
class nsIImapUrl;
class nsIMsgFolder;
class nsIMsgStatusFeedback;
class nsIMsgIncomingServer;

class nsImapService : public nsIImapService,
                      public nsIMsgMessageService,
                      public nsIMsgMessageFetchPartService,
                      public nsIProtocolHandler,
                      public nsIMsgProtocolInfo,
                      public nsIContentHandler
{
public:
  nsImapService();

  NS_DECL_THREADSAFE_ISUPPORTS
  NS_DECL_NSIMSGPROTOCOLINFO
  NS_DECL_NSIIMAPSERVICE
  NS_DECL_NSIMSGMESSAGESERVICE
  NS_DECL_NSIPROTOCOLHANDLER
  NS_DECL_NSIMSGMESSAGEFETCHPARTSERVICE
  NS_DECL_NSICONTENTHANDLER

protected:
  virtual ~nsImapService();
  char GetHierarchyDelimiter(nsIMsgFolder *aMsgFolder);

  nsresult GetFolderName(nsIMsgFolder *aImapFolder, nsACString &aFolderName);

  // This is called by both FetchMessage and StreamMessage
  nsresult GetMessageFromUrl(nsIImapUrl *aImapUrl,
                             nsImapAction aImapAction,
                             nsIMsgFolder *aImapMailFolder, 
                             nsIImapMessageSink *aImapMessage,
                             nsIMsgWindow *aMsgWindow,
                             nsISupports *aDisplayConsumer, 
                             bool aConvertDataToText,
                             nsIURI **aURL);

  nsresult CreateStartOfImapUrl(const nsACString &aImapURI,  // a RDF URI for the current message/folder, can be empty
                                nsIImapUrl  **imapUrl,
                                nsIMsgFolder *aImapFolder,
                                nsIUrlListener *aUrlListener,
                                nsACString &urlSpec,
                                char &hierarchyDelimiter);

  nsresult GetImapConnectionAndLoadUrl(nsIImapUrl *aImapUrl,
                                       nsISupports *aConsumer,
                                       nsIURI **aURL);

  nsresult SetImapUrlSink(nsIMsgFolder *aMsgFolder, nsIImapUrl *aImapUrl);

  nsresult FetchMimePart(nsIImapUrl *aImapUrl,
                         nsImapAction aImapAction,
                         nsIMsgFolder *aImapMailFolder, 
                         nsIImapMessageSink *aImapMessage,
                         nsIURI **aURL,
                         nsISupports *aDisplayConsumer, 
                         const nsACString &messageIdentifierList,
                         const nsACString &mimePart);

  nsresult FolderCommand(nsIMsgFolder *imapMailFolder,
                         nsIUrlListener *urlListener,
                         const char *aCommand,
                         nsImapAction imapAction,
                         nsIMsgWindow *msgWindow,
                         nsIURI **url);

  nsresult ChangeFolderSubscription(nsIMsgFolder *folder,
                                    const nsAString &folderName,
                                    const char *aCommand,
                                    nsIUrlListener *urlListener,
                                    nsIURI **url);

  nsresult DiddleFlags(nsIMsgFolder *aImapMailFolder,
                       nsIUrlListener *aUrlListener,
                       nsIURI **aURL,
                       const nsACString &messageIdentifierList,
                       const char *howToDiddle,
                       imapMessageFlagsType flags,
                       bool messageIdsAreUID);

  nsresult OfflineAppendFromFile(nsIFile *aFile,
                                 nsIURI *aUrl,
                                 nsIMsgFolder *aDstFolder,
                                 const nsACString &messageId,  // to be replaced
                                 bool inSelectedState, // needs to be in
                                 nsIUrlListener *aListener,
                                 nsIURI **aURL,
                                 nsISupports *aCopyState);

  nsresult GetServerFromUrl(nsIImapUrl *aImapUrl, nsIMsgIncomingServer **aServer);

  // just a little helper method...maybe it should be a macro? which helps break down a imap message uri
  // into the folder and message key equivalents
  nsresult DecomposeImapURI(const nsACString &aMessageURI, nsIMsgFolder **aFolder, nsACString &msgKey);
  nsresult DecomposeImapURI(const nsACString &aMessageURI, nsIMsgFolder **aFolder, nsMsgKey *msgKey);


  nsCOMPtr<nsICacheStorage> mCacheStorage;
  bool mPrintingOperation;                // Flag for printing operations
};

#endif /* nsImapService_h___ */