connectionmonitoring/cellularindicatorplugin/src/cellularindicatorplugin.cpp
branchGCC_SURGE
changeset 49 faa5ef4f80da
parent 47 cb7afde124a3
child 44 a0c4ceac30d0
equal deleted inserted replaced
39:f10336de0cd6 49:faa5ef4f80da
    14  * Description:
    14  * Description:
    15  * 
    15  * 
    16  */
    16  */
    17 
    17 
    18 #include <QtPlugin>
    18 #include <QtPlugin>
    19 #include <QTranslator>
    19 #include <HbTranslator>
    20 #include <QLocale>
    20 #include <QLocale>
    21 #include <QList>
    21 #include <QList>
    22 #include <HbLabel>
    22 #include <HbLabel>
    23 #include <HbDialog>
    23 #include <HbDialog>
    24 #include <HbDocumentLoader>
    24 #include <HbDocumentLoader>
    92     OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_CREATEINDICATOR_ENTRY );
    92     OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_CREATEINDICATOR_ENTRY );
    93     
    93     
    94     Q_UNUSED(indicatorType)
    94     Q_UNUSED(indicatorType)
    95     
    95     
    96     // Install localization
    96     // Install localization
    97     QTranslator *translator = new QTranslator(this);
    97     HbTranslator *translator(new HbTranslator("cellularindicatorplugin"));
    98 
       
    99     QString lang = QLocale::system().name(); 
       
   100     QString path = "Z:/resource/qt/translations/"; 
       
   101     translator->load("cellularindicatorplugin_" + lang, path);
       
   102     qApp->installTranslator(translator);
       
   103     
    98     
   104     OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_CREATEINDICATOR_EXIT );
    99     OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_CREATEINDICATOR_EXIT );
   105     return this;
   100     return this;
   106 }
   101 }
   107 
   102 
   154 {
   149 {
   155     OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_HANDLEINTERACTION_ENTRY );
   150     OstTraceFunctionEntry0( CELLULARINDICATORPLUGIN_HANDLEINTERACTION_ENTRY );
   156     
   151     
   157     Q_UNUSED(type)
   152     Q_UNUSED(type)
   158     bool handled = false;
   153     bool handled = false;
       
   154     QVariantMap data;
   159     
   155     
   160     switch(type) {
   156     switch(type) {
   161     case InteractionActivated:
   157     case InteractionActivated:
   162         //connect error() to slot processError() to get error, 
   158         // Emit a signal that will inform the client to start the connectionview client
   163         QObject::connect( &process, SIGNAL(error(QProcess::ProcessError)),                       
   159         emit userActivated(data);
   164                           this, SLOT(processError(QProcess::ProcessError)));
   160 
   165 
       
   166         // Show connection view
       
   167         process.start("connview");
       
   168         handled = true;
   161         handled = true;
   169         break;
   162         break;
   170     
   163     
   171     default:
   164     default:
   172         break;
   165         break;
   207                 ret = str.arg(indicatorInfo[0].toInt());
   200                 ret = str.arg(indicatorInfo[0].toInt());
   208             }
   201             }
   209             else if ( indicatorInfo[0].toInt() && (indicatorInfo.count() >= 2)) {
   202             else if ( indicatorInfo[0].toInt() && (indicatorInfo.count() >= 2)) {
   210                 
   203                 
   211                 // Only one connection -> show name of the iap
   204                 // Only one connection -> show name of the iap
   212                 QString iapName;
   205                 ret = indicatorInfo[1].toString();
   213                 iapName = indicatorInfo[1].toString();
       
   214                 QString str = QString(hbTrId("txt_occ_dblist_cellular_data_val_1_connected"));
       
   215                 ret = str.arg(iapName);
       
   216             }
   206             }
   217         }
   207         }
   218         break;
   208         break;
   219 
   209 
   220     case DecorationNameRole:
   210     case DecorationNameRole:
   221         // Return the icon
   211         // Return the icon
   222         ret = HbIcon("qtg_small_gprs");
   212         ret = QString("qtg_small_gprs");
   223         break;
   213         break;
   224     
   214     
   225     default:
   215     default:
   226         // Do nothing
   216         // Do nothing
   227         break;
   217         break;
   229     
   219     
   230     OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_INDICATORDATA_EXIT );
   220     OstTraceFunctionExit0( CELLULARINDICATORPLUGIN_INDICATORDATA_EXIT );
   231     return ret;
   221     return ret;
   232 }
   222 }
   233 
   223 
   234 /*!
       
   235     The processError is a handler for error codes.
       
   236 */
       
   237 void CellularIndicatorPlugin::processError(QProcess::ProcessError err)
       
   238     {
       
   239     OstTraceFunctionEntry1(CELLULARINDICATORPLUGIN_PROCESSERROR_ENTRY, this);
       
   240   
       
   241     switch (err) {   
       
   242         case QProcess::FailedToStart: 
       
   243         case QProcess::Crashed: 
       
   244         case QProcess::Timedout: 
       
   245         case QProcess::ReadError: 
       
   246         case QProcess::WriteError: 
       
   247         case QProcess::UnknownError:
       
   248             OstTrace1( CELLULARINDICATORPLUGIN_ERR,PROCESSERROR_KNOWN,"Process Error %u", err);
       
   249             break;  
       
   250         default:
       
   251         OstTrace1( CELLULARINDICATORPLUGIN_ERR,PROCESSERROR_UNKNOWN,"Unknown Process Error %u", err);
       
   252             break;
       
   253         }
       
   254     OstTraceFunctionExit1(CELLULARINDICATORPLUGIN_PROCESSERROR_EXIT, this);
       
   255     }
       
   256