emailservices/nmutilities/src/emailmailboxinfo_p.cpp
branchGCC_SURGE
changeset 55 cdd802add233
parent 30 759dc5235cdb
child 74 6c59112cfd31
equal deleted inserted replaced
28:011f79704660 55:cdd802add233
    13  *
    13  *
    14  * Description:  mailbox branding object
    14  * Description:  mailbox branding object
    15  *
    15  *
    16  */
    16  */
    17 
    17 
       
    18 #include "emailtrace.h"
       
    19 
    18 #include "emailmailboxinfo_p.h"
    20 #include "emailmailboxinfo_p.h"
    19 #include "nmutilitiescommonheaders.h"
    21 #include "nmutilitiescommonheaders.h"
    20 #include "nmcenrepkeys.h"
    22 #include "nmcenrepkeys.h"
    21 #include <QRegExp>
    23 #include <QRegExp>
    22 #include <QStringList>
    24 #include <QStringList>
    42 
    44 
    43 /*!
    45 /*!
    44      private constructor
    46      private constructor
    45  */
    47  */
    46 EmailMailboxInfoPrivate::EmailMailboxInfoPrivate() :
    48 EmailMailboxInfoPrivate::EmailMailboxInfoPrivate() :
    47     QObject(NULL), 
    49     QObject(NULL)
    48 	mIsResourceLoaded(false)
    50 {
    49 {
    51     NM_FUNCTION;
       
    52     
    50     XQSettingsManager manager;
    53     XQSettingsManager manager;
    51     XQCentralRepositorySettingsKey rccKey(EMAIL_CENREP, RCC_PATH);
    54     XQCentralRepositorySettingsKey rccKey(EMAIL_CENREP, RCC_PATH);
    52 
    55 
    53     XQCentralRepositorySettingsKey wlbKey(EMAIL_CENREP, WLB_BRAND_NAME);
    56     XQCentralRepositorySettingsKey wlbKey(EMAIL_CENREP, WLB_BRAND_NAME);
    54 
    57 
    55     mWlbDomainName = manager.readItemValue(wlbKey, XQSettingsManager::TypeString).value<QString> ();
    58     mWlbDomainName = manager.readItemValue(wlbKey, XQSettingsManager::TypeString).value<QString> ();    
    56 
       
    57     QString pathToRcc =
       
    58         manager.readItemValue(rccKey, XQSettingsManager::TypeString).value<QString> ();
       
    59     if (!mIsResourceLoaded) {
       
    60         mIsResourceLoaded = QResource::registerResource(pathToRcc);
       
    61     }
       
    62 }
    59 }
    63 /*!
    60 /*!
    64      private destructor
    61      private destructor
    65  */
    62  */
    66 EmailMailboxInfoPrivate::~EmailMailboxInfoPrivate()
    63 EmailMailboxInfoPrivate::~EmailMailboxInfoPrivate()
    67 {
    64 {
    68 
    65     NM_FUNCTION;
    69 }
    66 }
    70 
    67 
    71 /*!
    68 /*!
    72     gets instance of EmailMailboxInfoPrivate
    69     gets instance of EmailMailboxInfoPrivate
    73     \return instance of EmailMailboxInfoPrivate
    70     \return instance of EmailMailboxInfoPrivate
    74  */
    71  */
    75 EmailMailboxInfoPrivate* EmailMailboxInfoPrivate::getInstance()
    72 EmailMailboxInfoPrivate* EmailMailboxInfoPrivate::getInstance()
    76 {
    73 {
       
    74     NM_FUNCTION;
       
    75     
    77     if (!mSelf) {
    76     if (!mSelf) {
    78         mSelf = new EmailMailboxInfoPrivate();
    77         mSelf = new EmailMailboxInfoPrivate();
    79     }
    78     }
    80     mReferenceCount++;
    79     mReferenceCount++;
    81     return mSelf;
    80     return mSelf;
    85     releases pointer to instance of EmailMailboxInfoPrivate
    84     releases pointer to instance of EmailMailboxInfoPrivate
    86     \param pointer to instance of EmailMailboxInfoPrivate object
    85     \param pointer to instance of EmailMailboxInfoPrivate object
    87  */
    86  */
    88 void EmailMailboxInfoPrivate::releaseInstance(EmailMailboxInfoPrivate *&instance)
    87 void EmailMailboxInfoPrivate::releaseInstance(EmailMailboxInfoPrivate *&instance)
    89 {
    88 {
       
    89     NM_FUNCTION;
       
    90     
    90     if (instance) {
    91     if (instance) {
    91         mReferenceCount--;
    92         mReferenceCount--;
    92         instance = NULL;
    93         instance = NULL;
    93     }
    94     }
    94     if (mReferenceCount < 1) {
    95     if (mReferenceCount < 1) {
   102     \param branding identifier
   103     \param branding identifier
   103     \return branding name
   104     \return branding name
   104  */
   105  */
   105 QString EmailMailboxInfoPrivate::name(const QVariant &identifier)
   106 QString EmailMailboxInfoPrivate::name(const QVariant &identifier)
   106 {
   107 {
       
   108     NM_FUNCTION;
       
   109     
   107     QString returnValue = "";
   110     QString returnValue = "";
   108     QString domainName = "";
   111     QString domainName = "";
   109     if (identifier.canConvert<QString> ()) {
   112     if (identifier.canConvert<QString> ()) {
   110         domainName = identifier.value<QString> ();
   113         domainName = identifier.value<QString> ();
   111     }
   114     }
   125     \param branding identifier
   128     \param branding identifier
   126     \return branding icon
   129     \return branding icon
   127  */
   130  */
   128 QString EmailMailboxInfoPrivate::icon(const QVariant &identifier)
   131 QString EmailMailboxInfoPrivate::icon(const QVariant &identifier)
   129 {
   132 {
       
   133     NM_FUNCTION;
       
   134     
   130     QString returnValue = "";
   135     QString returnValue = "";
   131     QString domainName = "";
   136     QString domainName = "";
   132     if (identifier.canConvert<QString> ()) {
   137     if (identifier.canConvert<QString> ()) {
   133         domainName = identifier.value<QString> ();
   138         domainName = identifier.value<QString> ();
       
   139         int delimIndex = domainName.lastIndexOf('@');
       
   140         if(delimIndex >= 0) {
       
   141             domainName = domainName.mid(delimIndex + 1);
       
   142         }
   134     }
   143     }
   135 
   144 
   136     if (domainName.length() > 0){
   145     if (domainName.length() > 0){
   137         processCenRepRecords(domainName);
   146         processCenRepRecords(domainName);
   138         returnValue = mTempIcon;
   147         returnValue = mTempIcon;
   145     goes through cenrep to find matching branding details
   154     goes through cenrep to find matching branding details
   146     \param brandingId (i.e. domain name)
   155     \param brandingId (i.e. domain name)
   147  */
   156  */
   148 void EmailMailboxInfoPrivate::processCenRepRecords(const QString &brandingId)
   157 void EmailMailboxInfoPrivate::processCenRepRecords(const QString &brandingId)
   149 {
   158 {
       
   159     NM_FUNCTION;
       
   160     
   150     bool found = false;
   161     bool found = false;
   151     QString name;
   162     QString name;
   152     QString icon;
   163     QString icon;
   153 
   164 
   154     XQSettingsManager cenRepManager;
   165     XQSettingsManager cenRepManager;
   196             QRegExp regExp(cenRepRecord.at(1));
   207             QRegExp regExp(cenRepRecord.at(1));
   197             regExp.setCaseSensitivity(Qt::CaseInsensitive);
   208             regExp.setCaseSensitivity(Qt::CaseInsensitive);
   198 
   209 
   199             if (regExp.exactMatch(brandingId)) { //match
   210             if (regExp.exactMatch(brandingId)) { //match
   200                 found = true;
   211                 found = true;
   201                 icon = ":/" + cenRepRecord.at(3);
   212                 icon = "z:/resource/apps/" + cenRepRecord.at(3) + ".svg";
   202                 name = cenRepRecord.at(2);
   213                 name = cenRepRecord.at(2);
   203                 break;
   214                 break;
   204             }
   215             }
   205         }
   216         }
   206     }
   217     }
   207     if (!found || !mIsResourceLoaded) {
   218     if (!found ) { 
   208         //get default icon and name
   219         //get default icon and name
   209         icon = "qtg_large_email";
   220         icon = "qtg_large_email";
   210         QStringList domain = brandingId.split(".");
   221         QStringList domain = brandingId.split(".");
   211         if (domain.size() > 0) {
   222         if (domain.size() > 0) {
   212             name = domain.at(0);
   223             name = domain.at(0);
   220     gets current country code
   231     gets current country code
   221     \return current country id
   232     \return current country id
   222  */
   233  */
   223 quint8 EmailMailboxInfoPrivate::getCurrentCountryL() const
   234 quint8 EmailMailboxInfoPrivate::getCurrentCountryL() const
   224 {
   235 {
       
   236     NM_FUNCTION;
       
   237     
   225     CTzLocalizer* localizer = CTzLocalizer::NewLC();
   238     CTzLocalizer* localizer = CTzLocalizer::NewLC();
   226 
   239 
   227     CTzLocalizedCity* city = localizer->GetFrequentlyUsedZoneCityL(
   240     CTzLocalizedCity* city = localizer->GetFrequentlyUsedZoneCityL(
   228         CTzLocalizedTimeZone::ECurrentZone);
   241         CTzLocalizedTimeZone::ECurrentZone);
   229     CleanupStack::PushL(city);
   242     CleanupStack::PushL(city);
   244     verifies if timezone is set for Germany or UK
   257     verifies if timezone is set for Germany or UK
   245     \return true if timezone is UK or Germany, false otherwise
   258     \return true if timezone is UK or Germany, false otherwise
   246  */
   259  */
   247 bool EmailMailboxInfoPrivate::verifyTimeZone() const
   260 bool EmailMailboxInfoPrivate::verifyTimeZone() const
   248 {
   261 {
       
   262     NM_FUNCTION;
       
   263     
   249     quint8 timeZone = 0;
   264     quint8 timeZone = 0;
   250     bool retVal = false;
   265     bool retVal = false;
   251     TRAPD(err, timeZone = getCurrentCountryL());
   266     TRAPD(err, timeZone = getCurrentCountryL());
   252 
   267 
   253     if (err == KErrNone && (timeZone == KGermanyTzId || timeZone == KUKTzId)) {
   268     if (err == KErrNone && (timeZone == KGermanyTzId || timeZone == KUKTzId)) {
   260     modifies branding name "Gmail" according to UK and Germany law rules
   275     modifies branding name "Gmail" according to UK and Germany law rules
   261     \param brandingName name of branding
   276     \param brandingName name of branding
   262  */
   277  */
   263 void EmailMailboxInfoPrivate::verifyMailAccountName(QString &brandingName) const
   278 void EmailMailboxInfoPrivate::verifyMailAccountName(QString &brandingName) const
   264 {
   279 {
       
   280     NM_FUNCTION;
       
   281     
   265     QSystemNetworkInfo *networkInfo = new QSystemNetworkInfo();
   282     QSystemNetworkInfo *networkInfo = new QSystemNetworkInfo();
   266     QString currentMCC = networkInfo->currentMobileCountryCode();
   283     QString currentMCC = networkInfo->currentMobileCountryCode();
   267 
   284 
   268     if (brandingName == KBrandNameGmail) {
   285     if (brandingName == KBrandNameGmail) {
   269         if (currentMCC.size() > 0) {
   286         if (currentMCC.size() > 0) {