deviceupdatesui/deviceupdates/src/dmfotaview.cpp
changeset 42 aa33c2cb9a50
parent 27 516a867811c3
child 64 f2a9f5a3b8ba
equal deleted inserted replaced
41:c742e1129640 42:aa33c2cb9a50
    28 #include <centralrepository.h>
    28 #include <centralrepository.h>
    29 #include <sysversioninfo.h>
    29 #include <sysversioninfo.h>
    30 #include "nsmldmsyncprivatecrkeys.h"
    30 #include "nsmldmsyncprivatecrkeys.h"
    31 #include "dmadvancedview.h"
    31 #include "dmadvancedview.h"
    32 #include "dmfotaview.h"
    32 #include "dmfotaview.h"
       
    33 #include <xqconversions.h>
       
    34 #include "deviceupdatemoniter.h"
       
    35 #include "DeviceUpdateDebug.h"
    33 // ============================ MEMBER FUNCTIONS ===============================
    36 // ============================ MEMBER FUNCTIONS ===============================
    34     
    37     
    35 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    36 // DMFotaView::DMFotaView
    39 // DMFotaView::DMFotaView
    37 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    38 //
    41 //
    39 DMFotaView::DMFotaView(HbMainWindow *mainWindow):
    42 DMFotaView::DMFotaView(HbMainWindow *mainWindow):
    40     mMainWindow(mainWindow),profilesView(NULL)
    43     mMainWindow(mainWindow),profilesView(NULL),Connected(EFalse)
    41 {
    44 {
       
    45     qDebug("DMFotaView::DMFotaView >>");
    42     fotaPortraitView=0;
    46     fotaPortraitView=0;
    43     fotaLandscapeView=0;
    47     fotaLandscapeView=0;
       
    48     mainDmInfo=0;
       
    49     qDebug("DMFotaView::DMFotaView <<");
    44 }
    50 }
    45 
    51 
    46 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    47 // DMFotaView::~DMFotaView
    53 // DMFotaView::~DMFotaView
    48 // 
    54 // 
    49 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    50 //
    56 //
    51 DMFotaView::~DMFotaView()
    57 DMFotaView::~DMFotaView()
    52 { 
    58 {
       
    59     qDebug("DMFotaView::~DMFotaView >>");
       
    60     if(mainDmInfo)
       
    61         delete mainDmInfo;
       
    62     
       
    63     if (iFotaEngine.Handle())
       
    64         iFotaEngine.Close();
       
    65 
       
    66     if (iMoniter)
       
    67         {
       
    68         iMoniter->Cancel();
       
    69         delete iMoniter;
       
    70         }
       
    71     qDebug("DMFotaView::~DMFotaView <<");
    53 }
    72 }
    54 
    73 
    55 // -----------------------------------------------------------------------------
    74 // -----------------------------------------------------------------------------
    56 // DMFotaView::addFotaView
    75 // DMFotaView::addFotaView
    57 // Creates and adds the Fota Portrait and Landscape View
    76 // Creates and adds the Fota Portrait and Landscape View
    58 // -----------------------------------------------------------------------------
    77 // -----------------------------------------------------------------------------
    59 //
    78 //
    60 bool DMFotaView::addFotaView()
    79 bool DMFotaView::addFotaView()
    61     {
    80     {
       
    81     qDebug("DMFotaView::addFotaView >>");
    62     connect( mMainWindow, SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( readSection(Qt::Orientation) ) );
    82     connect( mMainWindow, SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( readSection(Qt::Orientation) ) );
    63         
    83         
    64     bool ok = false;
    84     bool ok = false;
    65     QString val,val2;
    85     QString val,val2;
    66     loader.load(":/xml/devman.docml", &ok);
    86     loader.load(":/xml/devman.docml", &ok);
   105     label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:title"));
   125     label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:title"));
   106     val = hbTrId("txt_device_update_subhead_device_updates");
   126     val = hbTrId("txt_device_update_subhead_device_updates");
   107     label->setPlainText(val);
   127     label->setPlainText(val);
   108     label2->setPlainText(val);
   128     label2->setPlainText(val);
   109     
   129     
   110     //Setting help text for update button
   130     
   111     label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
       
   112     label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
       
   113     val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
       
   114     label->setPlainText(val);
       
   115     label2->setPlainText(val);
       
   116     
   131     
   117     HbScrollArea* area = qobject_cast<HbScrollArea*> (loader.findWidget("scrollArea"));
   132     HbScrollArea* area = qobject_cast<HbScrollArea*> (loader.findWidget("scrollArea"));
   118     area->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn);
   133     area->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn);
   119     
   134     
   120     
   135     
   201     phone.GetPhoneId( status, telid );
   216     phone.GetPhoneId( status, telid );
   202     User::WaitForRequest( status );
   217     User::WaitForRequest( status );
   203     TBuf <50> imei;
   218     TBuf <50> imei;
   204     if (status==KErrNone)
   219     if (status==KErrNone)
   205     {
   220     {
       
   221     TBuf<100> phoneName;
   206     imei.Copy(telid.iSerialNumber);
   222     imei.Copy(telid.iSerialNumber);
   207     }
   223     }
   208     phone.Close();
   224     phone.Close();
   209     
       
   210     telServer.Close();
   225     telServer.Close();
   211 
   226 
   212     //type
   227     //type
   213     if(typedesignator.Length()>0)
   228     if(typedesignator.Length()>0)
   214         {
   229         {
   251         val = hbTrId("txt_device_update_dblist_imei");
   266         val = hbTrId("txt_device_update_dblist_imei");
   252         str = QString::fromUtf16(imei.Ptr(), imei.Length()); 
   267         str = QString::fromUtf16(imei.Ptr(), imei.Length()); 
   253         FormatList(val,str);
   268         FormatList(val,str);
   254         }
   269         }
   255 
   270 
   256     
   271    
   257     val = hbTrId("txt_device_update_button_update");
   272     iFotaState = FotaEngineL().GetState(-1);
   258     HbPushButton *updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
   273     
   259     updateButton->setText(val);
   274     TBuf8<80> Name;
   260     QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   275     TBuf8<80> Version;
   261     updateButton = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
   276     TInt Size;
   262     updateButton->setText(val);
   277     
   263     QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   278     if(iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState == RFotaEngineSession::EStartingUpdate
       
   279             || iFotaState == RFotaEngineSession::EStartingDownload || iFotaState == RFotaEngineSession::EDownloadProgressing)
       
   280         {
       
   281         label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
       
   282         label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
       
   283         FotaEngineL().GetCurrentFirmwareDetailsL(Name, Version, Size);
       
   284         
       
   285         const QString
       
   286         name =
       
   287                 QString::fromUtf8(
       
   288                         reinterpret_cast<const char*> (Name.Ptr()),
       
   289                                 Name.Length());
       
   290         const QString
       
   291         ver =
       
   292                 QString::fromUtf8(
       
   293                         reinterpret_cast<const char*> (Version.Ptr()),
       
   294                                 Version.Length());
       
   295         
       
   296         TInt sizeKB = Size / 1024;
       
   297         if(sizeKB < 1024)
       
   298             {
       
   299             val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_kb").arg(name)
       
   300                     .arg(ver).arg(sizeKB);
       
   301             }
       
   302         else
       
   303             {
       
   304             TInt sizeMB = sizeKB / 1024;
       
   305             val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
       
   306                     .arg(ver).arg(sizeMB);
       
   307             }
       
   308         label->setPlainText(val);
       
   309         label2->setPlainText(val);
       
   310 		
       
   311 		val = hbTrId("txt_device_update_button_resume_update");
       
   312     
       
   313         updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
       
   314         updateButton->setText(val);
       
   315         QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
       
   316         updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
       
   317         updateButtonLandscape->setText(val);
       
   318 		QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
       
   319 		Connected = ETrue;
       
   320         }
       
   321     else
       
   322         {
       
   323         //Setting help text for update button
       
   324         label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
       
   325         label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
       
   326         val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
       
   327         label->setPlainText(val);
       
   328         label2->setPlainText(val);
       
   329         
       
   330         val = hbTrId("txt_device_update_button_update");
       
   331         updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
       
   332         updateButton->setText(val);
       
   333         QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
       
   334         updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
       
   335         updateButtonLandscape->setText(val);
       
   336         QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
       
   337         Connected = ETrue;
       
   338         }
   264     
   339     
   265     val = hbTrId("txt_device_update_button_advanced");
   340     val = hbTrId("txt_device_update_button_advanced");
   266     HbPushButton *advancedButton = qobject_cast<HbPushButton*>(loader.findWidget("p:advanced")); 
   341     advancedButton = qobject_cast<HbPushButton*>(loader.findWidget("p:advanced")); 
   267     advancedButton->setText(val);
   342     advancedButton->setText(val);
   268     QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
   343     QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
   269     advancedButton = qobject_cast<HbPushButton*>(loader2.findWidget("l:advanced"));
   344     advancedButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:advanced"));
   270     advancedButton->setText(val);
   345     advancedButtonLandscape->setText(val);
   271     QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
   346     QObject::connect(advancedButtonLandscape, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
   272 
   347     fotaSupportEnabled();
   273     
       
   274     mMainWindow->addView(fotaPortraitView);
   348     mMainWindow->addView(fotaPortraitView);
   275     mMainWindow->addView(fotaLandscapeView);
   349     mMainWindow->addView(fotaLandscapeView);
   276     
   350     
   277     if(mMainWindow->orientation()==Qt::Vertical)
   351     if(mMainWindow->orientation()==Qt::Vertical)
   278             mMainWindow->setCurrentView(fotaPortraitView);
   352             mMainWindow->setCurrentView(fotaPortraitView);
   279         else
   353         else
   280             mMainWindow->setCurrentView(fotaLandscapeView);
   354             mMainWindow->setCurrentView(fotaLandscapeView);
       
   355     
       
   356     iMoniter = CDeviceUpdateMoniter::NewL(this);
       
   357     //iMoniter->StartMoniter();
       
   358     qDebug("DMFotaView::addFotaView <<");
   281     return ETrue;
   359     return ETrue;
   282     }
   360     }
   283 
   361 
   284 // -----------------------------------------------------------------------------
   362 // -----------------------------------------------------------------------------
   285 // DMFotaView::CheckforUpdate
   363 // DMFotaView::CheckforUpdate
   286 // Checks for updates from the default server
   364 // Checks for updates from the default server
   287 // -----------------------------------------------------------------------------
   365 // -----------------------------------------------------------------------------
   288 //
   366 //
   289 void DMFotaView::CheckforUpdate()
   367 void DMFotaView::CheckforUpdate()
   290  {
   368  {
   291     /*TInt profileId=NULL;
   369     qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
       
   370     
       
   371     TInt profileId=NULL;
   292     if(mainDmInfo==0)
   372     if(mainDmInfo==0)
   293         {
   373         {
   294         if(!profilesView)
   374         if(!profilesView)
   295             {
   375             {
   296             mainDmInfo = new DmInfo();
   376             bool launchview = false;
   297             mainDmInfo->refreshProfileList();
   377             AdvancedDeviceManager(launchview);
       
   378            /* mainDmInfo = new DmInfo();
       
   379             mainDmInfo->refreshProfileList();*/
   298             }
   380             }
   299         else 
   381        // else 
   300             {
   382         mainDmInfo = profilesView->dminfo;      
   301             mainDmInfo = profilesView->dminfo;
       
   302             }
       
   303         }
   383         }
   304     if((profileId = mainDmInfo->DefaultFotaProfileIdL())==KErrNotFound)
   384     if((profileId = mainDmInfo->DefaultFotaProfileIdL())==KErrNotFound)
   305         {*/
   385         {
   306 
   386 
   307         HbNotificationDialog* note = new HbNotificationDialog();
   387         HbNotificationDialog* note = new HbNotificationDialog();
   308         QString val = hbTrId("txt_device_update_info_no_server_configured_to_get");
   388         QString val = hbTrId("txt_device_update_info_no_server_configured_to_get");
   309         note->setTitle(val);
   389         note->setTitle(val);
   310         note->setTitleTextWrapping(Hb::TextWordWrap);
   390         note->setTitleTextWrapping(Hb::TextWordWrap);
   311         note->setDismissPolicy(HbPopup::TapAnywhere);
   391         note->setDismissPolicy(HbPopup::TapAnywhere);
   312         note->setTimeout(HbPopup::StandardTimeout);
   392         note->setTimeout(HbPopup::StandardTimeout);
   313         note->setAttribute(Qt::WA_DeleteOnClose, true);
   393         note->setAttribute(Qt::WA_DeleteOnClose, true);
   314         note->open();
   394         note->open();
   315        /* }
   395         }
   316     else
   396     else
   317         {
   397         {
   318         mainDmInfo->sync(profileId);
   398         mainDmInfo->sync(profileId);
   319         }*/
   399         //Connecting note to be displayed
       
   400         //Buttons to be disabled
       
   401         displayNoteAndDisableButtons();
       
   402         
       
   403         }
       
   404     qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
   320  }
   405  }
       
   406 
       
   407 
       
   408 void DMFotaView::ResumeUpdate()
       
   409     {
       
   410     qDebug("omadm DeviceManagerUi::ResumeUpdate >>");
       
   411     
       
   412     
       
   413     if(iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState == RFotaEngineSession::EStartingUpdate)
       
   414         {
       
   415         qDebug("Calling resuming of update");
       
   416         FotaEngineL().Update(-1,(TSmlProfileId)1, _L8(""), _L8(""));
       
   417         }
       
   418     else if(iFotaState == RFotaEngineSession::EStartingDownload || iFotaState == RFotaEngineSession::EDownloadProgressing)
       
   419         {
       
   420         qDebug("Calling resuming of download");
       
   421         FotaEngineL().TryResumeDownload(EFalse);        
       
   422         }
       
   423     
       
   424     qDebug("omadm DeviceManagerUi::ResumeUpdate <<");
       
   425     }
       
   426 
       
   427 // -----------------------------------------------------------------------------
       
   428 // DMFotaView::displayNoteAndDisableButtons
       
   429 // Displays the connecting note and disable all buttons
       
   430 // -----------------------------------------------------------------------------
       
   431 //
       
   432 void DMFotaView::displayNoteAndDisableButtons()
       
   433     {
       
   434     qDebug("DMFotaView::displayNoteAndDisableButtons >>");
       
   435     updateButton->setEnabled(false);
       
   436     advancedButton->setEnabled(false);
       
   437     updateButtonLandscape->setEnabled(false);
       
   438     advancedButtonLandscape->setEnabled(false);
       
   439     HbNotificationDialog* note = new HbNotificationDialog();
       
   440     //QString val = hbTrId("txt_device_update_dpophead_device_update");
       
   441     note->setTitle(hbTrId("txt_device_update_dpophead_device_update"));
       
   442     note->setTitleTextWrapping(Hb::TextWordWrap);
       
   443     note->setText(hbTrId("txt_device_update_info_connecting"));
       
   444     HbIcon icon1;
       
   445     icon1.setIconName(":/icons/qgn_prop_sml_http.svg");
       
   446     note->setIcon(icon1);
       
   447     note->setAttribute(Qt::WA_DeleteOnClose, true);
       
   448     note->open();
       
   449     qDebug("DMFotaView::displayNoteAndDisableButtons <<");
       
   450     }
       
   451 
       
   452 // -----------------------------------------------------------------------------
       
   453 // DMFotaView::enableButtons
       
   454 // Enables checkupdate and Advancedsetting buttons
       
   455 // -----------------------------------------------------------------------------
       
   456 //
       
   457 void DMFotaView::enableButtons()
       
   458     {
       
   459     qDebug("DMFotaView::enableButtons >>");
       
   460     TInt value (0);
       
   461     RProperty::Get(TUid::Uid(KOmaDMAppUid), KFotaServerActive, value);
       
   462     if (!value)
       
   463         {
       
   464         fotaSupportEnabled();
       
   465         advancedButtonLandscape->setEnabled(true);
       
   466         advancedButton->setEnabled(true);
       
   467         }
       
   468     qDebug("DMFotaView::enableButtons <<");
       
   469     }
   321 
   470 
   322 // -----------------------------------------------------------------------------
   471 // -----------------------------------------------------------------------------
   323 // DMFotaView::AdvancedDeviceManager
   472 // DMFotaView::AdvancedDeviceManager
   324 // Displays the Profiles view
   473 // Displays the Profiles view
   325 // -----------------------------------------------------------------------------
   474 // -----------------------------------------------------------------------------
   326 //
   475 //
   327 void DMFotaView::AdvancedDeviceManager()
   476 void DMFotaView::AdvancedDeviceManager(bool launchadvanceview)
   328  {
   477  { 
   329     
       
   330     qDebug("omadm DeviceManagerUi::AdvancedDeviceManager");
   478     qDebug("omadm DeviceManagerUi::AdvancedDeviceManager");
   331     if(!profilesView)
   479     if(!profilesView)
   332         {
   480         {
   333         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 1");
   481         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 1");
   334         profilesView = new DmAdvancedView(mMainWindow,this);
   482         profilesView = new DmAdvancedView(mMainWindow,this,mainDmInfo);
   335         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 2");
   483         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 2");
   336         bool loadingok = profilesView->displayItems();
   484         bool loadingok = profilesView->displayItems();
   337         if(loadingok)
   485         if(loadingok)
   338             {
   486             {
   339             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 3");
   487             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 3");
   340             mMainWindow->addView(profilesView);
   488             mMainWindow->addView(profilesView);
   341             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 4");
   489             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 4");
   342             profilesView->setBackBehavior();  
   490             profilesView->setBackBehavior();  
   343             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 5");
   491             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 5");
       
   492             if(launchadvanceview)
   344             mMainWindow->setCurrentView(profilesView);
   493             mMainWindow->setCurrentView(profilesView);
   345             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 6");
   494             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 6");
   346             }
   495             }
   347         else
   496         else
   348             {
   497             {
   353     else
   502     else
   354         {
   503         {
   355         profilesView->setBackBehavior();                
   504         profilesView->setBackBehavior();                
   356         mMainWindow->setCurrentView(profilesView);   
   505         mMainWindow->setCurrentView(profilesView);   
   357         }
   506         }
       
   507     qDebug("DMFotaView::AdvancedDeviceManager <<");
   358  }
   508  }
   359 
   509 
   360 // -----------------------------------------------------------------------------
   510 // -----------------------------------------------------------------------------
   361 // DMFotaView::FormatList
   511 // DMFotaView::FormatList
   362 // Adds data to the details list
   512 // Adds data to the details list
   363 // -----------------------------------------------------------------------------
   513 // -----------------------------------------------------------------------------
   364 //
   514 //
   365 void DMFotaView::FormatList(QString val,QString str)
   515 void DMFotaView::FormatList(QString val,QString str)
   366     {
   516     {
       
   517     qDebug("DMFotaView::FormatList >>");
   367     label = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
   518     label = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
   368     label2 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));         
   519     label2 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));         
   369     label3 = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
   520     label3 = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
   370     label4 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));
   521     label4 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));
   371     label->setPlainText(val);
   522     label->setPlainText(val);
   374     label4->setPlainText(str);
   525     label4->setPlainText(str);
   375     label->setVisible(ETrue);
   526     label->setVisible(ETrue);
   376     label2->setVisible(ETrue);
   527     label2->setVisible(ETrue);
   377     label3->setVisible(ETrue);
   528     label3->setVisible(ETrue);
   378     label4->setVisible(ETrue);
   529     label4->setVisible(ETrue);
       
   530     qDebug("DMFotaView::FormatList <<");
       
   531     }
       
   532 
       
   533 
       
   534 inline RFotaEngineSession & DMFotaView::FotaEngineL()
       
   535     {
       
   536     qDebug("DMFotaView::FotaEngineL >>");
       
   537     if (!iFotaEngine.Handle())
       
   538         iFotaEngine.OpenL();
       
   539     qDebug("DMFotaView::FotaEngineL <<");
       
   540     return iFotaEngine;
   379     }
   541     }
   380 // -----------------------------------------------------------------------------
   542 // -----------------------------------------------------------------------------
   381 // DMFotaView::backtoMainWindow
   543 // DMFotaView::backtoMainWindow
   382 // Enables switching between views
   544 // Enables switching between views
   383 // -----------------------------------------------------------------------------
   545 // -----------------------------------------------------------------------------
   384 //
   546 //
   385 void DMFotaView::backtoMainWindow()
   547 void DMFotaView::backtoMainWindow()
   386     {
   548     {
       
   549     qDebug("DMFotaView::backtoMainWindow >>");
   387         qApp->quit();
   550         qApp->quit();
       
   551         qDebug("DMFotaView::backtoMainWindow <<");
   388     }
   552     }
   389 
   553 
   390 // -----------------------------------------------------------------------------
   554 // -----------------------------------------------------------------------------
   391 // DMFotaView::OnHelp
   555 // DMFotaView::OnHelp
   392 // Displays Help contents
   556 // Displays Help contents
   400 // DMFotaView::OnExit
   564 // DMFotaView::OnExit
   401 // -----------------------------------------------------------------------------
   565 // -----------------------------------------------------------------------------
   402 //
   566 //
   403 void DMFotaView::OnExit()
   567 void DMFotaView::OnExit()
   404 {
   568 {
       
   569     qDebug("DMFotaView::OnExit >>");
   405     qApp->quit();
   570     qApp->quit();
       
   571     qDebug("DMFotaView::OnExit <<");
   406 }
   572 }
   407 
   573 
   408 void DMFotaView::readSection( Qt::Orientation orientation )
   574 void DMFotaView::readSection( Qt::Orientation orientation )
   409 {
   575 {
       
   576     qDebug("DMFotaView::readSection >>");
   410     if(mMainWindow->currentView() == fotaPortraitView || mMainWindow->currentView() == fotaLandscapeView)
   577     if(mMainWindow->currentView() == fotaPortraitView || mMainWindow->currentView() == fotaLandscapeView)
   411         {
   578         {
   412         if( orientation == Qt::Vertical ) {
   579         if( orientation == Qt::Vertical ) {
   413         // reading "portrait" section
   580         // reading "portrait" section
   414         mMainWindow->setCurrentView(fotaPortraitView);
   581         mMainWindow->setCurrentView(fotaPortraitView);
   420         }
   587         }
   421     else if(mMainWindow->currentView()==profilesView)
   588     else if(mMainWindow->currentView()==profilesView)
   422         {
   589         {
   423         profilesView->reLayout(orientation);
   590         profilesView->reLayout(orientation);
   424         }
   591         }
       
   592     qDebug("DMFotaView::readSection <<");
   425 
   593 
   426 }   
   594 }   
   427 
   595 
   428 
   596 
   429 
   597 void DMFotaView::UpdateDMUI(TBool aVal)
       
   598     {
       
   599     qDebug("DMFotaView::UpdateDMUI >>");
       
   600     qDebug("DMFotaView::UpdateDMUI >>");
       
   601 	    QString val;
       
   602     if (aVal == 1)
       
   603         {
       
   604         qDebug("DMFotaView::aVal == 1 >>");
       
   605         if(Connected)
       
   606             {
       
   607             qDebug("DMFotaView::Connected >>");
       
   608             QObject::disconnect(updateButton,0,0,0);
       
   609             QObject::disconnect(updateButtonLandscape,0,0,0);
       
   610             Connected = EFalse;
       
   611             }
       
   612     
       
   613         iFotaState = FotaEngineL().GetState(-1);
       
   614 
       
   615         if (iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState
       
   616                 == RFotaEngineSession::EStartingUpdate || iFotaState
       
   617                 == RFotaEngineSession::EStartingDownload || iFotaState
       
   618                 == RFotaEngineSession::EDownloadProgressing)
       
   619             {
       
   620             qDebug("CDeviceUpdateMoniter::Resume >>");
       
   621             QString value = hbTrId("txt_device_update_button_resume_update");
       
   622             //updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update");
       
   623             updateButton->setText(value);
       
   624             QObject::connect(updateButton, SIGNAL(clicked()), this,SLOT(ResumeUpdate()));
       
   625             //updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update");
       
   626             updateButtonLandscape->setText(value);
       
   627 		QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
       
   628 		Connected = ETrue;
       
   629 
       
   630 		TBuf8<80> Name;
       
   631 		TBuf8<80> Version;
       
   632 		TInt Size;
       
   633 
       
   634 		FotaEngineL().GetCurrentFirmwareDetailsL(Name, Version, Size);
       
   635         
       
   636         	const QString
       
   637 	        name =
       
   638         	        QString::fromUtf8(
       
   639 	                        reinterpret_cast<const char*> (Name.Ptr()),
       
   640                                 Name.Length());
       
   641 	        const QString
       
   642 	        ver =
       
   643         		QString::fromUtf8(
       
   644                         reinterpret_cast<const char*> (Version.Ptr()),
       
   645                                 Version.Length());
       
   646         
       
   647         	TInt sizeKB = Size / 1024;
       
   648 	        if(sizeKB < 1024)
       
   649 	            {
       
   650 	            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_kb").arg(name)
       
   651 	                    .arg(ver).arg(sizeKB);
       
   652 	            }
       
   653 	        else
       
   654 	            {
       
   655 	            TInt sizeMB = sizeKB / 1024;
       
   656 	            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
       
   657         	            .arg(ver).arg(sizeMB);
       
   658 	            }
       
   659 	        
       
   660 	        label->setPlainText(val);
       
   661 	        label2->setPlainText(val);
       
   662 	    }
       
   663         else
       
   664 	    {
       
   665         qDebug("DMFotaView::Update >>");
       
   666         val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
       
   667 	    label->setPlainText(val);
       
   668 	    label2->setPlainText(val);
       
   669 	    val = hbTrId("txt_device_update_button_update");
       
   670 	    updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
       
   671 	    updateButton->setText(val);
       
   672 	    QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
       
   673 	    updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
       
   674 	    updateButtonLandscape->setText(val);
       
   675 	    QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
       
   676 	    Connected = ETrue;
       
   677 	    }
       
   678 	}
       
   679     fotaSupportEnabled();
       
   680     if(fotaValue == 1 && aVal == 0)
       
   681     {
       
   682     	updateButton->setEnabled(aVal);
       
   683       updateButtonLandscape->setEnabled(aVal);
       
   684     }
       
   685     advancedButton->setEnabled(aVal);
       
   686     advancedButtonLandscape->setEnabled(aVal);
       
   687     qDebug("DMFotaView::UpdateDMUI <<");
       
   688     qDebug("DMFotaView::UpdateDMUI <<");
       
   689 }
       
   690 
       
   691 void DMFotaView::fotaSupportEnabled()
       
   692     { 
       
   693     fotaValue = 1;	
       
   694     CRepository* centrep( NULL);
       
   695     TUid uidValue = {0x101F9A08}; // KCRFotaAdapterEnabled
       
   696     TInt err = KErrNone;
       
   697     TRAP(err,centrep = CRepository::NewL( uidValue)); 
       
   698     if(centrep && err == KErrNone )
       
   699     {  
       
   700         centrep->Get( 1 , fotaValue ); // KCRFotaAdapterEnabled     
       
   701         delete centrep;
       
   702     }
       
   703     if(fotaValue == 0 || fotaValue == 1)
       
   704         {
       
   705         updateButton->setEnabled(fotaValue);
       
   706         updateButtonLandscape->setEnabled(fotaValue);
       
   707         }
       
   708     }
       
   709     
       
   710