iaupdate/IAD/bgcindicatorplugin/src/bgcindicator.cpp
changeset 33 8110bf1194d1
parent 29 26b6f0522fd8
child 42 d17dc5398051
equal deleted inserted replaced
29:26b6f0522fd8 33:8110bf1194d1
    18 #include <w32std.h>
    18 #include <w32std.h>
    19 #include <apgtask.h>
    19 #include <apgtask.h>
    20 #include <apacmdln.h>
    20 #include <apacmdln.h>
    21 #include <xqservicerequest.h>
    21 #include <xqservicerequest.h>
    22 
    22 
    23 // #include "debugtraces.h"
    23 #include <hb/hbcore/hbtranslator.h>
       
    24 
       
    25 #include <hbicon.h>
       
    26 
    24 #include "bgcindicator.h" 
    27 #include "bgcindicator.h" 
    25 
    28 
    26 //----------------------------------------------------------------------
    29 //----------------------------------------------------------------------
    27 
    30 
    28 
    31 
    30 // BgcIndicator::BgcIndicator
    33 // BgcIndicator::BgcIndicator
    31 // @see bgcindicator.h
    34 // @see bgcindicator.h
    32 // ----------------------------------------------------------------------------
    35 // ----------------------------------------------------------------------------
    33 BgcIndicator::BgcIndicator(const QString &indicatorType) :
    36 BgcIndicator::BgcIndicator(const QString &indicatorType) :
    34 HbIndicatorInterface(indicatorType,
    37 HbIndicatorInterface(indicatorType,
    35         HbIndicatorInterface::GroupPriorityHigh,
    38         HbIndicatorInterface::NotificationCategory,
    36         InteractionActivated),
    39         InteractionActivated), 
    37         mNrOfUpdates(0)
    40         mNrOfUpdates(0)
    38     {
    41     {
    39     }
    42     }
    40 
    43 
    41 // ----------------------------------------------------------------------------
    44 // ----------------------------------------------------------------------------
    54     {
    57     {
    55     bool handled = false;
    58     bool handled = false;
    56     
    59     
    57     if (type == InteractionActivated) 
    60     if (type == InteractionActivated) 
    58         {
    61         {
    59         StartIaupdateL();
    62         TRAPD( err, StartIaupdateL() );
       
    63         if ( err != KErrNone )
       
    64             {
       
    65             // nothing to do 
       
    66             }
    60         handled = true;   
    67         handled = true;   
    61         
    68         
    62         emit deactivate(); 
    69         emit deactivate(); 
    63         }
    70         }
    64     return handled;
    71     return handled;
    68 // BgcIndicator::indicatorData
    75 // BgcIndicator::indicatorData
    69 // @see bgcindicator.h
    76 // @see bgcindicator.h
    70 // ----------------------------------------------------------------------------
    77 // ----------------------------------------------------------------------------
    71 QVariant BgcIndicator::indicatorData(int role) const
    78 QVariant BgcIndicator::indicatorData(int role) const
    72 {
    79 {
    73     
    80     // use iaupdate's translate file
       
    81     // loc: HbTranslator trans("z:\\resource\\iaupdate\\","Text_Map_Swupdate_");
       
    82         
    74 switch(role)
    83 switch(role)
    75     {
    84     {
    76     case TextRole: 
    85     case PrimaryTextRole: 
    77         {
    86         {
    78         QString text("");
    87         QString text("");
    79         if ( mNrOfUpdates > 0 )
    88         if ( mNrOfUpdates == 0 )
       
    89             {
       
    90             // First time case
       
    91             // loc: text.append(hbTrId("txt_software_update_list_software_update"));
       
    92             text.append(QString("Check for updates?"));
       
    93             }
       
    94         else if ( mNrOfUpdates == 1 )
       
    95             {
       
    96             // one update available
       
    97             // loc: text.append(hbTrId("txt_software_dblist_update_available"));
       
    98             text.append(QString("Update available"));
       
    99             }
       
   100         else
       
   101             {
       
   102             // several updates available
       
   103             // loc: text.append(hbTrId("txt_software_dblist_updates_available"));
    80             text.append(QString("Updates available"));
   104             text.append(QString("Updates available"));
       
   105             }
       
   106         return text;        
       
   107         }
       
   108     case SecondaryTextRole:
       
   109         {
       
   110         QString text("");
       
   111         if ( mNrOfUpdates == 0 )
       
   112             {
       
   113             // First time case
       
   114             // loc: QString text(hbTrId("txt_software_update_list_software_update"));
       
   115             text.append(QString("Tap to view"));
       
   116             }
       
   117         else if ( mNrOfUpdates == 1 )
       
   118             {
       
   119             // one update available
       
   120             // loc: QString text(hbTrId("txt_software_dblist_val_1_new"));
       
   121             text.append(QString("%1 new").arg(mNrOfUpdates));
       
   122             }
    81         else
   123         else
    82             text.append(QString("Check for updates?"));
   124             {
    83         return text;        
   125             // several updates available
    84         }
   126             // loc: QString text(hbTrId("txt_software_dblist_val_ln_new"));
    85     case SecondaryTextRole:
   127             text.append(QString("%1 new").arg(mNrOfUpdates));
    86         {
   128             }
    87         QString text("Tap to view");
       
    88         return text; 
   129         return text; 
    89         }
   130         }
    90     case IconNameRole:
   131     case DecorationNameRole:
       
   132     case MonoDecorationNameRole:
    91         {
   133         {
    92         // QString iconName("z:/resource/messaging/message.svg");
   134         // QString iconName("z:/resource/messaging/message.svg");
    93         QString iconName("c:/qgn_note_swupdate_notification.svg");
   135         // HbIcon iconName1 ("c:/qgn_note_swupdate_notification.svg");
       
   136         QString iconName("z:/resource/iaupdate/qgn_note_swupdate_notification.svg");
    94         return iconName;
   137         return iconName;
    95         }
   138         }
    96     default: 
   139     default: 
    97         return QVariant();      
   140         return QVariant();      
    98     }
   141     }
   108     bool handled(false);
   151     bool handled(false);
   109     switch (type) {
   152     switch (type) {
   110         case RequestActivate:
   153         case RequestActivate:
   111             {
   154             {
   112             mNrOfUpdates = parameter.toInt();
   155             mNrOfUpdates = parameter.toInt();
       
   156             emit dataChanged();
   113             handled =  true;
   157             handled =  true;
   114             }
   158             }
   115             break;
   159             break;
   116         case RequestDeactivate:
   160         case RequestDeactivate:
   117             {
   161             {
   124 
   168 
   125     return handled;
   169     return handled;
   126     }
   170     }
   127 
   171 
   128 // ----------------------------------------------------------
   172 // ----------------------------------------------------------
   129 // CIAUpdateBGTimer::StartIaupdateL()
   173 // BgcIndicator::StartIaupdateL()
   130 // ----------------------------------------------------------
   174 // ----------------------------------------------------------
   131 void BgcIndicator::StartIaupdateL() const
   175 void BgcIndicator::StartIaupdateL() const
   132     {
   176     {
   133     
   177     
   134     const TUint KIADUpdateLauncherUid( 0x2001FE2F );
   178     const TUint KIADUpdateLauncherUid( 0x2001FE2F );
   135     _LIT(KIAUpdateLauncherExe, "iaupdatelauncher.exe" );
   179     _LIT(KIAUpdateLauncherExe, "iaupdatelauncher.exe" );
   136     _LIT8( KRefreshFromNetworkDenied, "1" );
   180     _LIT8( KRefreshFromNetworkDenied, "1" );
   137     
   181     
   138     //FLOG("[bgchecker] StartIaupdateL() begin");
       
   139     RWsSession ws;   
   182     RWsSession ws;   
   140     User::LeaveIfError( ws.Connect() == KErrNone );
   183     User::LeaveIfError( ws.Connect() == KErrNone );
   141     TApaTaskList tasklist(ws);   
   184     TApaTaskList tasklist(ws);   
   142     TApaTask task = tasklist.FindApp( TUid::Uid( KIADUpdateLauncherUid ) );
   185     TApaTask task = tasklist.FindApp( TUid::Uid( KIADUpdateLauncherUid ) );
   143     if ( task.Exists() )
   186     if ( task.Exists() )
   144         {
   187         {
   145         //FLOG("[bgchecker] StartIaupdateL() IAD launcher process found");
       
   146         task.BringToForeground();
   188         task.BringToForeground();
   147         //FLOG("[bgchecker] StartIaupdateL() after task.BringToForeground()");
       
   148         ws.Close();
   189         ws.Close();
   149         }
   190         }
   150     else 
   191     else 
   151         {
   192         {
   152         ws.Close();
   193         ws.Close();
   163         CleanupStack::PopAndDestroy( commandLine );
   204         CleanupStack::PopAndDestroy( commandLine );
   164        
   205        
   165         process.Resume();
   206         process.Resume();
   166         CleanupStack::PopAndDestroy( &process );    
   207         CleanupStack::PopAndDestroy( &process );    
   167         }
   208         }
   168     //FLOG("[bgchecker] StartIaupdateL() end");
   209     }
   169     }
   210 
   170