coreapplicationuis/powersaveutilities/psmindicatorplugin/src/psmindicator.cpp
changeset 77 b01c07dfcf84
parent 51 50b444048a8d
child 81 676b6116ca93
equal deleted inserted replaced
74:1505405bc645 77:b01c07dfcf84
    24 #include <hbapplication.h>
    24 #include <hbapplication.h>
    25 #include <hbmainwindow.h>
    25 #include <hbmainwindow.h>
    26 #include <hbaction.h>
    26 #include <hbaction.h>
    27 #include <cpbasesettingview.h>
    27 #include <cpbasesettingview.h>
    28 #include <e32debug.h>
    28 #include <e32debug.h>
       
    29 #include <hbmessagebox.h>
       
    30 #include <xqaiwrequest.h>
       
    31 #include <XQServiceRequest.h>
       
    32 #include <QTimer>
    29 
    33 
    30 
    34 
    31 Q_EXPORT_PLUGIN(PsmIndicatorPlugin)
    35 Q_EXPORT_PLUGIN(PsmIndicatorPlugin)
    32 const static char IndicatorType[] = "com.nokia.hb.powersavemodeplugin/1.0";
    36 const static char IndicatorType[] = "com.nokia.hb.powersavemodeplugin/1.0";
    33 QString KPsm = "PSM";
    37 QString KPsm = "PSM";
    34 QString KCharging = "Charging";
    38 QString KCharging = "Charging";
    35 
    39 
    36 PsmIndicatorPlugin::PsmIndicatorPlugin():HbIndicatorInterface(IndicatorType,HbIndicatorInterface::NotificationCategory,InteractionActivated)
    40 PsmIndicatorPlugin::PsmIndicatorPlugin():HbIndicatorInterface(IndicatorType,HbIndicatorInterface::NotificationCategory,InteractionActivated),mRequest(NULL)
    37     {
    41     {
    38     RDebug::Print( _L("PsmIndicatorPlugin constructor begin  ") );  
    42     RDebug::Print( _L("PsmIndicatorPlugin constructor begin  ") );  
    39     iIndicatorTypes << "com.nokia.hb.powersavemodeplugin/1.0";
    43     iIndicatorTypes << "com.nokia.hb.powersavemodeplugin/1.0";
    40     RDebug::Print( _L("PsmIndicatorPlugin constructor end  ")  ); 
    44     RDebug::Print( _L("PsmIndicatorPlugin constructor end  ")  ); 
    41     }
    45     }
   105     {
   109     {
   106     bool handled = false;
   110     bool handled = false;
   107     RDebug::Print( _L("PsmIndicatorPlugin handleinteraction begin  ")); 
   111     RDebug::Print( _L("PsmIndicatorPlugin handleinteraction begin  ")); 
   108     if (type == InteractionActivated) 
   112     if (type == InteractionActivated) 
   109         {
   113         {
   110          RDebug::Print( _L("PsmIndicatorPlugin handleinteraction inside interactionactivated  ") );	
   114          RDebug::Print( _L("PsmIndicatorPlugin handleinteractiontype  interactionactivated  ") );	
   111          QObject::connect( &iProcess, SIGNAL(error(QProcess::ProcessError)),                       
   115        //Qthighway methodology      
   112                                           this, SLOT(processError(QProcess::ProcessError)));
   116        if (mRequest)
   113                                           
   117        	{
   114          // Launch the process to show the view.
   118         delete mRequest;
   115          iProcess.start("CpPsmPluginLauncher");
   119         mRequest = NULL;
   116          handled = true;
   120         }
       
   121     
       
   122         mRequest = mAppMgr.create("com.nokia.symbian.ICpPluginLauncher", "launchSettingView(QString,QVariant)", false);
       
   123 
       
   124        if (!mRequest)
       
   125        {
       
   126         return handled;
       
   127        }
       
   128        
       
   129 
       
   130 
       
   131        // Set arguments for request 
       
   132        QList<QVariant> args;
       
   133        args << QVariant( "cppsmplugin.dll" );
       
   134        args << QVariant ( "psm_view" );
       
   135        mRequest->setArguments(args);
       
   136 
       
   137        mRequest->setSynchronous(false);
       
   138     
       
   139        QTimer::singleShot(20* 1000, this, SLOT(closeSettingView()));
       
   140     
       
   141        // Make the request
       
   142        if (!mRequest->send())
       
   143        {
       
   144         //report error  
       
   145         RDebug::Print( _L("PsmIndicatorPlugin handleinteraction error launching the psmview  "));    
       
   146        }
       
   147         
       
   148         
       
   149        handled = true;
   117                         
   150                         
   118         }   
   151        }   
   119     RDebug::Print( _L("PsmIndicatorPlugin handleinteraction end  ") );         
   152     RDebug::Print( _L("PsmIndicatorPlugin handleinteraction end  ") );         
   120     return handled;
   153     return handled;
   121     }
   154     }
   122 
   155 
   123 // ----------------------------------------------------------------------------
   156 // ----------------------------------------------------------------------------
   170                }
   203                }
   171             //else it's a charging indicator then prepare the string and icon accordingly
   204             //else it's a charging indicator then prepare the string and icon accordingly
   172             else
   205             else
   173               {
   206               {
   174             RDebug::Print( _L("PsmIndicatorPlugin handleclientrequest requestactivate charging  ") );   	  	
   207             RDebug::Print( _L("PsmIndicatorPlugin handleclientrequest requestactivate charging  ") );   	  	
   175             iDisplayName.append(hbTrId("txt_power_management_dblist_charging"));
   208             iDisplayName.append(hbTrId("txt_powermgt_dblist_charging"));
   176             iIcon.append(QString("qtg_mono_flash_charging"));
   209             iIcon.append(QString("qtg_mono_flash_charging"));
   177                }
   210                }
   178 
   211 
   179             
   212             
   180             emit dataChanged();
   213             emit dataChanged();
   197     RDebug::Print( _L("PsmIndicatorPlugin handleclientrequest end  ") );
   230     RDebug::Print( _L("PsmIndicatorPlugin handleclientrequest end  ") );
   198     return handled;
   231     return handled;
   199     }
   232     }
   200 
   233 
   201 
   234 
   202 // ----------------------------------------------------------------------------
   235 void PsmIndicatorPlugin::closeSettingView()
   203 // psmIndicator::processError
   236 {   
   204 // handle the error conditions returned by the QProcess.
   237     if (mRequest) {
   205 // ----------------------------------------------------------------------------
   238         delete mRequest;
   206 
   239         mRequest = NULL;
   207 void PsmIndicatorPlugin::processError(QProcess::ProcessError err)
   240     }
   208     {
   241 }
   209     RDebug::Print( _L("PsmIndicatorPlugin processerror begin  "));   		
       
   210     switch (err)
       
   211         {   
       
   212         case QProcess::FailedToStart: 
       
   213         case QProcess::Crashed: 
       
   214         case QProcess::Timedout: 
       
   215         case QProcess::ReadError: 
       
   216         case QProcess::WriteError: 
       
   217         case QProcess::UnknownError:
       
   218              break;  
       
   219         default:
       
   220             break;
       
   221         }
       
   222     }
       
   223 
       
   224