summaryrefslogtreecommitdiffstats
path: root/mailnews/base/src/nsMessengerUnixIntegration.h
blob: ba9f0f3f5304dcff385377c1769c5a442b3e9393 (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
/* -*- 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 __nsMessengerUnixIntegration_h
#define __nsMessengerUnixIntegration_h

#include "nsIMessengerOSIntegration.h"
#include "nsIFolderListener.h"
#include "nsIUrlListener.h"
#include "nsIMutableArray.h"
#include "nsIStringBundle.h"
#include "nsIObserver.h"
#include "nsIAtom.h"
#include "nsDataHashtable.h"
#include "nsTArray.h"

#define NS_MESSENGERUNIXINTEGRATION_CID \
  {0xf62f3d3a, 0x1dd1, 0x11b2, \
    {0xa5, 0x16, 0xef, 0xad, 0xb1, 0x31, 0x61, 0x5c}}

class nsIStringBundle;

class nsMessengerUnixIntegration : public nsIFolderListener,
                                   public nsIObserver,
                                   public nsIUrlListener,
                                   public nsIMessengerOSIntegration
{
public:
  nsMessengerUnixIntegration();
  virtual nsresult Init();

  NS_DECL_ISUPPORTS
  NS_DECL_NSIMESSENGEROSINTEGRATION
  NS_DECL_NSIFOLDERLISTENER
  NS_DECL_NSIOBSERVER
  NS_DECL_NSIURLLISTENER

private:
  virtual ~nsMessengerUnixIntegration() {}
  nsresult ShowAlertMessage(const nsAString& aAlertTitle, const nsAString& aAlertText, const nsACString& aFolderURI);
  nsresult GetFirstFolderWithNewMail(nsACString& aFolderURI);
  nsresult GetStringBundle(nsIStringBundle **aBundle);
  nsresult AlertFinished();
  nsresult AlertClicked();
  void FillToolTipInfo();
  nsresult GetMRUTimestampForFolder(nsIMsgFolder *aFolder, uint32_t *aLastMRUTime);

  bool BuildNotificationBody(nsIMsgDBHdr *aHdr, nsIStringBundle *Bundle, nsString &aBody);
  bool BuildNotificationTitle(nsIMsgFolder *aFolder, nsIStringBundle *aBundle, nsString &aTitle);
  nsresult ShowNewAlertNotification(bool aUserInitiated);
  nsresult PutMRUTimestampForFolder(nsIMsgFolder *aFolder, uint32_t aLastMRUTime);

  nsCOMPtr<nsIMutableArray> mFoldersWithNewMail;  // keep track of all the root folders with pending new mail
  nsCOMPtr<nsIAtom> mBiffStateAtom;
  nsCOMPtr<nsIAtom> mNewMailReceivedAtom;
  bool mAlertInProgress;
  nsDataHashtable<nsCStringHashKey, uint32_t> mLastMRUTimes; // We keep track of the last time we did a new mail notification for each account
  nsTArray<nsCString> mFetchingURIs;
};

#endif // __nsMessengerUnixIntegration_h