deviceupdatesui/deviceupdates/src/dmfotaview.cpp
branchRCL_3
changeset 57 6757f1e2efd2
equal deleted inserted replaced
55:c4687ff85147 57:6757f1e2efd2
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  Methods for DmFotaView.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <hbmainwindow.h>
       
    19 #include <hbpushbutton.h>
       
    20 #include <hbaction.h>
       
    21 #include <hbdialog.h>
       
    22 #include <sysutil.h>
       
    23 #include <hbscrollarea.h>
       
    24 #include <etel.h>
       
    25 #include <featmgr.h>
       
    26 #include <etelmm.h>
       
    27 #include <hbnotificationdialog.h>
       
    28 #include <centralrepository.h>
       
    29 #include <sysversioninfo.h>
       
    30 #include "nsmldmsyncprivatecrkeys.h"
       
    31 #include "dmadvancedview.h"
       
    32 #include "dmfotaview.h"
       
    33 #include <xqconversions.h>
       
    34 #include "deviceupdatemoniter.h"
       
    35 #include "DeviceUpdateDebug.h"
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37     
       
    38 // -----------------------------------------------------------------------------
       
    39 // DMFotaView::DMFotaView
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 DMFotaView::DMFotaView(HbMainWindow *mainWindow):
       
    43     mMainWindow(mainWindow),profilesView(NULL),Connected(EFalse)
       
    44 {
       
    45     qDebug("DMFotaView::DMFotaView >>");
       
    46     fotaPortraitView=0;
       
    47     fotaLandscapeView=0;
       
    48     mainDmInfo=0;
       
    49     qDebug("DMFotaView::DMFotaView <<");
       
    50 }
       
    51 
       
    52 // -----------------------------------------------------------------------------
       
    53 // DMFotaView::~DMFotaView
       
    54 // 
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 DMFotaView::~DMFotaView()
       
    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 <<");
       
    72 }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // DMFotaView::addFotaView
       
    76 // Creates and adds the Fota Portrait and Landscape View
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 bool DMFotaView::addFotaView()
       
    80     {
       
    81     qDebug("DMFotaView::addFotaView >>");
       
    82     connect( mMainWindow, SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( readSection(Qt::Orientation) ) );
       
    83         
       
    84     bool ok = false;
       
    85     QString val,val2;
       
    86     loader.load(":/xml/devman.docml", &ok);
       
    87     ok = false;
       
    88     loader2.load(":/xml/devman.docml", &ok);
       
    89     // Exit if the file format is invalid
       
    90     Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
       
    91     
       
    92     ok=false;
       
    93     loader.load(":/xml/devman.docml","Portrait", &ok);
       
    94     ok=false;
       
    95     loader2.load(":/xml/devman.docml","Landscape", &ok);
       
    96    
       
    97     // Load the view by name from the xml file
       
    98     fotaPortraitView = qobject_cast<HbView*>(loader.findWidget("p:view"));
       
    99     fotaLandscapeView = qobject_cast<HbView*>(loader2.findWidget("l:view"));
       
   100 
       
   101 
       
   102     HbAction *help = qobject_cast<HbAction*> (loader.findObject("help")); 
       
   103     help->setText(QString("txt_common_menu_help"));
       
   104     QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp()));
       
   105     HbAction *exit = qobject_cast<HbAction*> (loader.findObject("exit"));
       
   106     exit->setText(QString("txt_common_menu_exit"));
       
   107     QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit()));
       
   108 
       
   109     help = qobject_cast<HbAction*>(loader2.findObject("help"));
       
   110     help->setText(QString("txt_common_menu_help"));
       
   111     QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp()));
       
   112     exit = qobject_cast<HbAction*>( loader2.findObject("exit"));
       
   113     exit->setText(QString("txt_common_menu_exit"));
       
   114     QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit()));
       
   115     
       
   116     mSoftKeyBackAction = new HbAction(Hb::BackNaviAction ,this);
       
   117     mSoftKeyBackAction->setText("Back");
       
   118     connect(mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(backtoMainWindow()));
       
   119         
       
   120     
       
   121     i=0;
       
   122     QString str;
       
   123     //Setting title text
       
   124     label = qobject_cast<HbLabel*> (loader.findWidget("p:title"));
       
   125     label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:title"));
       
   126     val = hbTrId("txt_device_update_subhead_device_updates");
       
   127     label->setPlainText(val);
       
   128     label2->setPlainText(val);
       
   129     
       
   130     
       
   131     
       
   132     HbScrollArea* area = qobject_cast<HbScrollArea*> (loader.findWidget("scrollArea"));
       
   133     area->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn);
       
   134     
       
   135     
       
   136     list1 << "label" << "label_1" << "label_2" << "label_3" << "label_4" << "label_5" << "label_6"<<"label_7"<<"label_8"<<"label_9"<<"label_10"<<"label_11";
       
   137     list2 << "label_13" << "label_14" << "label_15" << "label_16" << "label_17" << "label_18" << "label_19"<<"label_20"<<"label_21"<<"label_22"<<"label_23"<<"label_24";
       
   138 
       
   139 
       
   140     //Product Release
       
   141     TBuf< KSysUtilVersionTextLength > prodrelease;
       
   142     prodrelease.Zero();
       
   143     if(SysUtil::GetPRInformation(prodrelease)==KErrNone)
       
   144         {
       
   145         val = hbTrId("txt_device_update_dblist_product_release");
       
   146         str = QString::fromUtf16(prodrelease.Ptr(), prodrelease.Length());
       
   147         FormatList(val,str);
       
   148         }
       
   149     
       
   150     //Software version
       
   151     
       
   152     TBuf< KSysUtilVersionTextLength > swversion;
       
   153     TBuf< KSysUtilVersionTextLength > swversiondate;
       
   154     TBuf< KSysUtilVersionTextLength > typedesignator;
       
   155     TBuf< KSysUtilVersionTextLength > version;
       
   156     swversion.Zero();
       
   157     version.Zero();
       
   158     typedesignator.Zero();
       
   159     swversiondate.Zero();
       
   160     if( SysUtil::GetSWVersion(version)==KErrNone)
       
   161         {
       
   162         TInt len= version.Length();
       
   163         TInt pos1 = version.Find(KSmlEOL);
       
   164              if( pos1 != KErrNotFound && len > pos1 )
       
   165                 {
       
   166                  TBuf<KSysUtilVersionTextLength> version1;
       
   167                  version1.Zero();
       
   168                  swversion.Append( version.Left(pos1));
       
   169                  version1.Append( version.Right( len-pos1-1 ));
       
   170                  len= version1.Length();
       
   171                  pos1 = version1.Find(KSmlEOL);
       
   172                  if( pos1 != KErrNotFound  && len > pos1 )
       
   173                      {
       
   174                      swversiondate.Append(version1.Left( pos1 ));
       
   175                      version.Zero();
       
   176                      version.Append( version1.Right( len-pos1-1 ));
       
   177                      len= version.Length();
       
   178                      pos1 = version.Find(KSmlEOL);
       
   179                      if( pos1 != KErrNotFound  && len > pos1 )
       
   180                          {
       
   181                          typedesignator.Append(version.Left(pos1));         
       
   182                          }
       
   183                      }
       
   184                 }
       
   185             val = hbTrId("txt_device_update_dblist_software_version");
       
   186             str = QString::fromUtf16(swversion.Ptr(), swversion.Length());
       
   187             FormatList(val,str);
       
   188             }
       
   189 
       
   190     //Model
       
   191     TBuf<100> phoneName;
       
   192     TInt error = SysVersionInfo::GetVersionInfo(SysVersionInfo::EModelVersion, phoneName);
       
   193     if (error==KErrNone)
       
   194     {
       
   195     
       
   196     //phoneName.Copy( telid.iModel );
       
   197     //imei.Copy(telid.iSerialNumber);
       
   198     if( phoneName.Length()>0 )
       
   199         {
       
   200         val = hbTrId("txt_device_update_dblist_model");
       
   201         str = QString::fromUtf16(phoneName.Ptr(), phoneName.Length());
       
   202         FormatList(val,str);
       
   203         }
       
   204     }
       
   205     RTelServer telServer;
       
   206     User::LeaveIfError( telServer.Connect() );
       
   207     RTelServer::TPhoneInfo teleinfo;
       
   208     User::LeaveIfError( telServer.GetPhoneInfo( 0, teleinfo ) );
       
   209     RMobilePhone phone;
       
   210     User::LeaveIfError( phone.Open( telServer, teleinfo.iName ) );
       
   211     User::LeaveIfError(phone.Initialise()); 
       
   212     TUint32 teleidentityCaps;
       
   213     phone.GetIdentityCaps( teleidentityCaps );
       
   214     RMobilePhone::TMobilePhoneIdentityV1 telid;
       
   215     TRequestStatus status;
       
   216     phone.GetPhoneId( status, telid );
       
   217     User::WaitForRequest( status );
       
   218     TBuf <50> imei;
       
   219     if (status==KErrNone)
       
   220     {
       
   221     TBuf<100> phoneName;
       
   222     imei.Copy(telid.iSerialNumber);
       
   223     }
       
   224     phone.Close();
       
   225     telServer.Close();
       
   226 
       
   227     //type
       
   228     if(typedesignator.Length()>0)
       
   229         {
       
   230         val = hbTrId("txt_device_update_dblist_type");
       
   231         str = QString::fromUtf16(typedesignator.Ptr(), typedesignator.Length());
       
   232         FormatList(val,str);
       
   233         }
       
   234       
       
   235     //Product Code
       
   236        /* TInt runtimesupport(0);
       
   237         CRepository* cenrep = NULL;
       
   238         TRAPD( error, cenrep = CRepository::NewL( KCRUidNSmlDMSyncApp ) );  
       
   239         if(error)
       
   240             {
       
   241             runtimesupport=1;
       
   242             }
       
   243         if ( cenrep )
       
   244                 {
       
   245                 cenrep->Get( KNsmlDmRuntimeVerSupport, runtimesupport );
       
   246                 delete cenrep; cenrep = NULL;
       
   247                 }
       
   248           if(runtimesupport)
       
   249           { */
       
   250          TBuf<KSysUtilVersionTextLength> productcode;
       
   251          productcode.Zero();
       
   252          error = SysVersionInfo::GetVersionInfo(SysVersionInfo::EProductCode, productcode);
       
   253          if(error ==KErrNone )
       
   254          {            
       
   255              if( productcode.Length()>0 )
       
   256              {        
       
   257              val = hbTrId("txt_device_update_dblist_product_code");
       
   258              str = QString::fromUtf16(productcode.Ptr(), productcode.Length());  
       
   259              FormatList(val,str);
       
   260              }                    
       
   261         }
       
   262 
       
   263     //IMEI   
       
   264     if(imei.Length()>0)
       
   265         {
       
   266         val = hbTrId("txt_device_update_dblist_imei");
       
   267         str = QString::fromUtf16(imei.Ptr(), imei.Length()); 
       
   268         FormatList(val,str);
       
   269         }
       
   270 
       
   271    
       
   272     iFotaState = FotaEngineL().GetState(-1);
       
   273     
       
   274     TBuf8<80> Name;
       
   275     TBuf8<80> Version;
       
   276     TInt Size;
       
   277     
       
   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         }
       
   339     
       
   340     val = hbTrId("txt_device_update_button_advanced");
       
   341     advancedButton = qobject_cast<HbPushButton*>(loader.findWidget("p:advanced")); 
       
   342     advancedButton->setText(val);
       
   343     QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
       
   344     advancedButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:advanced"));
       
   345     advancedButtonLandscape->setText(val);
       
   346     QObject::connect(advancedButtonLandscape, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
       
   347     fotaSupportEnabled();
       
   348     mMainWindow->addView(fotaPortraitView);
       
   349     mMainWindow->addView(fotaLandscapeView);
       
   350     
       
   351     if(mMainWindow->orientation()==Qt::Vertical)
       
   352             mMainWindow->setCurrentView(fotaPortraitView);
       
   353         else
       
   354             mMainWindow->setCurrentView(fotaLandscapeView);
       
   355     
       
   356     iMoniter = CDeviceUpdateMoniter::NewL(this);
       
   357     //iMoniter->StartMoniter();
       
   358     qDebug("DMFotaView::addFotaView <<");
       
   359     return ETrue;
       
   360     }
       
   361 
       
   362 // -----------------------------------------------------------------------------
       
   363 // DMFotaView::CheckforUpdate
       
   364 // Checks for updates from the default server
       
   365 // -----------------------------------------------------------------------------
       
   366 //
       
   367 void DMFotaView::CheckforUpdate()
       
   368  {
       
   369     qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
       
   370     
       
   371     TInt profileId=NULL;
       
   372     if(mainDmInfo==0)
       
   373         {
       
   374         if(!profilesView)
       
   375             {
       
   376             bool launchview = false;
       
   377             AdvancedDeviceManager(launchview);
       
   378            /* mainDmInfo = new DmInfo();
       
   379             mainDmInfo->refreshProfileList();*/
       
   380             }
       
   381        // else 
       
   382         mainDmInfo = profilesView->dminfo;      
       
   383         }
       
   384     if((profileId = mainDmInfo->DefaultFotaProfileIdL())==KErrNotFound)
       
   385         {
       
   386 
       
   387         HbNotificationDialog* note = new HbNotificationDialog();
       
   388         QString val = hbTrId("txt_device_update_info_no_server_configured_to_get");
       
   389         note->setTitle(val);
       
   390         note->setTitleTextWrapping(Hb::TextWordWrap);
       
   391         note->setDismissPolicy(HbPopup::TapAnywhere);
       
   392         note->setTimeout(HbPopup::StandardTimeout);
       
   393         note->setAttribute(Qt::WA_DeleteOnClose, true);
       
   394         note->open();
       
   395         }
       
   396     else
       
   397         {
       
   398         mainDmInfo->sync(profileId);
       
   399         //Connecting note to be displayed
       
   400         //Buttons to be disabled
       
   401         displayNoteAndDisableButtons();
       
   402         
       
   403         }
       
   404     qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
       
   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     }
       
   470 
       
   471 // -----------------------------------------------------------------------------
       
   472 // DMFotaView::AdvancedDeviceManager
       
   473 // Displays the Profiles view
       
   474 // -----------------------------------------------------------------------------
       
   475 //
       
   476 void DMFotaView::AdvancedDeviceManager(bool launchadvanceview)
       
   477  { 
       
   478     qDebug("omadm DeviceManagerUi::AdvancedDeviceManager");
       
   479     if(!profilesView)
       
   480         {
       
   481         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 1");
       
   482         profilesView = new DmAdvancedView(mMainWindow,this,mainDmInfo);
       
   483         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 2");
       
   484         bool loadingok = profilesView->displayItems();
       
   485         if(loadingok)
       
   486             {
       
   487             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 3");
       
   488             mMainWindow->addView(profilesView);
       
   489             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 4");
       
   490             profilesView->setBackBehavior();  
       
   491             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 5");
       
   492             if(launchadvanceview)
       
   493             mMainWindow->setCurrentView(profilesView);
       
   494             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 6");
       
   495             }
       
   496         else
       
   497             {
       
   498             qFatal("omadm Unable to read groupbox.docml");
       
   499         
       
   500             }
       
   501         }
       
   502     else
       
   503         {
       
   504         profilesView->setBackBehavior();                
       
   505         mMainWindow->setCurrentView(profilesView);   
       
   506         }
       
   507     qDebug("DMFotaView::AdvancedDeviceManager <<");
       
   508  }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // DMFotaView::FormatList
       
   512 // Adds data to the details list
       
   513 // -----------------------------------------------------------------------------
       
   514 //
       
   515 void DMFotaView::FormatList(QString val,QString str)
       
   516     {
       
   517     qDebug("DMFotaView::FormatList >>");
       
   518     label = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
       
   519     label2 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));         
       
   520     label3 = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
       
   521     label4 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));
       
   522     label->setPlainText(val);
       
   523     label2->setPlainText(val);
       
   524     label3->setPlainText(str);
       
   525     label4->setPlainText(str);
       
   526     label->setVisible(ETrue);
       
   527     label2->setVisible(ETrue);
       
   528     label3->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;
       
   541     }
       
   542 // -----------------------------------------------------------------------------
       
   543 // DMFotaView::backtoMainWindow
       
   544 // Enables switching between views
       
   545 // -----------------------------------------------------------------------------
       
   546 //
       
   547 void DMFotaView::backtoMainWindow()
       
   548     {
       
   549     qDebug("DMFotaView::backtoMainWindow >>");
       
   550         qApp->quit();
       
   551         qDebug("DMFotaView::backtoMainWindow <<");
       
   552     }
       
   553 
       
   554 // -----------------------------------------------------------------------------
       
   555 // DMFotaView::OnHelp
       
   556 // Displays Help contents
       
   557 // -----------------------------------------------------------------------------
       
   558 //
       
   559 void DMFotaView::OnHelp()
       
   560 {   
       
   561 }
       
   562 
       
   563 // -----------------------------------------------------------------------------
       
   564 // DMFotaView::OnExit
       
   565 // -----------------------------------------------------------------------------
       
   566 //
       
   567 void DMFotaView::OnExit()
       
   568 {
       
   569     qDebug("DMFotaView::OnExit >>");
       
   570     qApp->quit();
       
   571     qDebug("DMFotaView::OnExit <<");
       
   572 }
       
   573 
       
   574 void DMFotaView::readSection( Qt::Orientation orientation )
       
   575 {
       
   576     qDebug("DMFotaView::readSection >>");
       
   577     if(mMainWindow->currentView() == fotaPortraitView || mMainWindow->currentView() == fotaLandscapeView)
       
   578         {
       
   579         if( orientation == Qt::Vertical ) {
       
   580         // reading "portrait" section
       
   581         mMainWindow->setCurrentView(fotaPortraitView);
       
   582         }
       
   583      else {
       
   584         // reading "landscape" section
       
   585         mMainWindow->setCurrentView(fotaLandscapeView);
       
   586          }
       
   587         }
       
   588     else if(mMainWindow->currentView()==profilesView)
       
   589         {
       
   590         profilesView->reLayout(orientation);
       
   591         }
       
   592     qDebug("DMFotaView::readSection <<");
       
   593 
       
   594 }   
       
   595 
       
   596 
       
   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