phonebookui/pbkcommonui/src/cntimportsview.cpp
changeset 31 2a11b5b00470
child 37 fd64c38c277d
equal deleted inserted replaced
27:de1630741fbe 31:2a11b5b00470
       
     1 /*
       
     2 * Copyright (c) 2009 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 #include "cntimportsview.h"
       
    19 #include "qtpbkglobal.h"
       
    20 #include <hbpushbutton.h>
       
    21 #include <hbaction.h>
       
    22 #include <hbview.h>
       
    23 #include <hbmenu.h>
       
    24 #include <hbframebackground.h>
       
    25 #include <QStandardItemModel>
       
    26 #include <hbmainwindow.h>
       
    27 #include <hblabel.h>
       
    28 #include <hblistview.h>
       
    29 #include <hbgroupbox.h>
       
    30 #include <QTimer.h>
       
    31 #include <hbnotificationdialog.h>
       
    32 #include <hbmessagebox.h>
       
    33 #include <hbprogressbar.h>
       
    34 #include <QGraphicsLinearLayout>
       
    35 #include <hbframebackground.h>
       
    36 #include <hbabstractviewitem.h>
       
    37 
       
    38 const char *CNT_IMPORT_UI_XML = ":/xml/contacts_sim.docml";
       
    39 const int KTimerValue = 1; // used as 1 msec timer for saving ADN contacts from SIM   
       
    40 
       
    41 CntImportsView::CntImportsView() : mContactSimManagerADN(0),
       
    42     mContactSimManagerSDN(0),    
       
    43     mFetchRequestADN(0),
       
    44     mFetchRequestSDN(0),
       
    45     mListView(0),
       
    46     mSimUtility(0),
       
    47     mAdnEntriesPresent(0),
       
    48     mImportSimPopup(0),
       
    49     mSaveCount(0),
       
    50     mFetchIsDone(0),
       
    51     mTimerId(0),
       
    52     mAdnStorePresent(0),
       
    53     mSdnStorePresent(0),
       
    54     mSimPresent(0),
       
    55     mAdnStoreEntries(0),
       
    56     mSimError(0),
       
    57     mWaitingForAdnCache(0)
       
    58 {
       
    59     bool ok = false;
       
    60     mDocumentLoader.load(CNT_IMPORT_UI_XML, &ok);
       
    61 
       
    62     if (ok)
       
    63     {
       
    64         mView = static_cast<HbView*>(mDocumentLoader.findWidget(QString("view")));
       
    65     }
       
    66     else
       
    67     {
       
    68         qFatal("Unable to read :/xml/contacts_sim.docml");
       
    69     }
       
    70 
       
    71     //back button
       
    72     mSoftkey = new HbAction(Hb::BackNaviAction, mView);
       
    73     connect(mSoftkey, SIGNAL(triggered()), this, SLOT(showPreviousView()));
       
    74       
       
    75 }
       
    76 
       
    77 void CntImportsView::deactivate()
       
    78 {
       
    79 }
       
    80 
       
    81    
       
    82 CntImportsView::~CntImportsView()
       
    83 {
       
    84     mView->deleteLater();
       
    85     delete mFetchRequestADN;
       
    86     delete mFetchRequestSDN;
       
    87     delete mModel;
       
    88     delete mSimUtility;
       
    89 }
       
    90 
       
    91 /*!
       
    92 Activates a previous view
       
    93 */
       
    94 void CntImportsView::showPreviousView()
       
    95 {
       
    96   CntViewParameters args;
       
    97   mViewManager->back(args);
       
    98 }
       
    99 
       
   100 /*
       
   101 Activates a default view
       
   102 */
       
   103 void CntImportsView::activate(CntAbstractViewManager* aMgr, const CntViewParameters aArgs)
       
   104 {
       
   105     Q_UNUSED(aArgs);
       
   106     //back button
       
   107     HbMainWindow* window = mView->mainWindow();
       
   108     if (mView->navigationAction() != mSoftkey)
       
   109     {
       
   110         mView->setNavigationAction(mSoftkey);
       
   111     }
       
   112             
       
   113     mViewManager = aMgr;  
       
   114     mContactSymbianManager = mViewManager->contactManager(SYMBIAN_BACKEND);
       
   115    
       
   116     // Sim Utility info fetch
       
   117     int getSimInfoError(0);
       
   118     int storesError(0);
       
   119     
       
   120     int error = -1;
       
   121     mSimUtility = new SimUtility(SimUtility::AdnStore, error);
       
   122     if (error != 0) 
       
   123     {
       
   124         delete mSimUtility; 
       
   125         mSimUtility = 0;
       
   126         mSimError = true;
       
   127     }
       
   128     else
       
   129     {
       
   130         // check what stores are there
       
   131         SimUtility::AvailableStores stores = mSimUtility->getAvailableStores(storesError);
       
   132         if(!storesError)
       
   133         {
       
   134             mSimPresent = stores.SimPresent;
       
   135             mAdnStorePresent = stores.AdnStorePresent; 
       
   136             mSdnStorePresent = stores.SdnStorePresent;
       
   137         }
       
   138         
       
   139         //check there are ADN contacts 
       
   140         if (mAdnStorePresent)
       
   141         {
       
   142             SimUtility::SimInfo simInfo = mSimUtility->getSimInfo(getSimInfoError);
       
   143             if (!getSimInfoError)
       
   144             {
       
   145                 // sim entries are present
       
   146                 mAdnStoreEntries = simInfo.usedEntries;
       
   147                 if (mAdnStoreEntries > 0) 
       
   148                 { 
       
   149                     mAdnEntriesPresent = true;
       
   150                 }
       
   151             }
       
   152             else
       
   153             {
       
   154                 if (getSimInfoError == KErrNotReady)
       
   155                 {
       
   156                     //ADN store is not accessible, e.g. because of active FDN
       
   157                     //Or ADN cache is not ready yet, so wait for this  
       
   158                     mAdnStorePresent = true;
       
   159                     mAdnEntriesPresent = true;
       
   160                     mWaitingForAdnCache = true;
       
   161                     connect(mSimUtility, SIGNAL(adnCacheStatusReady(SimUtility::CacheStatus&, int)), this, SLOT(adnCacheStatusReady(SimUtility::CacheStatus&, int)));
       
   162                     if (!mSimUtility->notifyAdnCacheStatus()) {
       
   163                         mAdnStorePresent = false;
       
   164                         mAdnEntriesPresent = false;
       
   165                         mWaitingForAdnCache = false;
       
   166                     }
       
   167                 }
       
   168                 else
       
   169                 {
       
   170                     simInfoErrorMessage(getSimInfoError);
       
   171                 }
       
   172             }
       
   173         }
       
   174     }
       
   175         
       
   176     mListView = static_cast<HbListView*>(mDocumentLoader.findWidget(QString("listView")));
       
   177     
       
   178     HbFrameBackground frame;
       
   179     frame.setFrameGraphicsName("qtg_fr_list_normal");
       
   180     frame.setFrameType(HbFrameDrawer::NinePieces);
       
   181     mListView->itemPrototypes().first()->setDefaultFrame(frame);
       
   182     
       
   183     mListView->setUniformItemSizes(true);
       
   184     
       
   185     connect(mListView, SIGNAL(activated (const QModelIndex&)),
       
   186                                       this,  SLOT(onListViewActivated(const QModelIndex&)));
       
   187        
       
   188     mModel = new QStandardItemModel();
       
   189     
       
   190     QStandardItem *importSimItem = new QStandardItem();
       
   191     QStringList simList;
       
   192     
       
   193     QString simImport(hbTrId("txt_phob_dblist_import_from_sim"));
       
   194     QString simNoContacts(hbTrId("txt_phob_dblist_import_from_1_val_no_sim_contacts"));
       
   195     QString simNoCard(hbTrId("txt_phob_dblist_import_from_ovi_val_no_sim_card"));
       
   196     
       
   197     // check if SIM card is there 
       
   198     if (mSimError)
       
   199     {
       
   200         simList << simImport;
       
   201         importSimItem->setEnabled(false);
       
   202     }
       
   203     else if (!(mAdnStorePresent || mSdnStorePresent))
       
   204     {
       
   205         // Both stores are not present
       
   206         // disable the QStandardItem
       
   207         if (!mSimPresent) 
       
   208         {
       
   209             simList << simImport << simNoCard;
       
   210         }
       
   211         else
       
   212         {
       
   213             simList << simImport << simNoContacts;
       
   214         }
       
   215         importSimItem->setEnabled(false);
       
   216     }
       
   217     else if (!(mAdnEntriesPresent || mSdnStorePresent))
       
   218     {
       
   219         // Sim card is present
       
   220         // No ADN entries are there
       
   221         // no SDN entries are there
       
   222         simList << simImport << simNoContacts;
       
   223         importSimItem->setEnabled(false);
       
   224     }
       
   225     else
       
   226     {   
       
   227         // SIM card is present
       
   228         //ADN entries or SDN entries are there
       
   229         simList << simImport ;        
       
   230     }
       
   231     importSimItem->setData(simList, Qt::DisplayRole);
       
   232     importSimItem->setData(HbIcon("qtg_large_sim"), Qt::DecorationRole);   
       
   233      
       
   234     mModel->insertRow(0,importSimItem);
       
   235     
       
   236     QStandardItem *importDeviceItem = new QStandardItem();
       
   237     QStringList deviceList;
       
   238     QString deviceImport(hbTrId("txt_phob_dblist_import_from_device"));
       
   239     deviceList << deviceImport;
       
   240     importDeviceItem->setData(deviceList, Qt::DisplayRole);
       
   241     importDeviceItem->setData(HbIcon("qtg_large_data_import"), Qt::DecorationRole);
       
   242     importDeviceItem->setEnabled(false);
       
   243        
       
   244     mModel->insertRow(1,importDeviceItem);
       
   245     
       
   246     mListView->setModel(mModel);
       
   247     mListView->setSelectionMode(HbAbstractItemView::NoSelection);
       
   248 }
       
   249 
       
   250 void CntImportsView::simInfoErrorMessage(int infoError)
       
   251 {
       
   252     Q_UNUSED(infoError);
       
   253     QString errorMessage;
       
   254     errorMessage.append(hbTrId("sim_card_not_accessable"));
       
   255     HbNotificationDialog::launchDialog(errorMessage);
       
   256     mSimError = true;
       
   257 }
       
   258 
       
   259 void CntImportsView::onListViewActivated(const QModelIndex &index)
       
   260 {
       
   261     int row = index.row();
       
   262     if ( row == 0 ) // row 0 has "Imports from SIM" 
       
   263     {
       
   264        if (!startSimImport())
       
   265        {
       
   266            //show error note
       
   267            simInfoErrorMessage(KErrAccessDenied);
       
   268        }
       
   269        else
       
   270        {
       
   271            //start popup and progress
       
   272            showWaitNote();
       
   273        }
       
   274     }        
       
   275 }
       
   276 
       
   277 
       
   278 bool CntImportsView::startSimImport()
       
   279 {
       
   280     bool started = false;
       
   281 
       
   282     delete mFetchRequestADN;
       
   283     mFetchRequestADN = 0;
       
   284     delete mFetchRequestSDN;
       
   285     mFetchRequestSDN = 0;
       
   286         
       
   287     if (mWaitingForAdnCache)
       
   288     {
       
   289         //show progress dialog and wait when ADN cache is ready
       
   290         started = true;
       
   291     }
       
   292     else
       
   293     {
       
   294         if(mAdnStorePresent)
       
   295         {
       
   296             mContactSimManagerADN = mViewManager->contactManager(SIM_BACKEND_ADN);
       
   297             mFetchRequestADN = new QContactFetchRequest;
       
   298             mFetchRequestADN->setManager(mContactSimManagerADN);
       
   299             connect(mFetchRequestADN, SIGNAL(resultsAvailable()), this, SLOT(importFetchResultReceivedADN()));
       
   300         }
       
   301       
       
   302         if(mSdnStorePresent)
       
   303         {
       
   304             mContactSimManagerSDN = mViewManager->contactManager(SIM_BACKEND_SDN);
       
   305             // SDN store fetch request
       
   306             mFetchRequestSDN = new QContactFetchRequest;
       
   307             mFetchRequestSDN->setManager(mContactSimManagerSDN);
       
   308             connect(mFetchRequestSDN, SIGNAL(resultsAvailable()), this, SLOT(importFetchResultReceivedSDN()));
       
   309         }
       
   310         
       
   311         if(mAdnEntriesPresent > 0 && mContactSimManagerADN->error() == QContactManager::NoError) 
       
   312         {
       
   313             // ADN contacts are there, start fetch
       
   314             mFetchRequestADN->start();
       
   315             started = true;
       
   316         }
       
   317         else if (mSdnStorePresent && mContactSimManagerSDN->error() == QContactManager::NoError)        
       
   318         {
       
   319             //start fetch of SDN contacts since ADN contacts are not there
       
   320             mFetchRequestSDN->start();
       
   321             started = true;
       
   322         }
       
   323     }
       
   324     return started;
       
   325 }  
       
   326 
       
   327 void CntImportsView::stopSimImport()
       
   328 {
       
   329     mImportSimPopup->close();
       
   330     if (mFetchIsDone)
       
   331     {
       
   332         // indicates that timer has been started
       
   333         killTimer(mTimerId);
       
   334     }
       
   335     mSaveSimContactsList.clear(); 
       
   336     mSaveSimContactsListSDN.clear(); 
       
   337     
       
   338     showSimImportResults();
       
   339     
       
   340     if (mFetchRequestADN != NULL)
       
   341     {
       
   342         mFetchRequestADN->cancel();
       
   343     }
       
   344     if (mFetchRequestSDN != NULL)
       
   345     {
       
   346         mFetchRequestSDN->cancel();
       
   347     }
       
   348     
       
   349 }
       
   350 
       
   351 void CntImportsView::importFetchResultReceivedADN()
       
   352 {
       
   353     QList<QContact> simContactsList = mFetchRequestADN->contacts();
       
   354     if (simContactsList.isEmpty())
       
   355     {
       
   356         // No sim contacts, jump to fetching SDN contacts
       
   357         fetchSDNContacts();
       
   358     }
       
   359     else
       
   360     {
       
   361         // save ADN contacts
       
   362     
       
   363         int count = simContactsList.count();
       
   364         foreach(QContact contact, simContactsList) 
       
   365         {
       
   366             if (contact.localId() > 0) 
       
   367             {
       
   368             //delete local id before saving to different storage
       
   369                QScopedPointer<QContactId> contactId(new QContactId());
       
   370                contactId->setLocalId(0);
       
   371                contactId->setManagerUri(QString());
       
   372                contact.setId(*contactId);
       
   373     
       
   374                // custom label contains name information, save it to the first name 
       
   375                QList<QContactDetail> names = contact.details(QContactName::DefinitionName);
       
   376                if (names.count() > 0) 
       
   377                {
       
   378                    QContactName name = static_cast<QContactName>(names.at(0));
       
   379                    name.setFirstName(name.customLabel());
       
   380                    name.setCustomLabel(QString());
       
   381                    contact.saveDetail(&name);
       
   382                }
       
   383                  
       
   384                //update phone numbers to contain default subtype
       
   385                QList<QContactDetail> numbers = contact.details(QContactPhoneNumber::DefinitionName);
       
   386                for (int i = 0; i < numbers.count(); i++) 
       
   387                {
       
   388                    QContactPhoneNumber number = static_cast<QContactPhoneNumber>(numbers.at(i));
       
   389                    number.setSubTypes(QContactPhoneNumber::SubTypeMobile);
       
   390                    contact.saveDetail(&number);
       
   391                }
       
   392                
       
   393                //remove sync target details, it's read-only. 
       
   394                 QList<QContactDetail> syncTargets = contact.details(QContactSyncTarget::DefinitionName);
       
   395                 for (int j = 0; j < syncTargets.count(); j++) 
       
   396                 {
       
   397                     QContactSyncTarget syncTarget = static_cast<QContactSyncTarget>(syncTargets.at(j));
       
   398                     contact.removeDetail(&syncTarget);
       
   399                 }
       
   400                
       
   401                contact.setType(QContactType::TypeContact);
       
   402                mSaveSimContactsList.append(contact);
       
   403                 
       
   404             }
       
   405         }
       
   406         // save the list synchronously because async cancelling of save request is  
       
   407         // not supported in symbian backend at the time of this implementation
       
   408         
       
   409         if (!(mSaveSimContactsList.isEmpty()))
       
   410         {
       
   411             // indicates that there is one or more sim contact that has been fetched
       
   412             // create a timer and start saving synchronously one by one
       
   413             // when cancel is pressed, kill the timer
       
   414             
       
   415             mTimerId = startTimer(KTimerValue); // starting a 1 msec timer
       
   416             mFetchIsDone = true;
       
   417             mSaveCount = 0;    
       
   418         }
       
   419     
       
   420     }
       
   421 }
       
   422 
       
   423 void CntImportsView::timerEvent(QTimerEvent *event)
       
   424 {
       
   425     Q_UNUSED(event);
       
   426     if (!(mSaveCount >= mSaveSimContactsList.count())) // while mSaveCount is less than or equal to mSaveSimContactsList.count()
       
   427     {
       
   428         QContact unSavedContact = mSaveSimContactsList.at(mSaveCount);
       
   429         mContactSymbianManager->saveContact(&unSavedContact);
       
   430         mSaveCount++;
       
   431         //use another counter to check number of actual saved if saveContact() fails
       
   432     }
       
   433     else
       
   434     {
       
   435         // saving complete
       
   436         killTimer(mTimerId);
       
   437         mSaveSimContactsList.clear();
       
   438         
       
   439         // ADN contacts fetching and saving is done
       
   440         // Now start SDN fetching and save
       
   441         fetchSDNContacts();
       
   442     }
       
   443 }
       
   444 
       
   445 void CntImportsView::showWaitNote()
       
   446 {
       
   447     mImportSimPopup = new HbDialog();    
       
   448     mImportSimPopup->setDismissPolicy(HbDialog::NoDismiss);
       
   449     mImportSimPopup->setTimeout(0);
       
   450     mImportSimPopup->setBackgroundFaded(true);
       
   451     mImportSimPopup->setAttribute(Qt::WA_DeleteOnClose, true);
       
   452     
       
   453     HbGroupBox *groupBox = new HbGroupBox;
       
   454     groupBox->setHeading(hbTrId("txt_phob_title_import_contacts")); 
       
   455     mImportSimPopup->setHeadingWidget(groupBox);
       
   456     
       
   457     QGraphicsLinearLayout *containerLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
   458     containerLayout->setContentsMargins(0, 0, 0, 0);
       
   459     containerLayout->setSpacing(10);
       
   460     
       
   461     HbLabel *icon = new HbLabel();
       
   462     icon->setIcon(HbIcon("qtg_large_sim"));  
       
   463     
       
   464     HbLabel *simText= new HbLabel();
       
   465     simText->setPlainText(hbTrId("txt_phob_info_importing_contacts_from_sim")); 
       
   466     simText->setTextWrapping(Hb::TextWordWrap);
       
   467     simText->setElideMode(Qt::ElideNone);
       
   468     
       
   469     HbProgressBar *progressBar = new HbProgressBar;
       
   470     progressBar->setRange(0,0); 
       
   471     
       
   472     HbPushButton *stopButton = new HbPushButton;
       
   473     stopButton->setText(hbTrId("txt_phob_button_cancel"));
       
   474     connect(stopButton, SIGNAL(clicked()), this, SLOT(stopSimImport()));
       
   475     
       
   476     QGraphicsLinearLayout *containerLayout1 = new QGraphicsLinearLayout(Qt::Horizontal);
       
   477     containerLayout1->addItem(icon);
       
   478     containerLayout1->addItem(simText);
       
   479     
       
   480     QGraphicsWidget *containerWidget = new QGraphicsWidget;    
       
   481     containerLayout->addItem(containerLayout1);
       
   482     containerLayout->addItem(progressBar);
       
   483     containerLayout->addItem(stopButton);  
       
   484     containerWidget->setLayout(containerLayout);
       
   485     mImportSimPopup->setContentWidget(containerWidget);
       
   486     mSaveCount = 0;
       
   487     mImportSimPopup->open();
       
   488 }
       
   489 
       
   490 void CntImportsView::showSimImportResults() const
       
   491 {
       
   492     QString results;
       
   493     results.append(hbTrId("txt_phob_dpophead_ln_contacts_imported", mSaveCount));
       
   494     HbNotificationDialog::launchDialog(results);
       
   495 }
       
   496 
       
   497 void CntImportsView::fetchSDNContacts()
       
   498 {
       
   499    if (mSdnStorePresent && mContactSimManagerSDN->error() == QContactManager::NoError)
       
   500     {
       
   501         mFetchRequestSDN->start();
       
   502     }
       
   503     else
       
   504     {
       
   505         // no SDN contacts to fetch
       
   506         showSimImportResults();
       
   507         mImportSimPopup->close();
       
   508         // Importing finished, go back to NamesView
       
   509         showPreviousView();
       
   510     }
       
   511 }
       
   512 
       
   513 void CntImportsView::importFetchResultReceivedSDN()
       
   514 {
       
   515     QList<QContact> simContactsListSDN = mFetchRequestSDN->contacts();
       
   516     if (simContactsListSDN.isEmpty())
       
   517     {
       
   518         //No sdn contacts present
       
   519         showSimImportResults();
       
   520         mSaveSimContactsListSDN.clear(); 
       
   521         mImportSimPopup->close();
       
   522         // Importing finished, go back to NamesView
       
   523         showPreviousView();
       
   524     }
       
   525     else
       
   526     {
       
   527     // SAVE SDN CONTACTS
       
   528         int count = simContactsListSDN.count();
       
   529         foreach(QContact contact, simContactsListSDN) 
       
   530         {
       
   531             if (contact.localId() > 0) 
       
   532             {
       
   533             //delete local id before saving to different storage
       
   534                QScopedPointer<QContactId> contactId(new QContactId());
       
   535                contactId->setLocalId(0);
       
   536                contactId->setManagerUri(QString());
       
   537                contact.setId(*contactId);
       
   538     
       
   539                //custom label contains name information, save it to the first name 
       
   540               QList<QContactDetail> names = contact.details(QContactName::DefinitionName);
       
   541               if (names.count() > 0) 
       
   542               {
       
   543                   QContactName name = static_cast<QContactName>(names.at(0));
       
   544                   name.setFirstName(name.customLabel());
       
   545                   name.setCustomLabel(QString());
       
   546                   contact.saveDetail(&name);
       
   547               }
       
   548                 
       
   549               //update phone numbers to contain default subtype
       
   550               QList<QContactDetail> numbers = contact.details(QContactPhoneNumber::DefinitionName);
       
   551               for (int i = 0; i < numbers.count(); i++) 
       
   552               {
       
   553                   QContactPhoneNumber number = static_cast<QContactPhoneNumber>(numbers.at(i));
       
   554                   number.setSubTypes(QContactPhoneNumber::SubTypeMobile);
       
   555                   contact.saveDetail(&number);
       
   556               }
       
   557               
       
   558               //remove sync target details, it's read-only. 
       
   559               QList<QContactDetail> syncTargets = contact.details(QContactSyncTarget::DefinitionName);
       
   560               for (int j = 0; j < syncTargets.count(); j++) 
       
   561               {
       
   562                   QContactSyncTarget syncTarget = static_cast<QContactSyncTarget>(syncTargets.at(j));
       
   563                   contact.removeDetail(&syncTarget);
       
   564               }
       
   565               
       
   566                contact.setType(QContactType::TypeContact);
       
   567                mSaveSimContactsListSDN.append(contact);
       
   568                 
       
   569             }
       
   570         }
       
   571         // save the list synchronously because async cancelling of save request is  
       
   572         // not supported in symbian backend at the time of this implementation
       
   573         
       
   574         if (!(mSaveSimContactsListSDN.isEmpty()))
       
   575         {
       
   576             // indicates that there is one or more SDN sim contact that has been fetched
       
   577             QMap<int, QContactManager::Error> errorMap;
       
   578             mContactSymbianManager->saveContacts(&mSaveSimContactsListSDN,&errorMap);
       
   579             // check number of contacts really saved
       
   580             mSaveCount = mSaveCount + mSaveSimContactsListSDN.count();
       
   581         }
       
   582         
       
   583         // no more SDN contacts to fetch
       
   584         showSimImportResults();
       
   585         mSaveSimContactsListSDN.clear(); 
       
   586         mImportSimPopup->close();
       
   587         // Importing finished, go back to NamesView
       
   588         showPreviousView();
       
   589     }   
       
   590 }
       
   591 
       
   592 void CntImportsView::adnCacheStatusReady(SimUtility::CacheStatus& cacheStatus, int error)
       
   593 {
       
   594     mWaitingForAdnCache = false;
       
   595     //update ADN store info...
       
   596     if (error != 0 || cacheStatus == SimUtility::ECacheFailed)
       
   597     {
       
   598         mAdnStorePresent = false;
       
   599         mAdnEntriesPresent = false;
       
   600     }
       
   601     else
       
   602     {
       
   603         //check if there are ADN contacts
       
   604         mAdnStorePresent = true;
       
   605         mAdnEntriesPresent = false;
       
   606         int getSimInfoError = -1;
       
   607         SimUtility::SimInfo simInfo = mSimUtility->getSimInfo(getSimInfoError);
       
   608         if (!getSimInfoError)
       
   609         {
       
   610             // sim entries are present
       
   611             mAdnStoreEntries = simInfo.usedEntries;
       
   612             if (mAdnStoreEntries > 0) 
       
   613             { 
       
   614                 mAdnEntriesPresent = true;
       
   615             }
       
   616         }
       
   617     }
       
   618     
       
   619     //and start SIM contacts import, if user tapped "SIM import"
       
   620     if(mImportSimPopup != NULL && mImportSimPopup->isActive())
       
   621     {
       
   622         if (!startSimImport())
       
   623         {
       
   624             //dismiss wait note
       
   625             mImportSimPopup->close();
       
   626             //and show error note
       
   627             simInfoErrorMessage(KErrAccessDenied);
       
   628         }
       
   629     }
       
   630 }
       
   631 
       
   632 // EOF