summaryrefslogtreecommitdiffstats
path: root/comm/mailnews/base/src/nsMsgOfflineManager.h
blob: f340ee0fd1373fd0d4cad5a08f7d65c5d54caf80 (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
/* -*- Mode: C++; tab-width: 2; 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 nsMsgOfflineManager_h__
#define nsMsgOfflineManager_h__

#include "nscore.h"
#include "nsIMsgOfflineManager.h"
#include "nsCOMPtr.h"
#include "nsIObserver.h"
#include "nsWeakReference.h"
#include "nsIUrlListener.h"
#include "nsIMsgWindow.h"
#include "nsIMsgSendLaterListener.h"
#include "nsIStringBundle.h"

class nsMsgOfflineManager : public nsIMsgOfflineManager,
                            public nsIObserver,
                            public nsSupportsWeakReference,
                            public nsIMsgSendLaterListener,
                            public nsIUrlListener {
 public:
  nsMsgOfflineManager();

  NS_DECL_THREADSAFE_ISUPPORTS

  /* nsIMsgOfflineManager methods */

  NS_DECL_NSIMSGOFFLINEMANAGER
  NS_DECL_NSIOBSERVER
  NS_DECL_NSIURLLISTENER
  NS_DECL_NSIMSGSENDLATERLISTENER

  typedef enum {
    eStarting = 0,
    eSynchronizingOfflineImapChanges = 1,
    eDownloadingNews = 2,
    eDownloadingMail = 3,
    eSendingUnsent = 4,
    eDone = 5,
    eNoState = 6  // we're not doing anything
  } offlineManagerState;

  typedef enum {
    eGoingOnline = 0,
    eDownloadingForOffline = 1,
    eNoOp = 2  // no operation in progress
  } offlineManagerOperation;

 private:
  virtual ~nsMsgOfflineManager();

  nsresult AdvanceToNextState(nsresult exitStatus);
  nsresult SynchronizeOfflineImapChanges();
  nsresult StopRunning(nsresult exitStatus);
  nsresult SendUnsentMessages();
  nsresult DownloadOfflineNewsgroups();
  nsresult DownloadMail();

  nsresult SetOnlineState(bool online);
  nsresult ShowStatus(const char* statusMsgName);

  bool m_inProgress;
  bool m_sendUnsentMessages;
  bool m_downloadNews;
  bool m_downloadMail;
  bool m_playbackOfflineImapOps;
  bool m_goOfflineWhenDone;
  offlineManagerState m_curState;
  offlineManagerOperation m_curOperation;
  nsCOMPtr<nsIMsgWindow> m_window;
  nsCOMPtr<nsIMsgStatusFeedback> m_statusFeedback;
  nsCOMPtr<nsIStringBundle> mStringBundle;
  nsCOMPtr<nsISupports> mOfflineImapSync;
};

#endif