emailservices/nmutilities/inc/emailmru.h
changeset 68 83cc6bae1de8
child 74 6c59112cfd31
equal deleted inserted replaced
67:459da34cdb45 68:83cc6bae1de8
       
     1 /*
       
     2  * Copyright (c) 2007-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:  Object for accessing most recent used email addresses and
       
    15  * display names.
       
    16  *
       
    17  */
       
    18 
       
    19 #ifndef EMAILMRU_H_
       
    20 #define EMAILMRU_H_
       
    21 
       
    22 #include <QString>
       
    23 #include "emailutilitiesdef.h"
       
    24 
       
    25 class XQSettingsManager;
       
    26 
       
    27 
       
    28 /*!
       
    29      Key to MRU repository
       
    30  */
       
    31 static const qint32 emailMruRepositoryKey = 0x2003EA97;
       
    32 
       
    33 /*!
       
    34      Where to find the cenrep-index of the newest saved entry
       
    35  */
       
    36 static const qint32 currentIndexKey = 0;
       
    37 
       
    38 /*!
       
    39      Where to find the number of entries
       
    40  */
       
    41 static const qint32 countKey = 1;
       
    42 
       
    43 /*!
       
    44      Key to contacts central repository
       
    45  */
       
    46 static const qint32 contactsRepositoryKey = 0x2002FF54;
       
    47 
       
    48 /*!
       
    49      Setting for name ordering.
       
    50  */
       
    51 static const qint32 nameOrderKey = 0x1;
       
    52 
       
    53 /*!
       
    54      How many entries are kept in MRU repository
       
    55  */
       
    56 static const qint32 emailAddressHistorySize = 300;
       
    57 
       
    58 class EMAIL_UTILITIES_EXPORT EmailMRU
       
    59 {
       
    60 public:
       
    61 
       
    62     EmailMRU();
       
    63 
       
    64     ~EmailMRU();
       
    65 
       
    66     bool updateMRU(QString displayName, QString emailAddress);
       
    67 
       
    68     quint32 entryCount() const;
       
    69 
       
    70     bool getEntry(qint32 entryIndex, QString &displayName, QString &address);
       
    71 
       
    72     void reset();
       
    73 
       
    74     static int nameOrder();
       
    75 
       
    76 private:
       
    77 
       
    78     quint32 getNextEntryIndex();
       
    79 
       
    80     bool writeCenRep(qint32 index, QString value);
       
    81 
       
    82     QString readCenRep(qint32 index);
       
    83 
       
    84     qint32 searchForAddress(QString address);
       
    85 
       
    86     static qint32 entryIndex(qint32 crKey);
       
    87 
       
    88     static qint32 addressKeyByEntryIndex(qint32 entryIndex);
       
    89 
       
    90     static qint32 nameKeyByEntryIndex(qint32 entryIndex);
       
    91 
       
    92     void moveEntry(qint32 oldEntryIndex, qint32 newEntryIndex);
       
    93 
       
    94     bool writeEntry(qint32 entryIndex, QString displayName, QString emailAddress);
       
    95 
       
    96     bool updateEntry(qint32 entryIndex, QString newDisplayName);
       
    97 
       
    98 private:
       
    99 
       
   100     /*!
       
   101         Points to the latest saved entry
       
   102      */
       
   103     qint32 mLatestIndex;
       
   104 
       
   105     /*!
       
   106         Pointer to central repository manager
       
   107      */
       
   108     XQSettingsManager* mRepositoryManager;
       
   109 
       
   110     /*!
       
   111         Number of entries
       
   112      */
       
   113     quint32 mCount;
       
   114 
       
   115 };
       
   116 
       
   117 
       
   118 #endif // EMAILMRU_H_