appinstaller/AppinstUi/sisxsilentinstallindicatorplugin/src/sisxsilentinstallindicator.cpp
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     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:
       
    15  *
       
    16  */
       
    17 
       
    18 #include <w32std.h>
       
    19 #include <apgtask.h>
       
    20 #include <apacmdln.h>
       
    21 #include <xqservicerequest.h>
       
    22 #include <hb/hbcore/hbtranslator.h>
       
    23 #include <hbicon.h>
       
    24 #include "sisxsilentinstallindicator.h" 
       
    25 
       
    26 const char KSifUiDefaultApplicationIcon[] = "qtg_large_application.svg";
       
    27 
       
    28 // ----------------------------------------------------------------------------
       
    29 // SisxSilentInstallIndicator::SisxSilentInstallIndicator
       
    30 // @see sisxsilentinstallindicator.h
       
    31 // ----------------------------------------------------------------------------
       
    32 SisxSilentInstallIndicator::SisxSilentInstallIndicator( 
       
    33 	const QString &indicatorType) :
       
    34     	HbIndicatorInterface( indicatorType,    				
       
    35     		HbIndicatorInterface::NotificationCategory,
       
    36     		InteractionActivated),
       
    37     	mUpdateValue(0),
       
    38     	mIsInstallProcess(1) // Set installer mode as default.
       
    39     {
       
    40     }
       
    41 
       
    42 // ----------------------------------------------------------------------------
       
    43 // SisxSilentInstallIndicator::~SisxSilentInstallIndicator
       
    44 // @see sisxsilentinstallindicator.h
       
    45 // ----------------------------------------------------------------------------
       
    46 SisxSilentInstallIndicator::~SisxSilentInstallIndicator()
       
    47     {
       
    48     }
       
    49 
       
    50 // ----------------------------------------------------------------------------
       
    51 // SisxSilentInstallIndicator::handleInteraction
       
    52 // @see sisxsilentinstallindicator.h
       
    53 // ----------------------------------------------------------------------------
       
    54 bool SisxSilentInstallIndicator::handleInteraction(InteractionType type)
       
    55     {
       
    56     bool handled = false;
       
    57     
       
    58     if (type == InteractionActivated) 
       
    59         {       
       
    60         handled = true;           
       
    61         emit deactivate(); 
       
    62         }
       
    63     
       
    64     return handled;
       
    65     }
       
    66 
       
    67 // ----------------------------------------------------------------------------
       
    68 // SisxSilentInstallIndicator::indicatorData
       
    69 // @see sisxsilentinstallindicator.h
       
    70 // ----------------------------------------------------------------------------
       
    71 QVariant SisxSilentInstallIndicator::indicatorData(int role) const
       
    72 {       
       
    73 switch(role)
       
    74     {
       
    75     case PrimaryTextRole: 
       
    76         {
       
    77         // Set text to first line of indicator.
       
    78         QString text("");
       
    79         // Check which mode is on.
       
    80         if ( mIsInstallProcess  )
       
    81             { 
       
    82             text.append(QString("Installing"));            
       
    83             }       
       
    84         else
       
    85             {
       
    86             text.append(QString("Finalizing installations"));            
       
    87             }     
       
    88         return text;        
       
    89         }
       
    90     case SecondaryTextRole:
       
    91         {
       
    92         // Set text to second line of indicator.
       
    93         QString text("");        
       
    94         text.append(QString("%1 %").arg(mUpdateValue));      
       
    95         return text; 
       
    96         }    
       
    97     case DecorationNameRole:
       
    98     case MonoDecorationNameRole:
       
    99         {
       
   100         // Get icon for the indicator.
       
   101         QString iconName(KSifUiDefaultApplicationIcon);
       
   102         return iconName;
       
   103         }
       
   104     default: 
       
   105         return QVariant();      
       
   106     }
       
   107 }
       
   108 
       
   109 // ----------------------------------------------------------------------------
       
   110 // SisxSilentInstallIndicator::prepareDisplayName
       
   111 // @see sisxsilentinstallindicator.h
       
   112 // ----------------------------------------------------------------------------
       
   113 bool SisxSilentInstallIndicator::handleClientRequest( RequestType type, 
       
   114                                                       const QVariant &parameter)
       
   115     {
       
   116     bool handled(false);
       
   117     
       
   118     switch (type) 
       
   119         {
       
   120         case RequestActivate:
       
   121             {
       
   122             // Read client percent value to float.
       
   123             mUpdateValue = parameter.toInt();
       
   124             
       
   125             // If client send -1 insted of percent value (0-100) we need
       
   126             // to switch to uninstaller mode.
       
   127             if (mUpdateValue == -1)
       
   128                 {
       
   129                 mIsInstallProcess = false;
       
   130                 mUpdateValue = 0;
       
   131                 }           
       
   132             emit dataChanged();
       
   133             handled =  true;
       
   134             }
       
   135             break;
       
   136         case RequestDeactivate:
       
   137             {
       
   138             emit deactivate();
       
   139             }
       
   140             break;
       
   141         default:
       
   142             break;
       
   143         }
       
   144 
       
   145     return handled;
       
   146     }
       
   147 
       
   148 // EOF