appinstaller/AppinstUi/startuplistupdater/tsrc/testslulauncher/testslulauncher.cpp
branchRCL_3
changeset 66 8b7f4e561641
parent 65 7333d7932ef7
child 70 e8965914fac7
equal deleted inserted replaced
65:7333d7932ef7 66:8b7f4e561641
     1 /*
       
     2 * Copyright (c) 2010 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:  Test startup list update launcher application
       
    15 *
       
    16 */
       
    17 
       
    18 #include "testslulauncher.h"
       
    19 #include <hbmainwindow.h>
       
    20 #include <hbview.h>
       
    21 #include <hbpushbutton.h>
       
    22 #include <hblabel.h>
       
    23 #include <hbmessagebox.h>
       
    24 #include <QGraphicsLinearLayout>
       
    25 #ifdef Q_OS_SYMBIAN
       
    26 #include <e32std.h>
       
    27 #endif  // Q_OS_SYMBIAN
       
    28 
       
    29 
       
    30 // ======== LOCAL FUNCTIONS ========
       
    31 
       
    32 #ifdef Q_OS_SYMBIAN
       
    33 _LIT( KStartupListUpdater, "z:\\sys\\bin\\startuplistupdater.exe" );
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // DoLaunchStartupListUpdater()
       
    37 // ---------------------------------------------------------------------------
       
    38 //
       
    39 TInt DoLaunchStartupListUpdater()
       
    40 {
       
    41     RProcess process;
       
    42     TInt result = process.Create( KStartupListUpdater, KNullDesC );
       
    43 
       
    44     if (result == KErrNone) {
       
    45         TRequestStatus rendezvousStatus;
       
    46         process.Rendezvous(rendezvousStatus);
       
    47 
       
    48         // start process and wait until it is started
       
    49         process.Resume();
       
    50         User::WaitForRequest(rendezvousStatus);
       
    51 
       
    52         if (rendezvousStatus.Int() == KErrNone) {
       
    53             TRequestStatus logonStatus;
       
    54             process.Logon(logonStatus);
       
    55 
       
    56             // waits until process is finished
       
    57             User::WaitForRequest(logonStatus);
       
    58 
       
    59             result = logonStatus.Int();
       
    60         } else {
       
    61             result = rendezvousStatus.Int();
       
    62         }
       
    63 
       
    64         process.Close();
       
    65     }
       
    66 
       
    67     return result;
       
    68 }
       
    69 #endif  // Q_OS_SYMBIAN
       
    70 
       
    71 
       
    72 // ======== MEMBER FUNCTIONS ========
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // TestStartupListUpdateLauncher::TestStartupListUpdateLauncher
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 TestStartupListUpdateLauncher::TestStartupListUpdateLauncher(int& argc, char* argv[])
       
    79         : HbApplication(argc, argv), mMainWindow(0), mMainView(0)
       
    80 {
       
    81     mMainWindow = new HbMainWindow();
       
    82     mMainView = new HbView();
       
    83     mMainView->setTitle(tr("Test SLU Launcher"));
       
    84 
       
    85     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
       
    86 
       
    87     HbPushButton *updateStartupList = new HbPushButton(tr("Update Startup List"));
       
    88     layout->addItem(updateStartupList);
       
    89     connect(updateStartupList, SIGNAL(clicked()), this, SLOT(updateStartupList()));
       
    90 
       
    91     HbPushButton *exitApp = new HbPushButton(tr("Exit"));
       
    92     layout->addItem(exitApp);
       
    93     connect(exitApp, SIGNAL(clicked()), this, SLOT(closeApp()));
       
    94 
       
    95     mMainView->setLayout(layout);
       
    96     mMainWindow->addView(mMainView);
       
    97     mMainWindow->show();
       
    98 }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // TestStartupListUpdateLauncher::~TestStartupListUpdateLauncher
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 TestStartupListUpdateLauncher::~TestStartupListUpdateLauncher()
       
   105 {
       
   106     delete mMainView;
       
   107     delete mMainWindow;
       
   108 }
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // TestStartupListUpdateLauncher::updateStartupList()
       
   112 // ---------------------------------------------------------------------------
       
   113 //
       
   114 void TestStartupListUpdateLauncher::updateStartupList()
       
   115 {
       
   116 #ifdef Q_OS_SYMBIAN
       
   117     int err = DoLaunchStartupListUpdater();
       
   118     if( !err ) {
       
   119         HbMessageBox::information(tr("Ok"));
       
   120     } else {
       
   121         HbMessageBox::information(tr("Error %L1").arg(err));
       
   122     }
       
   123 #endif  // Q_OS_SYMBIAN
       
   124 }
       
   125 
       
   126 // ---------------------------------------------------------------------------
       
   127 // TestStartupListUpdateLauncher::closeApp()
       
   128 // ---------------------------------------------------------------------------
       
   129 //
       
   130 void TestStartupListUpdateLauncher::closeApp()
       
   131 {
       
   132     qApp->exit();
       
   133 }
       
   134