deviceupdatesui/deviceupdates/src/dmfotaview.cpp
changeset 67 fdbfe0a95492
parent 62 03849bd79877
child 71 a6c938002837
equal deleted inserted replaced
62:03849bd79877 67:fdbfe0a95492
    20 #include <hbaction.h>
    20 #include <hbaction.h>
    21 #include <hbdialog.h>
    21 #include <hbdialog.h>
    22 #include <sysutil.h>
    22 #include <sysutil.h>
    23 #include <hbscrollarea.h>
    23 #include <hbscrollarea.h>
    24 #include <etel.h>
    24 #include <etel.h>
    25 #include <eikenv.h>
       
    26 #include <featmgr.h>
    25 #include <featmgr.h>
    27 #include <etelmm.h>
    26 #include <etelmm.h>
    28 #include <apgtask.h>
       
    29 #include <coemain.h>
       
    30 #include <hbnotificationdialog.h>
    27 #include <hbnotificationdialog.h>
    31 #include <centralrepository.h>
    28 #include <centralrepository.h>
    32 #include <sysversioninfo.h>
    29 #include <sysversioninfo.h>
    33 #include "nsmldmsyncprivatecrkeys.h"
    30 #include "nsmldmsyncprivatecrkeys.h"
    34 #include "dmadvancedview.h"
    31 #include "dmadvancedview.h"
    40     
    37     
    41 // -----------------------------------------------------------------------------
    38 // -----------------------------------------------------------------------------
    42 // DMFotaView::DMFotaView
    39 // DMFotaView::DMFotaView
    43 // -----------------------------------------------------------------------------
    40 // -----------------------------------------------------------------------------
    44 //
    41 //
    45 DMFotaView::DMFotaView(HbMainWindow *mainWindow):
    42 DMFotaView::DMFotaView(HbMainWindow *aMainWindow,DMServiceProvider* aService):
    46     mMainWindow(mainWindow),profilesView(NULL),Connected(EFalse)
    43 mService(aService),mMainWindow(aMainWindow),mProfilesView(NULL),iConnected(EFalse)
    47 {
    44 {
    48     qDebug("DMFotaView::DMFotaView >>");
    45     qDebug("DMFotaView::DMFotaView >>");
    49     fotaPortraitView=0;
    46     mFotaPortraitView=NULL;
    50     fotaLandscapeView=0;
    47     mFotaLandscapeView=NULL;
    51     mainDmInfo=0;
    48     iMainDmInfo=NULL;
    52     qDebug("DMFotaView::DMFotaView <<");
    49     qDebug("DMFotaView::DMFotaView <<");
    53 }
    50 }
    54 
    51 
    55 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    56 // DMFotaView::~DMFotaView
    53 // DMFotaView::~DMFotaView
    58 // -----------------------------------------------------------------------------
    55 // -----------------------------------------------------------------------------
    59 //
    56 //
    60 DMFotaView::~DMFotaView()
    57 DMFotaView::~DMFotaView()
    61 {
    58 {
    62     qDebug("DMFotaView::~DMFotaView >>");
    59     qDebug("DMFotaView::~DMFotaView >>");
    63     if(mainDmInfo)
    60     if(iMainDmInfo)
    64         delete mainDmInfo;
    61         delete iMainDmInfo;
    65     
    62     
    66     if (iFotaEngine.Handle())
    63     if (iFotaEngine.Handle())
    67         iFotaEngine.Close();
    64         iFotaEngine.Close();
    68 
    65 
    69     if (iMoniter)
    66     if (iMoniter)
    84     qDebug("DMFotaView::addFotaView >>");
    81     qDebug("DMFotaView::addFotaView >>");
    85     connect( mMainWindow, SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( readSection(Qt::Orientation) ) );
    82     connect( mMainWindow, SIGNAL( orientationChanged(Qt::Orientation) ), this, SLOT( readSection(Qt::Orientation) ) );
    86         
    83         
    87     bool ok = false;
    84     bool ok = false;
    88     QString val,val2;
    85     QString val,val2;
    89     loader.load(":/xml/devman.docml", &ok);
    86     mLoader.load(":/xml/devman.docml", &ok);
    90     ok = false;
    87     ok = false;
    91     loader2.load(":/xml/devman.docml", &ok);
    88     mLoader2.load(":/xml/devman.docml", &ok);
    92     // Exit if the file format is invalid
    89     // Exit if the file format is invalid
    93     Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
    90     Q_ASSERT_X(ok, "Device Manager", "Invalid docml file");
    94     
    91     
    95     ok=false;
    92     ok=false;
    96     loader.load(":/xml/devman.docml","Portrait", &ok);
    93     mLoader.load(":/xml/devman.docml","Portrait", &ok);
    97     ok=false;
    94     ok=false;
    98     loader2.load(":/xml/devman.docml","Landscape", &ok);
    95     mLoader2.load(":/xml/devman.docml","Landscape", &ok);
    99    
    96    
   100     // Load the view by name from the xml file
    97     // Load the view by name from the xml file
   101     fotaPortraitView = qobject_cast<HbView*>(loader.findWidget("p:view"));
    98     mFotaPortraitView = qobject_cast<HbView*>(mLoader.findWidget("p:view"));
   102     fotaLandscapeView = qobject_cast<HbView*>(loader2.findWidget("l:view"));
    99     mFotaLandscapeView = qobject_cast<HbView*>(mLoader2.findWidget("l:view"));
   103 
   100 
   104 
   101 
   105     HbAction *help = qobject_cast<HbAction*> (loader.findObject("help")); 
   102     HbAction *help = qobject_cast<HbAction*> (mLoader.findObject("help")); 
   106     help->setText(QString("txt_common_menu_help"));
   103     help->setText(QString("txt_common_menu_help"));
   107     QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp()));
   104     QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp()));
   108     HbAction *exit = qobject_cast<HbAction*> (loader.findObject("exit"));
   105     HbAction *exit = qobject_cast<HbAction*> (mLoader.findObject("exit"));
   109     exit->setText(QString("txt_common_menu_exit"));
   106     exit->setText(QString("txt_common_menu_exit"));
   110     QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit()));
   107     QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit()));
   111 
   108 
   112     help = qobject_cast<HbAction*>(loader2.findObject("help"));
   109     help = qobject_cast<HbAction*>(mLoader2.findObject("help"));
   113     help->setText(QString("txt_common_menu_help"));
   110     help->setText(QString("txt_common_menu_help"));
   114     QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp()));
   111     QObject::connect(help, SIGNAL(triggered()), this, SLOT(OnHelp()));
   115     exit = qobject_cast<HbAction*>( loader2.findObject("exit"));
   112     exit = qobject_cast<HbAction*>( mLoader2.findObject("exit"));
   116     exit->setText(QString("txt_common_menu_exit"));
   113     exit->setText(QString("txt_common_menu_exit"));
   117     QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit()));
   114     QObject::connect(exit, SIGNAL(triggered()), this, SLOT(OnExit()));
   118     
   115     
   119     mSoftKeyBackAction = new HbAction(Hb::BackNaviAction ,this);
   116     mSoftKeyBackAction = new HbAction(Hb::BackNaviAction ,this);
   120     mSoftKeyBackAction->setText("Back");
   117     mSoftKeyBackAction->setText("Back");
   121     fotaPortraitView->setNavigationAction(mSoftKeyBackAction);
   118     mFotaPortraitView->setNavigationAction(mSoftKeyBackAction);
   122 	fotaLandscapeView->setNavigationAction(mSoftKeyBackAction);
   119 	mFotaLandscapeView->setNavigationAction(mSoftKeyBackAction);
   123     connect(mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(backtoMainWindow()));
   120     connect(mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(backtoMainWindow()));
   124         
   121         
   125     
   122     
   126     i=0;
   123     iCount=0;
   127     QString str;
   124     QString str;
   128     //Setting title text
   125     //Setting title text
   129     label = qobject_cast<HbLabel*> (loader.findWidget("p:title"));
   126     mLabel = qobject_cast<HbLabel*> (mLoader.findWidget("p:title"));
   130     label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:title"));
   127     mLabel2 = qobject_cast<HbLabel*> (mLoader2.findWidget("l:title"));
   131     val = hbTrId("txt_device_update_subhead_device_updates");
   128     val = hbTrId("txt_device_update_subhead_device_updates");
   132     label->setPlainText(val);
   129     mLabel->setPlainText(val);
   133     label2->setPlainText(val);
   130     mLabel2->setPlainText(val);
   134     
   131     
   135     
   132     
   136     
   133     
   137     HbScrollArea* area = qobject_cast<HbScrollArea*> (loader.findWidget("scrollArea"));
   134     HbScrollArea* area = qobject_cast<HbScrollArea*> (mLoader.findWidget("scrollArea"));
   138     area->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn);
   135     area->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOn);
   139     
   136     
   140     
   137     
   141     list1 << "label" << "label_1" << "label_2" << "label_3" << "label_4" << "label_5" << "label_6"<<"label_7"<<"label_8"<<"label_9"<<"label_10"<<"label_11";
   138     mList1 << "label" << "label_1" << "label_2" << "label_3" << "label_4" << "label_5" << "label_6"<<"label_7"<<"label_8"<<"label_9"<<"label_10"<<"label_11";
   142     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";
   139     mList2 << "label_13" << "label_14" << "label_15" << "label_16" << "label_17" << "label_18" << "label_19"<<"label_20"<<"label_21"<<"label_22"<<"label_23"<<"label_24";
   143 
   140 
   144 
   141 
   145     //Product Release
   142     //Product Release
   146     TBuf< KSysUtilVersionTextLength > prodrelease;
   143     TBuf< KSysUtilVersionTextLength > prodrelease;
   147     prodrelease.Zero();
   144     prodrelease.Zero();
   281     TInt Size;
   278     TInt Size;
   282     
   279     
   283     if(iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState == RFotaEngineSession::EStartingUpdate
   280     if(iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState == RFotaEngineSession::EStartingUpdate
   284             || iFotaState == RFotaEngineSession::EStartingDownload || iFotaState == RFotaEngineSession::EDownloadProgressing)
   281             || iFotaState == RFotaEngineSession::EStartingDownload || iFotaState == RFotaEngineSession::EDownloadProgressing)
   285         {
   282         {
   286         label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
   283         mLabel = qobject_cast<HbLabel*> (mLoader.findWidget("p:updatelabel"));
   287         label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
   284         mLabel2 = qobject_cast<HbLabel*> (mLoader2.findWidget("l:updatelabel"));
   288         FotaEngineL().GetCurrentFirmwareDetailsL(Name, Version, Size);
   285         FotaEngineL().GetCurrentFirmwareDetailsL(Name, Version, Size);
   289         
   286         
   290         const QString
   287         const QString
   291         name =
   288         name =
   292                 QString::fromUtf8(
   289                 QString::fromUtf8(
   308             {
   305             {
   309             TInt sizeMB = sizeKB / 1024;
   306             TInt sizeMB = sizeKB / 1024;
   310             val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
   307             val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
   311                     .arg(ver).arg(sizeMB);
   308                     .arg(ver).arg(sizeMB);
   312             }
   309             }
   313         label->setPlainText(val);
   310         mLabel->setPlainText(val);
   314         label2->setPlainText(val);
   311         mLabel2->setPlainText(val);
   315 		
   312 		
   316 		val = hbTrId("txt_device_update_button_resume_update");
   313 		val = hbTrId("txt_device_update_button_resume_update");
   317     
   314     
   318         updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
   315         mUpdateButton = qobject_cast<HbPushButton*>(mLoader.findWidget("p:update"));
   319         updateButton->setText(val);
   316         mUpdateButton->setText(val);
   320         QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
   317         QObject::connect(mUpdateButton, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
   321         updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
   318         mUpdateButtonLandscape = qobject_cast<HbPushButton*>(mLoader2.findWidget("l:update"));
   322         updateButtonLandscape->setText(val);
   319         mUpdateButtonLandscape->setText(val);
   323 		QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
   320 		QObject::connect(mUpdateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
   324 		Connected = ETrue;
   321 		iConnected = ETrue;
   325         }
   322         }
   326     else
   323     else
   327         {
   324         {
   328         //Setting help text for update button
   325         //Setting help text for update button
   329         label = qobject_cast<HbLabel*> (loader.findWidget("p:updatelabel"));
   326         mLabel = qobject_cast<HbLabel*> (mLoader.findWidget("p:updatelabel"));
   330         label2 = qobject_cast<HbLabel*> (loader2.findWidget("l:updatelabel"));
   327         mLabel2 = qobject_cast<HbLabel*> (mLoader2.findWidget("l:updatelabel"));
   331         val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
   328         val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
   332         label->setPlainText(val);
   329         mLabel->setPlainText(val);
   333         label2->setPlainText(val);
   330         mLabel2->setPlainText(val);
   334         
   331         
   335         val = hbTrId("txt_device_update_button_update");
   332         val = hbTrId("txt_device_update_button_update");
   336         updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
   333         mUpdateButton = qobject_cast<HbPushButton*>(mLoader.findWidget("p:update"));
   337         updateButton->setText(val);
   334         mUpdateButton->setText(val);
   338         QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   335         QObject::connect(mUpdateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   339         updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
   336         mUpdateButtonLandscape = qobject_cast<HbPushButton*>(mLoader2.findWidget("l:update"));
   340         updateButtonLandscape->setText(val);
   337         mUpdateButtonLandscape->setText(val);
   341         QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   338         QObject::connect(mUpdateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   342         Connected = ETrue;
   339         iConnected = ETrue;
   343         }
   340         }
   344     
   341     
   345     val = hbTrId("txt_device_update_button_advanced");
   342     val = hbTrId("txt_device_update_button_advanced");
   346     advancedButton = qobject_cast<HbPushButton*>(loader.findWidget("p:advanced")); 
   343     mAdvancedButton = qobject_cast<HbPushButton*>(mLoader.findWidget("p:advanced")); 
   347     advancedButton->setText(val);
   344     mAdvancedButton->setText(val);
   348     QObject::connect(advancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
   345     QObject::connect(mAdvancedButton, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
   349     advancedButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:advanced"));
   346     mAdvancedButtonLandscape = qobject_cast<HbPushButton*>(mLoader2.findWidget("l:advanced"));
   350     advancedButtonLandscape->setText(val);
   347     mAdvancedButtonLandscape->setText(val);
   351     QObject::connect(advancedButtonLandscape, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
   348     QObject::connect(mAdvancedButtonLandscape, SIGNAL(clicked()), this, SLOT(AdvancedDeviceManager()));
   352     fotaSupportEnabled();
   349     fotaSupportEnabled();
   353     mMainWindow->addView(fotaPortraitView);
   350     mMainWindow->addView(mFotaPortraitView);
   354     mMainWindow->addView(fotaLandscapeView);
   351     mMainWindow->addView(mFotaLandscapeView);
   355     
   352     
   356     if(mMainWindow->orientation()==Qt::Vertical)
   353     if(mMainWindow->orientation()==Qt::Vertical)
   357             mMainWindow->setCurrentView(fotaPortraitView);
   354             mMainWindow->setCurrentView(mFotaPortraitView);
   358         else
   355         else
   359             mMainWindow->setCurrentView(fotaLandscapeView);
   356             mMainWindow->setCurrentView(mFotaLandscapeView);
   360     
   357     
   361     iMoniter = CDeviceUpdateMoniter::NewL(this);
   358     iMoniter = CDeviceUpdateMoniter::NewL(this);
   362     //iMoniter->StartMoniter();
   359     //iMoniter->StartMoniter();
   363     emit applicationReady();
   360     emit applicationReady();
   364     qDebug("DMFotaView::addFotaView <<");
   361     qDebug("DMFotaView::addFotaView <<");
   373 void DMFotaView::CheckforUpdate()
   370 void DMFotaView::CheckforUpdate()
   374  {
   371  {
   375     qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
   372     qDebug("omadm DeviceManagerUi::CheckforUpdate >>");
   376     
   373     
   377     TInt profileId=NULL;
   374     TInt profileId=NULL;
   378     if(mainDmInfo==0)
   375     if(iMainDmInfo==0)
   379         {
   376         {
   380         if(!profilesView)
   377         if(!mProfilesView)
   381             {
   378             {
   382             bool launchview = false;
   379             bool launchview = false;
   383             AdvancedDeviceManager(launchview);
   380             AdvancedDeviceManager(launchview);
   384            /* mainDmInfo = new DmInfo();
   381            /* mainDmInfo = new DmInfo();
   385             mainDmInfo->refreshProfileList();*/
   382             mainDmInfo->refreshProfileList();*/
   386             }
   383             }
   387        // else 
   384        // else 
   388         mainDmInfo = profilesView->dminfo;      
   385         iMainDmInfo = mProfilesView->dminfo;      
   389         }
   386         }
   390     if((profileId = mainDmInfo->DefaultFotaProfileIdL())==KErrNotFound)
   387     if((profileId = iMainDmInfo->DefaultFotaProfileIdL())==KErrNotFound)
   391         {
   388         {
   392 
   389 
   393         HbNotificationDialog* note = new HbNotificationDialog();
   390         HbNotificationDialog* note = new HbNotificationDialog();
   394         QString val = hbTrId("txt_device_update_info_no_server_configured_to_get");
   391         QString val = hbTrId("txt_device_update_info_no_server_configured_to_get");
   395         note->setTitle(val);
   392         note->setTitle(val);
   399         note->setAttribute(Qt::WA_DeleteOnClose, true);
   396         note->setAttribute(Qt::WA_DeleteOnClose, true);
   400         note->open();
   397         note->open();
   401         }
   398         }
   402     else
   399     else
   403         {
   400         {
   404         mainDmInfo->sync(profileId);
   401         iMainDmInfo->sync(profileId);
   405         //Connecting note to be displayed
   402         //Connecting note to be displayed
   406         //Buttons to be disabled
   403         //Buttons to be disabled
   407         displayNoteAndDisableButtons();
   404         displayNoteAndDisableButtons();
   408         
   405         
   409         }
   406         }
   436 // -----------------------------------------------------------------------------
   433 // -----------------------------------------------------------------------------
   437 //
   434 //
   438 void DMFotaView::displayNoteAndDisableButtons()
   435 void DMFotaView::displayNoteAndDisableButtons()
   439     {
   436     {
   440     qDebug("DMFotaView::displayNoteAndDisableButtons >>");
   437     qDebug("DMFotaView::displayNoteAndDisableButtons >>");
   441     updateButton->setEnabled(false);
   438     mUpdateButton->setEnabled(false);
   442     advancedButton->setEnabled(false);
   439     mAdvancedButton->setEnabled(false);
   443     updateButtonLandscape->setEnabled(false);
   440     mUpdateButtonLandscape->setEnabled(false);
   444     advancedButtonLandscape->setEnabled(false);
   441     mAdvancedButtonLandscape->setEnabled(false);
   445     HbNotificationDialog* note = new HbNotificationDialog();
   442     HbNotificationDialog* note = new HbNotificationDialog();
   446     //QString val = hbTrId("txt_device_update_dpophead_device_update");
   443     //QString val = hbTrId("txt_device_update_dpophead_device_update");
   447     note->setTitle(hbTrId("txt_device_update_dpophead_device_update"));
   444     note->setTitle(hbTrId("txt_device_update_dpophead_device_update"));
   448     note->setTitleTextWrapping(Hb::TextWordWrap);
   445     note->setTitleTextWrapping(Hb::TextWordWrap);
   449     note->setText(hbTrId("txt_device_update_info_connecting"));
   446     note->setText(hbTrId("txt_device_update_info_connecting"));
   466     TInt value (0);
   463     TInt value (0);
   467     RProperty::Get(TUid::Uid(KOmaDMAppUid), KFotaServerActive, value);
   464     RProperty::Get(TUid::Uid(KOmaDMAppUid), KFotaServerActive, value);
   468     if (!value)
   465     if (!value)
   469         {
   466         {
   470         fotaSupportEnabled();
   467         fotaSupportEnabled();
   471         advancedButtonLandscape->setEnabled(true);
   468         mAdvancedButtonLandscape->setEnabled(true);
   472         advancedButton->setEnabled(true);
   469         mAdvancedButton->setEnabled(true);
   473         }
   470         }
   474     qDebug("DMFotaView::enableButtons <<");
   471     qDebug("DMFotaView::enableButtons <<");
   475     }
   472     }
   476 
   473 
   477 // -----------------------------------------------------------------------------
   474 // -----------------------------------------------------------------------------
   480 // -----------------------------------------------------------------------------
   477 // -----------------------------------------------------------------------------
   481 //
   478 //
   482 void DMFotaView::AdvancedDeviceManager(bool launchadvanceview)
   479 void DMFotaView::AdvancedDeviceManager(bool launchadvanceview)
   483  { 
   480  { 
   484     qDebug("omadm DeviceManagerUi::AdvancedDeviceManager");
   481     qDebug("omadm DeviceManagerUi::AdvancedDeviceManager");
   485     if(!profilesView)
   482     if(!mProfilesView)
   486         {
   483         {
   487         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 1");
   484         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 1");
   488         profilesView = new DmAdvancedView(mMainWindow,this,mainDmInfo);
   485         mProfilesView = new DmAdvancedView(mMainWindow,this,iMainDmInfo);
   489         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 2");
   486         qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 2");
   490         bool loadingok = profilesView->displayItems();
   487         bool loadingok = mProfilesView->displayItems();
   491         if(loadingok)
   488         if(loadingok)
   492             {
   489             {
   493             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 3");
   490             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 3");
   494             mMainWindow->addView(profilesView);
   491             mMainWindow->addView(mProfilesView);
   495             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 4");
   492             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 4");
   496             profilesView->setBackBehavior();  
   493             mProfilesView->setBackBehavior();  
   497             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 5");
   494             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 5");
   498             if(launchadvanceview)
   495             if(launchadvanceview)
   499             mMainWindow->setCurrentView(profilesView);
   496             mMainWindow->setCurrentView(mProfilesView);
   500             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 6");
   497             qDebug("omadm DeviceManagerUi::AdvancedDeviceManager 6");
   501             }
   498             }
   502         else
   499         else
   503             {
   500             {
   504             qFatal("omadm Unable to read groupbox.docml");
   501             qFatal("omadm Unable to read groupbox.docml");
   505         
   502         
   506             }
   503             }
   507         }
   504         }
   508     else
   505     else
   509         {
   506         {
   510         profilesView->setBackBehavior();                
   507         mProfilesView->setBackBehavior();                
   511         mMainWindow->setCurrentView(profilesView);   
   508         mMainWindow->setCurrentView(mProfilesView);   
   512         }
   509         }
   513     qDebug("DMFotaView::AdvancedDeviceManager <<");
   510     qDebug("DMFotaView::AdvancedDeviceManager <<");
   514  }
   511  }
   515 
   512 
   516 // -----------------------------------------------------------------------------
   513 // -----------------------------------------------------------------------------
   519 // -----------------------------------------------------------------------------
   516 // -----------------------------------------------------------------------------
   520 //
   517 //
   521 void DMFotaView::FormatList(QString val,QString str)
   518 void DMFotaView::FormatList(QString val,QString str)
   522     {
   519     {
   523     qDebug("DMFotaView::FormatList >>");
   520     qDebug("DMFotaView::FormatList >>");
   524     label = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
   521     mLabel = qobject_cast<HbLabel*> (mLoader.findWidget(mList1[iCount]));
   525     label2 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));         
   522     mLabel2 = qobject_cast<HbLabel*> (mLoader2.findWidget(mList2[iCount++]));         
   526     label3 = qobject_cast<HbLabel*> (loader.findWidget(list1[i]));
   523     mLabel3 = qobject_cast<HbLabel*> (mLoader.findWidget(mList1[iCount]));
   527     label4 = qobject_cast<HbLabel*> (loader2.findWidget(list2[i++]));
   524     mLabel4 = qobject_cast<HbLabel*> (mLoader2.findWidget(mList2[iCount++]));
   528     label->setPlainText(val);
   525     mLabel->setPlainText(val);
   529     label2->setPlainText(val);
   526     mLabel2->setPlainText(val);
   530     label3->setPlainText(str);
   527     mLabel3->setPlainText(str);
   531     label4->setPlainText(str);
   528     mLabel4->setPlainText(str);
   532     label->setVisible(ETrue);
   529     mLabel->setVisible(ETrue);
   533     label2->setVisible(ETrue);
   530     mLabel2->setVisible(ETrue);
   534     label3->setVisible(ETrue);
   531     mLabel3->setVisible(ETrue);
   535     label4->setVisible(ETrue);
   532     mLabel4->setVisible(ETrue);
   536     qDebug("DMFotaView::FormatList <<");
   533     qDebug("DMFotaView::FormatList <<");
   537     }
   534     }
   538 
   535 
   539 
   536 
   540 inline RFotaEngineSession & DMFotaView::FotaEngineL()
   537 inline RFotaEngineSession & DMFotaView::FotaEngineL()
   551 // -----------------------------------------------------------------------------
   548 // -----------------------------------------------------------------------------
   552 //
   549 //
   553 void DMFotaView::backtoMainWindow()
   550 void DMFotaView::backtoMainWindow()
   554     {
   551     {
   555     qDebug("DMFotaView::backtoMainWindow >>");
   552     qDebug("DMFotaView::backtoMainWindow >>");
   556     QString appName = qApp->applicationName();
   553     if(mService)
   557     QString cpAppTitle("Control panel");
   554         {
   558     mMainWindow->removeView(fotaPortraitView);
   555         mService->complete();
   559     mMainWindow->removeView(fotaLandscapeView);
   556         connect(mService, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
   560     fotaPortraitView->deleteLater();
   557         }
   561     fotaLandscapeView->deleteLater();
   558     else
   562     fotaPortraitView = NULL;
   559         {
   563     fotaLandscapeView = NULL;
   560         qApp->quit();
   564     if (appName == cpAppTitle)
   561         }
   565         {
       
   566         TApaTaskList taskList(CEikonEnv::Static()->WsSession());
       
   567         TApaTask task = taskList.FindApp(KControlPanelAppUid);
       
   568         if (task.Exists())
       
   569             {
       
   570             task.BringToForeground();
       
   571             }
       
   572         }
       
   573     qApp->quit();
       
   574     qDebug("DMFotaView::backtoMainWindow <<");
   562     qDebug("DMFotaView::backtoMainWindow <<");
   575     }
   563     }
   576 
   564 
   577 // -----------------------------------------------------------------------------
   565 // -----------------------------------------------------------------------------
   578 // DMFotaView::OnHelp
   566 // DMFotaView::OnHelp
   595 }
   583 }
   596 
   584 
   597 void DMFotaView::readSection( Qt::Orientation orientation )
   585 void DMFotaView::readSection( Qt::Orientation orientation )
   598 {
   586 {
   599     qDebug("DMFotaView::readSection >>");
   587     qDebug("DMFotaView::readSection >>");
   600     if(mMainWindow->currentView() == fotaPortraitView || mMainWindow->currentView() == fotaLandscapeView)
   588     if(mMainWindow->currentView() == mFotaPortraitView || mMainWindow->currentView() == mFotaLandscapeView)
   601         {
   589         {
   602         if( orientation == Qt::Vertical ) {
   590         if( orientation == Qt::Vertical ) {
   603         // reading "portrait" section
   591         // reading "portrait" section
   604         mMainWindow->setCurrentView(fotaPortraitView);
   592         mMainWindow->setCurrentView(mFotaPortraitView);
   605         }
   593         }
   606      else {
   594      else {
   607         // reading "landscape" section
   595         // reading "landscape" section
   608         mMainWindow->setCurrentView(fotaLandscapeView);
   596         mMainWindow->setCurrentView(mFotaLandscapeView);
   609          }
   597          }
   610         }
   598         }
   611     else if(mMainWindow->currentView()==profilesView)
   599     else if(mMainWindow->currentView()==mProfilesView)
   612         {
   600         {
   613         profilesView->reLayout(orientation);
   601         mProfilesView->reLayout(orientation);
   614         }
   602         }
   615     qDebug("DMFotaView::readSection <<");
   603     qDebug("DMFotaView::readSection <<");
   616 
   604 
   617 }   
   605 }   
   618 
   606 
   623     qDebug("DMFotaView::UpdateDMUI >>");
   611     qDebug("DMFotaView::UpdateDMUI >>");
   624 	    QString val;
   612 	    QString val;
   625     if (aVal == 1)
   613     if (aVal == 1)
   626         {
   614         {
   627         qDebug("DMFotaView::aVal == 1 >>");
   615         qDebug("DMFotaView::aVal == 1 >>");
   628         if(Connected)
   616         if(iConnected)
   629             {
   617             {
   630             qDebug("DMFotaView::Connected >>");
   618             qDebug("DMFotaView::Connected >>");
   631             QObject::disconnect(updateButton,0,0,0);
   619             QObject::disconnect(mUpdateButton,0,0,0);
   632             QObject::disconnect(updateButtonLandscape,0,0,0);
   620             QObject::disconnect(mUpdateButtonLandscape,0,0,0);
   633             Connected = EFalse;
   621             iConnected = EFalse;
   634             }
   622             }
   635     
   623     
   636         iFotaState = FotaEngineL().GetState(-1);
   624         iFotaState = FotaEngineL().GetState(-1);
   637 
   625 
   638         if (iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState
   626         if (iFotaState == RFotaEngineSession::EDownloadComplete || iFotaState
   641                 == RFotaEngineSession::EDownloadProgressing)
   629                 == RFotaEngineSession::EDownloadProgressing)
   642             {
   630             {
   643             qDebug("CDeviceUpdateMoniter::Resume >>");
   631             qDebug("CDeviceUpdateMoniter::Resume >>");
   644             QString value = hbTrId("txt_device_update_button_resume_update");
   632             QString value = hbTrId("txt_device_update_button_resume_update");
   645             //updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update");
   633             //updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update");
   646             updateButton->setText(value);
   634             mUpdateButton->setText(value);
   647             QObject::connect(updateButton, SIGNAL(clicked()), this,SLOT(ResumeUpdate()));
   635             QObject::connect(mUpdateButton, SIGNAL(clicked()), this,SLOT(ResumeUpdate()));
   648             //updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update");
   636             //updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update");
   649             updateButtonLandscape->setText(value);
   637             mUpdateButtonLandscape->setText(value);
   650 		QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
   638 		QObject::connect(mUpdateButtonLandscape, SIGNAL(clicked()), this, SLOT(ResumeUpdate()));
   651 		Connected = ETrue;
   639 		iConnected = ETrue;
   652 
   640 
   653 		TBuf8<80> Name;
   641 		TBuf8<80> Name;
   654 		TBuf8<80> Version;
   642 		TBuf8<80> Version;
   655 		TInt Size;
   643 		TInt Size;
   656 
   644 
   678 	            TInt sizeMB = sizeKB / 1024;
   666 	            TInt sizeMB = sizeKB / 1024;
   679 	            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
   667 	            val = hbTrId("txt_device_update_setlabel_the_last_update_1_2_mb").arg(name)
   680         	            .arg(ver).arg(sizeMB);
   668         	            .arg(ver).arg(sizeMB);
   681 	            }
   669 	            }
   682 	        
   670 	        
   683 	        label->setPlainText(val);
   671 	        mLabel->setPlainText(val);
   684 	        label2->setPlainText(val);
   672 	        mLabel2->setPlainText(val);
   685 	    }
   673 	    }
   686         else
   674         else
   687 	    {
   675 	    {
   688         qDebug("DMFotaView::Update >>");
   676         qDebug("DMFotaView::Update >>");
   689         val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
   677         val = hbTrId("txt_device_update_setlabel_to_update_your_device_s");
   690 	    label->setPlainText(val);
   678 	    mLabel->setPlainText(val);
   691 	    label2->setPlainText(val);
   679 	    mLabel2->setPlainText(val);
   692 	    val = hbTrId("txt_device_update_button_update");
   680 	    val = hbTrId("txt_device_update_button_update");
   693 	    updateButton = qobject_cast<HbPushButton*>(loader.findWidget("p:update"));
   681 	    mUpdateButton = qobject_cast<HbPushButton*>(mLoader.findWidget("p:update"));
   694 	    updateButton->setText(val);
   682 	    mUpdateButton->setText(val);
   695 	    QObject::connect(updateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   683 	    QObject::connect(mUpdateButton, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   696 	    updateButtonLandscape = qobject_cast<HbPushButton*>(loader2.findWidget("l:update"));
   684 	    mUpdateButtonLandscape = qobject_cast<HbPushButton*>(mLoader2.findWidget("l:update"));
   697 	    updateButtonLandscape->setText(val);
   685 	    mUpdateButtonLandscape->setText(val);
   698 	    QObject::connect(updateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   686 	    QObject::connect(mUpdateButtonLandscape, SIGNAL(clicked()), this, SLOT(CheckforUpdate()));
   699 	    Connected = ETrue;
   687 	    iConnected = ETrue;
   700 	    }
   688 	    }
   701 	}
   689 	}
   702     fotaSupportEnabled();
   690     fotaSupportEnabled();
   703     if(fotaValue == 1 && aVal == 0)
   691     if(iFotaValue == 1 && aVal == 0)
   704     {
   692     {
   705     	updateButton->setEnabled(aVal);
   693     	mUpdateButton->setEnabled(aVal);
   706       updateButtonLandscape->setEnabled(aVal);
   694     	mUpdateButtonLandscape->setEnabled(aVal);
   707     }
   695     }
   708     advancedButton->setEnabled(aVal);
   696     mAdvancedButton->setEnabled(aVal);
   709     advancedButtonLandscape->setEnabled(aVal);
   697     mAdvancedButtonLandscape->setEnabled(aVal);
   710     qDebug("DMFotaView::UpdateDMUI <<");
   698     qDebug("DMFotaView::UpdateDMUI <<");
   711     qDebug("DMFotaView::UpdateDMUI <<");
   699     qDebug("DMFotaView::UpdateDMUI <<");
   712 }
   700 }
   713 
   701 
   714 void DMFotaView::fotaSupportEnabled()
   702 void DMFotaView::fotaSupportEnabled()
   715     { 
   703     { 
   716     fotaValue = 1;	
   704     iFotaValue = 1;	
   717     CRepository* centrep( NULL);
   705     CRepository* centrep( NULL);
   718     TUid uidValue = {0x101F9A08}; // KCRFotaAdapterEnabled
   706     TUid uidValue = {0x101F9A08}; // KCRFotaAdapterEnabled
   719     TInt err = KErrNone;
   707     TInt err = KErrNone;
   720     TRAP(err,centrep = CRepository::NewL( uidValue)); 
   708     TRAP(err,centrep = CRepository::NewL( uidValue)); 
   721     if(centrep && err == KErrNone )
   709     if(centrep && err == KErrNone )
   722     {  
   710     {  
   723         centrep->Get( 1 , fotaValue ); // KCRFotaAdapterEnabled     
   711         centrep->Get( 1 , iFotaValue ); // KCRFotaAdapterEnabled     
   724         delete centrep;
   712         delete centrep;
   725     }
   713     }
   726     if(fotaValue == 0 || fotaValue == 1)
   714     if(iFotaValue == 0 || iFotaValue == 1)
   727         {
   715         {
   728         updateButton->setEnabled(fotaValue);
   716         mUpdateButton->setEnabled(iFotaValue);
   729         updateButtonLandscape->setEnabled(fotaValue);
   717         mUpdateButtonLandscape->setEnabled(iFotaValue);
   730         }
   718         }
   731     }
   719     }
   732     
   720     
   733 
   721