harvesterplugins/messaging/email/qtemailfetcher/qtemailfetcher.h
changeset 2 208a4ba3894c
child 3 6832643895f7
equal deleted inserted replaced
0:ccd0fd43f247 2:208a4ba3894c
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Utility class for fetching email.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef _QEMAILFETCHER_H
       
    19 #define _QEMAILFETCHER_H
       
    20 
       
    21 #ifdef BUILD_DLL
       
    22 #define DLL_EXPORT Q_DECL_EXPORT
       
    23 #else
       
    24 #define DLL_EXPORT Q_DECL_IMPORT
       
    25 #endif
       
    26 
       
    27 //TODO: Uncomment when available.
       
    28 #include <nmapiemailservice.h>
       
    29 #include <nmapieventnotifier.h>
       
    30 #include <nmapimailboxlisting.h>
       
    31 #include <nmapienvelopelisting.h>
       
    32 #include <nmapimessageenvelope.h>
       
    33 #include <nmapifolderlisting.h>
       
    34 #include <QObject>
       
    35 #include "memailitemobserver.h"
       
    36 
       
    37 using namespace EmailClientApi;
       
    38 
       
    39 //How this works:
       
    40 //1. List all mail boxes.
       
    41 //2. In each mail box, list the folders
       
    42 //3. In each folder, list the mails
       
    43 //4. Process each email
       
    44 //
       
    45 //We voluntarily relinquish the processor (we sleep) each time we have completed 
       
    46 //processing a given folder. This is to avoid 'hogging' the processor.
       
    47 
       
    48 
       
    49 class DLL_EXPORT QEmailFetcher: public QObject
       
    50     {
       
    51     Q_OBJECT
       
    52 public:
       
    53     static QEmailFetcher* newInstance(MEmailItemObserver& aObserver);
       
    54     ~QEmailFetcher();
       
    55     void StartHarvesting();
       
    56 
       
    57 private:
       
    58     QEmailFetcher(MEmailItemObserver& aObserver );
       
    59     static void initialize(QEmailFetcher* aThis); //helper (2nd phase constructor).
       
    60 
       
    61     //Private?
       
    62 public slots:
       
    63     void emailServiceIntialized( bool );
       
    64     void handleMailboxesListed( int );
       
    65     void mailFoldersListed( int );
       
    66     void processMessages( int );
       
    67     //Connect to messageEvent signal
       
    68     void handleMessageEvent( MessageEvent aEvent, quint64 mailboxId, quint64 folderId, QList<quint64> messageList );
       
    69     
       
    70 private:
       
    71     MEmailItemObserver& iEmailObserver;     //The parent/creator. Not owned.
       
    72     NmEventNotifier* iEmailEventNotifier;   //owned; triggers handleMessageEvent.
       
    73     NmEmailService* iEmailService;          //owned. 
       
    74     NmMailboxListing* iMailBoxListings;     //owned.
       
    75     NmFolderListing* iMailFolderList;       //owned.
       
    76     NmEnvelopeListing* iEnvelopeListing;    //owned.
       
    77     NmMessageEnvelope* iMessageListing;     //owned.
       
    78     };
       
    79 
       
    80 #endif //_QEMAILFETCHER_H