ipsservices/ipssosaoplugin/src/IpsSosAOSettingsHandler.cpp
changeset 43 99bcbff212ad
parent 23 2dc6caa42ec3
child 57 ae34e1715e21
equal deleted inserted replaced
42:139d4b7b2938 43:99bcbff212ad
   153     IpsServices::TIpsSetDataAoStates ret = IpsServices::EMailAoOff;
   153     IpsServices::TIpsSetDataAoStates ret = IpsServices::EMailAoOff;
   154     
   154     
   155     QVariant state;
   155     QVariant state;
   156     TBool ok = GetSettingValue(IpsServices::ReceptionActiveProfile, state);
   156     TBool ok = GetSettingValue(IpsServices::ReceptionActiveProfile, state);
   157     
   157     
   158     if(ok ){
   158     if( ok )
   159         prof = state.toInt();
   159         {
   160         
   160         prof = state.toInt();        
   161         ret = ProfileIntoAOState(prof);
   161         ret = ProfileIntoAOState(prof);
   162         }   
   162         }   
   163     
   163     
   164     return ret;
   164     return ret;
   165     }
   165     }
   168 // ----------------------------------------------------------------------------
   168 // ----------------------------------------------------------------------------
   169 void CIpsSosAOSettingsHandler::SetAlwaysOnlineState(
   169 void CIpsSosAOSettingsHandler::SetAlwaysOnlineState(
   170     const IpsServices::TIpsSetDataAoStates aAlwaysOnlineState )
   170     const IpsServices::TIpsSetDataAoStates aAlwaysOnlineState )
   171     {
   171     {
   172     //we're allowed to switch ourselves off, not on.
   172     //we're allowed to switch ourselves off, not on.
   173     if ( aAlwaysOnlineState == IpsServices::EMailAoOff ){
   173     if ( aAlwaysOnlineState == IpsServices::EMailAoOff )
       
   174         {
   174         if(!SetSettingValue(
   175         if(!SetSettingValue(
   175                 IpsServices::ReceptionActiveProfile, 
   176                 IpsServices::ReceptionActiveProfile, 
   176                 IpsServices::EmailSyncProfileManualFetch)){
   177                 IpsServices::EmailSyncProfileManualFetch))
       
   178             {
   177         
   179         
   178             CreateKeyValuePair(
   180             CreateKeyValuePair(
   179                     IpsServices::ReceptionActiveProfile, 
   181                     IpsServices::ReceptionActiveProfile, 
   180                     IpsServices::EmailSyncProfileManualFetch);
   182                     IpsServices::EmailSyncProfileManualFetch);
   181             }
   183             }
   192 
   194 
   193     /* Not supported yet
   195     /* Not supported yet
   194     QVariant state = NULL;
   196     QVariant state = NULL;
   195     TBool ok = GetSettingValue(IpsServices::EmailNotificationState, state);
   197     TBool ok = GetSettingValue(IpsServices::EmailNotificationState, state);
   196         
   198         
   197     if(ok){
   199     if(ok)
       
   200         {
   198         ret = static_cast<IpsServices::TIpsSetDataEmnStates>(state.toInt());
   201         ret = static_cast<IpsServices::TIpsSetDataEmnStates>(state.toInt());
   199         }
   202         }
   200     */
   203     */
   201         
   204         
   202     return ret;
   205     return ret;
   206 // ----------------------------------------------------------------------------
   209 // ----------------------------------------------------------------------------
   207 void CIpsSosAOSettingsHandler::SetEmailNotificationState(
   210 void CIpsSosAOSettingsHandler::SetEmailNotificationState(
   208     const IpsServices::TIpsSetDataEmnStates /*aEmnState*/ )
   211     const IpsServices::TIpsSetDataEmnStates /*aEmnState*/ )
   209     {
   212     {
   210     /* Not supported yet
   213     /* Not supported yet
   211     if(!SetSettingValue(IpsServices::EmailNotificationState, aEmnState)){
   214     if(!SetSettingValue(IpsServices::EmailNotificationState, aEmnState))
       
   215         {
   212         CreateKeyValuePair(IpsServices::EmailNotificationState, aEmnState);
   216         CreateKeyValuePair(IpsServices::EmailNotificationState, aEmnState);
   213         }
   217         }
   214     */
   218     */
   215     }
   219     }
   216     
   220     
   222     
   226     
   223     /* Not supported yet
   227     /* Not supported yet
   224     QVariant state = NULL;
   228     QVariant state = NULL;
   225     TBool ok = GetSettingValue(IpsServices::FirstEmnReceived, state);
   229     TBool ok = GetSettingValue(IpsServices::FirstEmnReceived, state);
   226             
   230             
   227     if(ok){
   231     if(ok)
       
   232         {
   228         ret = static_cast<TBool>(state.toInt());
   233         ret = static_cast<TBool>(state.toInt());
   229         }
   234         }
   230     */
   235     */
   231     
   236     
   232     return ret;
   237     return ret;
   235 // ----------------------------------------------------------------------------
   240 // ----------------------------------------------------------------------------
   236 // ----------------------------------------------------------------------------
   241 // ----------------------------------------------------------------------------
   237 void CIpsSosAOSettingsHandler::SetFirstEmnReceived( TBool /*aValue*/ )
   242 void CIpsSosAOSettingsHandler::SetFirstEmnReceived( TBool /*aValue*/ )
   238     {
   243     {
   239     /* Not supported yet
   244     /* Not supported yet
   240     if(!SetSettingValue( IpsServices::FirstEmnReceived, aValue )){
   245     if(!SetSettingValue( IpsServices::FirstEmnReceived, aValue ))
       
   246         {
   241         CreateKeyValuePair(IpsServices::FirstEmnReceived, aValue);
   247         CreateKeyValuePair(IpsServices::FirstEmnReceived, aValue);
   242         }
   248         }
   243     */
   249     */
   244     }
   250     }
   245 
   251 
   252     /* Not supported yet
   258     /* Not supported yet
   253 
   259 
   254     QVariant state = NULL;
   260     QVariant state = NULL;
   255     TBool ok = GetSettingValue(IpsServices::EmnReceivedNotSynced, state);
   261     TBool ok = GetSettingValue(IpsServices::EmnReceivedNotSynced, state);
   256                 
   262                 
   257     if(ok){
   263     if(ok)
       
   264         {
   258         ret = static_cast<TBool>(state.toInt());
   265         ret = static_cast<TBool>(state.toInt());
   259         }
   266         }
   260     */
   267     */
   261 
   268 
   262     return ret;
   269     return ret;
   266 // ----------------------------------------------------------------------------
   273 // ----------------------------------------------------------------------------
   267 void CIpsSosAOSettingsHandler::SetEmnReceivedButNotSyncedFlag( TBool /*aFlag*/ )
   274 void CIpsSosAOSettingsHandler::SetEmnReceivedButNotSyncedFlag( TBool /*aFlag*/ )
   268     {
   275     {
   269     /* Not supported yet
   276     /* Not supported yet
   270     
   277     
   271     if(!SetSettingValue(IpsServices::EmnReceivedNotSynced, aFlag)){
   278     if(!SetSettingValue(IpsServices::EmnReceivedNotSynced, aFlag))
       
   279         {
   272         CreateKeyValuePair(IpsServices::EmnReceivedNotSynced, aFlag);
   280         CreateKeyValuePair(IpsServices::EmnReceivedNotSynced, aFlag);
   273         }
   281         }
   274     */
   282     */
   275     }
   283     }
   276 
   284 
   281     TUint ret = 0;
   289     TUint ret = 0;
   282     
   290     
   283     QVariant state = NULL;
   291     QVariant state = NULL;
   284     TBool ok = GetSettingValue(IpsServices::ReceptionWeekDays, state);
   292     TBool ok = GetSettingValue(IpsServices::ReceptionWeekDays, state);
   285                     
   293                     
   286     if(ok){
   294     if(ok)
       
   295         {
   287         ret = static_cast<TUint>(state.toUInt());
   296         ret = static_cast<TUint>(state.toUInt());
   288         }
   297         }
   289     
   298     
   290     return ret;
   299     return ret;
   291     }
   300     }
   296     {
   305     {
   297     QVariant value = NULL;
   306     QVariant value = NULL;
   298     TBool ok = GetSettingValue(IpsServices::ReceptionDayStartTime, value);
   307     TBool ok = GetSettingValue(IpsServices::ReceptionDayStartTime, value);
   299     TDateTime time;
   308     TDateTime time;
   300     
   309     
   301     if(ok){
   310     if(ok)
       
   311         {
   302         TInt total = value.toInt();
   312         TInt total = value.toInt();
   303         TInt minutes = total%KAOMinutesInHour;
   313         TInt minutes = total%KAOMinutesInHour;
   304         TInt hour = total/KAOMinutesInHour;
   314         TInt hour = total/KAOMinutesInHour;
   305         time.SetHour(hour);
   315         time.SetHour(hour);
   306         time.SetMinute(minutes);
   316         time.SetMinute(minutes);
   316     {
   326     {
   317     QVariant value = NULL;
   327     QVariant value = NULL;
   318     TBool ok = GetSettingValue(IpsServices::ReceptionDayEndTime, value);
   328     TBool ok = GetSettingValue(IpsServices::ReceptionDayEndTime, value);
   319     TDateTime time;
   329     TDateTime time;
   320     
   330     
   321     if(ok){
   331     if(ok)
       
   332         {
   322         TInt total = value.toInt();
   333         TInt total = value.toInt();
   323         TInt minutes = total%KAOMinutesInHour;
   334         TInt minutes = total%KAOMinutesInHour;
   324         TInt hour = total/KAOMinutesInHour;
   335         TInt hour = total/KAOMinutesInHour;
   325         time.SetHour(hour);
   336         time.SetHour(hour);
   326         time.SetMinute(minutes);
   337         time.SetMinute(minutes);
   336         const IpsServices::TAOInfo& aLastUpdateInfo )
   347         const IpsServices::TAOInfo& aLastUpdateInfo )
   337     {
   348     {
   338     TInt high = I64HIGH(aLastUpdateInfo.iLastSuccessfulUpdate.Int64());
   349     TInt high = I64HIGH(aLastUpdateInfo.iLastSuccessfulUpdate.Int64());
   339     TInt low = I64LOW(aLastUpdateInfo.iLastSuccessfulUpdate.Int64());
   350     TInt low = I64LOW(aLastUpdateInfo.iLastSuccessfulUpdate.Int64());
   340    
   351    
   341     if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low)){
   352     if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low))
       
   353         {
   342         CreateKeyValuePair(IpsServices::AoLastSuccessfulUpdateL, low);
   354         CreateKeyValuePair(IpsServices::AoLastSuccessfulUpdateL, low);
   343         }
   355         }
   344         
   356         
   345     if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high)){
   357     if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high))
       
   358         {
   346         CreateKeyValuePair(IpsServices::AoLastSuccessfulUpdateH, high);
   359         CreateKeyValuePair(IpsServices::AoLastSuccessfulUpdateH, high);
   347         }
   360         }
   348         
   361         
   349     if(!SetSettingValue(
   362     if(!SetSettingValue(
   350             IpsServices::AoLastUpdateFailed, 
   363             IpsServices::AoLastUpdateFailed, 
   351             aLastUpdateInfo.iLastUpdateFailed)){
   364             aLastUpdateInfo.iLastUpdateFailed))
       
   365         {
   352         CreateKeyValuePair(IpsServices::AoLastUpdateFailed, 
   366         CreateKeyValuePair(IpsServices::AoLastUpdateFailed, 
   353                 aLastUpdateInfo.iLastUpdateFailed);
   367                 aLastUpdateInfo.iLastUpdateFailed);
   354         }
   368         }
   355         
   369         
   356     if(!SetSettingValue(
   370     if(!SetSettingValue(
   357             IpsServices::AoUpdateSuccessfulWithCurSettings, 
   371             IpsServices::AoUpdateSuccessfulWithCurSettings, 
   358             aLastUpdateInfo.iUpdateSuccessfulWithCurSettings)){
   372             aLastUpdateInfo.iUpdateSuccessfulWithCurSettings))
       
   373         {
   359         CreateKeyValuePair(IpsServices::AoUpdateSuccessfulWithCurSettings, 
   374         CreateKeyValuePair(IpsServices::AoUpdateSuccessfulWithCurSettings, 
   360                 aLastUpdateInfo.iUpdateSuccessfulWithCurSettings);
   375                 aLastUpdateInfo.iUpdateSuccessfulWithCurSettings);
   361         }
   376         }
   362     }
   377     }
   363 
   378 
   374     QVariant low=NULL;
   389     QVariant low=NULL;
   375     QVariant fail=NULL;
   390     QVariant fail=NULL;
   376     QVariant success=NULL;
   391     QVariant success=NULL;
   377         
   392         
   378     TBool ok = GetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high);
   393     TBool ok = GetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high);
   379     if(ok){
   394     if( ok )
       
   395         {
   380         ok = GetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low);
   396         ok = GetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low);
   381         }
   397         }
   382      if(ok){
   398      if( ok )
       
   399          {
   383          info.iLastSuccessfulUpdate = MAKE_TINT64( high.toInt(), low.toInt() );
   400          info.iLastSuccessfulUpdate = MAKE_TINT64( high.toInt(), low.toInt() );
   384          }
   401          }
   385     
   402     
   386     ok = GetSettingValue(IpsServices::AoLastUpdateFailed, fail);
   403     ok = GetSettingValue(IpsServices::AoLastUpdateFailed, fail);
   387     
   404     
   388     if(ok){
   405     if( ok )
       
   406         {
   389         info.iLastUpdateFailed = static_cast<TBool>(fail.toInt());
   407         info.iLastUpdateFailed = static_cast<TBool>(fail.toInt());
   390         }
   408         }
   391     
   409     
   392     ok = GetSettingValue(IpsServices::AoUpdateSuccessfulWithCurSettings, success);
   410     ok = GetSettingValue(IpsServices::AoUpdateSuccessfulWithCurSettings, success);
   393     
   411     
   394     if(ok){
   412     if( ok )
       
   413         {
   395         info.iUpdateSuccessfulWithCurSettings = static_cast<TBool>(success.toInt());
   414         info.iUpdateSuccessfulWithCurSettings = static_cast<TBool>(success.toInt());
   396         }
   415         }
   397     
   416     
   398     return info;
   417     return info;
   399     }
   418     }
   402 // ----------------------------------------------------------------------------
   421 // ----------------------------------------------------------------------------
   403 TInt CIpsSosAOSettingsHandler::InboxRefreshTime() const
   422 TInt CIpsSosAOSettingsHandler::InboxRefreshTime() const
   404     {
   423     {
   405     QVariant value = NULL;
   424     QVariant value = NULL;
   406     TBool ok = EFalse;
   425     TBool ok = EFalse;
   407     if(IsDaytime()){
   426     if( IsDaytime() )
       
   427         {
   408         ok = GetSettingValue( IpsServices::ReceptionRefreshPeriodDayTime, value);
   428         ok = GetSettingValue( IpsServices::ReceptionRefreshPeriodDayTime, value);
   409         }
   429         }
   410     else{
   430     else
       
   431         {
   411         ok = GetSettingValue(IpsServices::ReceptionRefreshPeriodOther, value);
   432         ok = GetSettingValue(IpsServices::ReceptionRefreshPeriodOther, value);
   412         }    
   433         }    
   413     
   434     
   414     TInt ret = 0;
   435     TInt ret = 0;
   415     if(ok){
   436     if( ok )
       
   437         {
   416         ret = value.toInt();
   438         ret = value.toInt();
   417         }
   439         }
   418     
   440     
   419     return ret;
   441     return ret;
   420     }
   442     }
   442 TBool CIpsSosAOSettingsHandler::GetSettingValue(
   464 TBool CIpsSosAOSettingsHandler::GetSettingValue(
   443         IpsServices::SettingItem aItem,
   465         IpsServices::SettingItem aItem,
   444         QVariant& aValue) const
   466         QVariant& aValue) const
   445     {
   467     {
   446     bool ret = false;
   468     bool ret = false;
   447     if(iExtMgr){
   469     if( iExtMgr )
       
   470         {
   448         ret = iExtMgr->readSetting(aItem, aValue);
   471         ret = iExtMgr->readSetting(aItem, aValue);
   449         }
   472         }
   450     return ret;
   473     return ret;
   451     }
   474     }
   452 
   475 
   456         const IpsServices::SettingItem aItem, 
   479         const IpsServices::SettingItem aItem, 
   457         const QVariant& aData)
   480         const QVariant& aData)
   458     {
   481     {
   459     bool ret = false;
   482     bool ret = false;
   460     
   483     
   461     if(iExtMgr){
   484     if( iExtMgr )
       
   485         {
   462         ret = iExtMgr->writeSetting(aItem, aData);
   486         ret = iExtMgr->writeSetting(aItem, aData);
   463         }
   487         }
   464     return ret;
   488     return ret;
   465     }
   489     }
   466 
   490 
   508 IpsServices::TIpsSetDataAoStates CIpsSosAOSettingsHandler::ProfileIntoAOState(
   532 IpsServices::TIpsSetDataAoStates CIpsSosAOSettingsHandler::ProfileIntoAOState(
   509             const TInt aProfile) const
   533             const TInt aProfile) const
   510     {
   534     {
   511     IpsServices::TIpsSetDataAoStates ret = IpsServices::EMailAoOff;
   535     IpsServices::TIpsSetDataAoStates ret = IpsServices::EMailAoOff;
   512     
   536     
   513     if ( aProfile != IpsServices::EmailSyncProfileManualFetch ){
   537     if ( aProfile != IpsServices::EmailSyncProfileManualFetch )
       
   538         {
   514         ret = IpsServices::EMailAoAlways;
   539         ret = IpsServices::EMailAoAlways;
   515         }
   540         }
   516     
   541     
   517     return ret;
   542     return ret;
   518     }
   543     }