ipsservices/ipssosaoplugin/src/IpsSosAOSettingsHandler.cpp
changeset 23 2dc6caa42ec3
parent 20 ecc8def7944a
child 30 759dc5235cdb
equal deleted inserted replaced
20:ecc8def7944a 23:2dc6caa42ec3
    14 * Description: 
    14 * Description: 
    15 *     
    15 *     
    16 *
    16 *
    17 */
    17 */
    18 #include "IpsSosAOSettingsHandler.h"
    18 #include "IpsSosAOSettingsHandler.h"
       
    19 #include "IpsSosAoExtendedSettingsManager.h"
       
    20 #include "nmipssettingitems.h"
       
    21 #include "ipssettingkeys.h"
    19 #include <SendUiConsts.h>
    22 #include <SendUiConsts.h>
    20 
    23 #include <msvapi.h>
    21 
    24 #include <cemailaccounts.h>
    22 // ----------------------------------------------------------------------------
    25 #include <smtpset.h>
    23 // ----------------------------------------------------------------------------
    26 #include <nmcommon.h>
    24 CIpsSosAOSettingsHandler* CIpsSosAOSettingsHandler::NewL( TUid aProtocol )
    27 
    25     {
    28 const TInt KAOMinutesInHour = 60;
    26     CIpsSosAOSettingsHandler* self = new(ELeave)CIpsSosAOSettingsHandler();
    29 
       
    30 // ----------------------------------------------------------------------------
       
    31 // ----------------------------------------------------------------------------
       
    32 CIpsSosAOSettingsHandler* CIpsSosAOSettingsHandler::NewL( 
       
    33         CMsvSession& aSession,
       
    34         TMsvId aMailboxId )
       
    35     {
       
    36     CIpsSosAOSettingsHandler* self = new(ELeave)CIpsSosAOSettingsHandler(aSession);
    27     CleanupStack::PushL(self);
    37     CleanupStack::PushL(self);
    28     self->ConstructL( aProtocol );
    38     self->ConstructL( aMailboxId );
    29     CleanupStack::Pop(self);
    39     CleanupStack::Pop(self);
    30     return self;
    40     return self;
    31     }
    41     }
    32 
    42 
    33 // ----------------------------------------------------------------------------
    43 // ----------------------------------------------------------------------------
    34 // ----------------------------------------------------------------------------
    44 // ----------------------------------------------------------------------------
    35 CIpsSosAOSettingsHandler::CIpsSosAOSettingsHandler() 
    45 CIpsSosAOSettingsHandler::CIpsSosAOSettingsHandler(CMsvSession& aSession) :
       
    46         iSession(aSession)
    36     {
    47     {
    37     }
    48     }
    38 
    49 
    39 // ----------------------------------------------------------------------------
    50 // ----------------------------------------------------------------------------
    40 // ----------------------------------------------------------------------------
    51 // ----------------------------------------------------------------------------
    41 CIpsSosAOSettingsHandler::~CIpsSosAOSettingsHandler()
    52 CIpsSosAOSettingsHandler::~CIpsSosAOSettingsHandler()
    42     {
    53     {
    43     }
    54     delete iExtMgr;
    44 
    55     }
    45 // ----------------------------------------------------------------------------
    56 
    46 // ----------------------------------------------------------------------------
    57 // ----------------------------------------------------------------------------
    47 void CIpsSosAOSettingsHandler::ConstructL( TUid aProtocol )
    58 // ----------------------------------------------------------------------------
    48     {
    59 void CIpsSosAOSettingsHandler::ConstructL( TMsvId aMailboxId )
    49     iMtmType = aProtocol;
    60     {
       
    61     TMsvId dummy;    
       
    62     iSession.GetEntry(aMailboxId, dummy, iEntry);
       
    63     
       
    64     iExtMgr = new NmIpsSosAoExtendedSettingsManager(MboxId());
    50     }
    65     }
    51 
    66 
    52 
    67 
    53 // ----------------------------------------------------------------------------
    68 // ----------------------------------------------------------------------------
    54 // ----------------------------------------------------------------------------
    69 // ----------------------------------------------------------------------------
    55 TInt CIpsSosAOSettingsHandler::GetFSPluginId() const
    70 TInt CIpsSosAOSettingsHandler::GetFSPluginId() const
    56     {
    71     {
    57     TInt pluginId = 0;
    72     TInt pluginId = 0;
    58     if ( iMtmType.iUid == KSenduiMtmImap4UidValue )
    73     if ( iEntry.iMtm.iUid == KSenduiMtmImap4UidValue )
    59         {
    74         {
    60         pluginId = IPSSOSIMAP4PLUGIN_IMPLEMENTATION_UID;
    75         pluginId = IPSSOSIMAP4PLUGIN_IMPLEMENTATION_UID;
    61         }
    76         }
    62     else if ( iMtmType.iUid == KSenduiMtmPop3UidValue )
    77     else if ( iEntry.iMtm.iUid == KSenduiMtmPop3UidValue )
    63         {
    78         {
    64         pluginId = IPSSOSPOP3PLUGIN_IMPLEMENTATION_UID;
    79         pluginId = IPSSOSPOP3PLUGIN_IMPLEMENTATION_UID;
    65         }
    80         }
    66     return pluginId;
    81     return pluginId;
       
    82     }
       
    83 
       
    84 // ----------------------------------------------------------------------------
       
    85 // ----------------------------------------------------------------------------
       
    86 NmId CIpsSosAOSettingsHandler::MboxId() const
       
    87     {
       
    88     NmId id;
       
    89     id.setId32(iEntry.Id());
       
    90     id.setPluginId32(GetFSPluginId());
       
    91     return id;
    67     }
    92     }
    68 
    93 
    69 // ----------------------------------------------------------------------------
    94 // ----------------------------------------------------------------------------
    70 // ----------------------------------------------------------------------------
    95 // ----------------------------------------------------------------------------
    71 void CIpsSosAOSettingsHandler::GetSubscribedImapFoldersL( 
    96 void CIpsSosAOSettingsHandler::GetSubscribedImapFoldersL( 
    72             TMsvId /*aServiceId*/, 
    97             TMsvId /*aServiceId*/, 
    73             RArray<TMsvId>& /*aFoldersArray*/ )
    98             RArray<TMsvId>& /*aFoldersArray*/ )
    74     {
    99     {
    75     
   100     //folders not supported
    76     }
   101     }
    77     
   102     
    78     
   103     
    79 // ----------------------------------------------------------------------------
   104 // ----------------------------------------------------------------------------
    80 // ----------------------------------------------------------------------------
   105 // ----------------------------------------------------------------------------
    81 void CIpsSosAOSettingsHandler::ConstructImapPartialFetchInfo( 
   106 void CIpsSosAOSettingsHandler::ConstructImapPartialFetchInfo( 
    82         TImImap4GetPartialMailInfo& /*aInfo*/, 
   107         TImImap4GetPartialMailInfo& aInfo, 
    83         CImImap4Settings& /*aImap4Settings*/ )
   108         CImImap4Settings& aImap4Settings )
    84     {
   109     {
    85     
   110     TInt sizeLimit = aImap4Settings.BodyTextSizeLimit();
       
   111     
       
   112     if ( sizeLimit == KIpsHeadersOnly )
       
   113         {
       
   114         aInfo.iTotalSizeLimit = KIpsHeadersOnly;
       
   115         }
       
   116     else if ( sizeLimit == KIpsFullBodyAndAttas )
       
   117         {        
       
   118         aInfo.iTotalSizeLimit = KMaxTInt;
       
   119         aInfo.iAttachmentSizeLimit = KMaxTInt;
       
   120         aInfo.iBodyTextSizeLimit = KMaxTInt;
       
   121         aInfo.iMaxEmailSize = KMaxTInt;
       
   122         aInfo.iPartialMailOptions = ENoSizeLimits;
       
   123         aInfo.iGetMailBodyParts = EGetImap4EmailBodyTextAndAttachments;
       
   124         }
       
   125     else if ( sizeLimit == KIpsFullBodyOnly )
       
   126         {
       
   127         aInfo.iTotalSizeLimit = KMaxTInt; 
       
   128         aInfo.iAttachmentSizeLimit = 0;
       
   129         aInfo.iBodyTextSizeLimit = KMaxTInt;
       
   130         aInfo.iMaxEmailSize = KMaxTInt;
       
   131         aInfo.iPartialMailOptions = EBodyAlternativeText;
       
   132         aInfo.iGetMailBodyParts = EGetImap4EmailBodyAlternativeText;
       
   133         }
       
   134     else
       
   135         {
       
   136         aInfo.iTotalSizeLimit = sizeLimit*1024; 
       
   137         // set zero when it not documentated does total size overrides these 
       
   138         aInfo.iAttachmentSizeLimit = 0;
       
   139         aInfo.iMaxEmailSize = sizeLimit*1024;
       
   140         aInfo.iBodyTextSizeLimit = sizeLimit*1024;
       
   141         aInfo.iPartialMailOptions = EBodyAlternativeText;
       
   142         aInfo.iGetMailBodyParts = EGetImap4EmailBodyAlternativeText;
       
   143         }
    86     }
   144     }
    87 
   145 
    88 
   146 
    89 // ----------------------------------------------------------------------------
   147 // ----------------------------------------------------------------------------
    90 // ----------------------------------------------------------------------------
   148 // ----------------------------------------------------------------------------
    91 IpsServices::TIpsSetDataAoStates 
   149 IpsServices::TIpsSetDataAoStates 
    92     CIpsSosAOSettingsHandler::AlwaysOnlineState() const
   150     CIpsSosAOSettingsHandler::AlwaysOnlineState() const
    93     {
   151     {
    94     return IpsServices::EMailAoOff;
   152     TInt prof = IpsServices::EmailSyncProfileManualFetch;
       
   153     IpsServices::TIpsSetDataAoStates ret = IpsServices::EMailAoOff;
       
   154     
       
   155     QVariant state;
       
   156     TBool ok = GetSettingValue(IpsServices::ReceptionActiveProfile, state);
       
   157     
       
   158     if(ok ){
       
   159         prof = state.toInt();
       
   160         
       
   161         ret = ProfileIntoAOState(prof);
       
   162         }   
       
   163     
       
   164     return ret;
    95     }
   165     }
    96 
   166 
    97 // ----------------------------------------------------------------------------
   167 // ----------------------------------------------------------------------------
    98 // ----------------------------------------------------------------------------
   168 // ----------------------------------------------------------------------------
    99 void CIpsSosAOSettingsHandler::SetAlwaysOnlineState(
   169 void CIpsSosAOSettingsHandler::SetAlwaysOnlineState(
   100     const IpsServices::TIpsSetDataAoStates /*aAlwaysOnlineState*/,
   170     const IpsServices::TIpsSetDataAoStates aAlwaysOnlineState )
   101     TBool /*aIgnoreStateFlag*/ )
   171     {
   102     {
   172     //we're allowed to switch ourselves off, not on.
       
   173     if ( aAlwaysOnlineState == IpsServices::EMailAoOff ){
       
   174         if(!SetSettingValue(
       
   175                 IpsServices::ReceptionActiveProfile, 
       
   176                 IpsServices::EmailSyncProfileManualFetch)){
       
   177         
       
   178             CreateKeyValuePair(
       
   179                     IpsServices::ReceptionActiveProfile, 
       
   180                     IpsServices::EmailSyncProfileManualFetch);
       
   181             }
       
   182         }
   103     
   183     
   104     }
   184     }
   105 
   185 
   106 // ----------------------------------------------------------------------------
   186 // ----------------------------------------------------------------------------
   107 // ----------------------------------------------------------------------------
   187 // ----------------------------------------------------------------------------
   108 IpsServices::TIpsSetDataEmnStates 
   188 IpsServices::TIpsSetDataEmnStates 
   109     CIpsSosAOSettingsHandler::EmailNotificationState() const
   189     CIpsSosAOSettingsHandler::EmailNotificationState() const
   110     {
   190     {
   111     return IpsServices::EMailEmnOff;
   191     IpsServices::TIpsSetDataEmnStates ret = IpsServices::EMailEmnOff;
       
   192 
       
   193     /* Not supported yet
       
   194     QVariant state = NULL;
       
   195     TBool ok = GetSettingValue(IpsServices::EmailNotificationState, state);
       
   196         
       
   197     if(ok){
       
   198         ret = static_cast<IpsServices::TIpsSetDataEmnStates>(state.toInt());
       
   199         }
       
   200     */
       
   201         
       
   202     return ret;
   112     }
   203     }
   113 
   204 
   114 // ----------------------------------------------------------------------------
   205 // ----------------------------------------------------------------------------
   115 // ----------------------------------------------------------------------------
   206 // ----------------------------------------------------------------------------
   116 void CIpsSosAOSettingsHandler::SetEmailNotificationState(
   207 void CIpsSosAOSettingsHandler::SetEmailNotificationState(
   117     const IpsServices::TIpsSetDataEmnStates /*aEmnState*/ )
   208     const IpsServices::TIpsSetDataEmnStates /*aEmnState*/ )
   118     {
   209     {
   119     
   210     /* Not supported yet
       
   211     if(!SetSettingValue(IpsServices::EmailNotificationState, aEmnState)){
       
   212         CreateKeyValuePair(IpsServices::EmailNotificationState, aEmnState);
       
   213         }
       
   214     */
   120     }
   215     }
   121     
   216     
   122 // ----------------------------------------------------------------------------
   217 // ----------------------------------------------------------------------------
   123 // ----------------------------------------------------------------------------
   218 // ----------------------------------------------------------------------------
   124 TBool CIpsSosAOSettingsHandler::FirstEmnReceived() const
   219 TBool CIpsSosAOSettingsHandler::FirstEmnReceived() const
   125     {
   220     {
   126     return EFalse;
   221     TBool ret = EFalse;
       
   222     
       
   223     /* Not supported yet
       
   224     QVariant state = NULL;
       
   225     TBool ok = GetSettingValue(IpsServices::FirstEmnReceived, state);
       
   226             
       
   227     if(ok){
       
   228         ret = static_cast<TBool>(state.toInt());
       
   229         }
       
   230     */
       
   231     
       
   232     return ret;
   127     }
   233     }
   128 
   234 
   129 // ----------------------------------------------------------------------------
   235 // ----------------------------------------------------------------------------
   130 // ----------------------------------------------------------------------------
   236 // ----------------------------------------------------------------------------
   131 void CIpsSosAOSettingsHandler::SetFirstEmnReceived( TBool /*aValue*/ )
   237 void CIpsSosAOSettingsHandler::SetFirstEmnReceived( TBool /*aValue*/ )
   132     {
   238     {
   133     
   239     /* Not supported yet
       
   240     if(!SetSettingValue( IpsServices::FirstEmnReceived, aValue )){
       
   241         CreateKeyValuePair(IpsServices::FirstEmnReceived, aValue);
       
   242         }
       
   243     */
   134     }
   244     }
   135 
   245 
   136 // ----------------------------------------------------------------------------
   246 // ----------------------------------------------------------------------------
   137 // ----------------------------------------------------------------------------
   247 // ----------------------------------------------------------------------------
   138 TBool CIpsSosAOSettingsHandler::EmnReceivedButNotSyncedFlag() const
   248 TBool CIpsSosAOSettingsHandler::EmnReceivedButNotSyncedFlag() const
   139     {
   249     {
   140     return EFalse;
   250     TBool ret = EFalse; 
       
   251 
       
   252     /* Not supported yet
       
   253 
       
   254     QVariant state = NULL;
       
   255     TBool ok = GetSettingValue(IpsServices::EmnReceivedNotSynced, state);
       
   256                 
       
   257     if(ok){
       
   258         ret = static_cast<TBool>(state.toInt());
       
   259         }
       
   260     */
       
   261 
       
   262     return ret;
   141     }
   263     }
   142     
   264     
   143 // ----------------------------------------------------------------------------
   265 // ----------------------------------------------------------------------------
   144 // ----------------------------------------------------------------------------
   266 // ----------------------------------------------------------------------------
   145 void CIpsSosAOSettingsHandler::SetEmnReceivedButNotSyncedFlag( TBool /*aFlag*/ )
   267 void CIpsSosAOSettingsHandler::SetEmnReceivedButNotSyncedFlag( TBool /*aFlag*/ )
   146     {
   268     {
   147     
   269     /* Not supported yet
       
   270     
       
   271     if(!SetSettingValue(IpsServices::EmnReceivedNotSynced, aFlag)){
       
   272         CreateKeyValuePair(IpsServices::EmnReceivedNotSynced, aFlag);
       
   273         }
       
   274     */
   148     }
   275     }
   149 
   276 
   150 // ----------------------------------------------------------------------------
   277 // ----------------------------------------------------------------------------
   151 // ----------------------------------------------------------------------------
   278 // ----------------------------------------------------------------------------
   152 TUint CIpsSosAOSettingsHandler::SelectedWeekDays() const
   279 TUint CIpsSosAOSettingsHandler::SelectedWeekDays() const
   153     {
   280     {
   154     return 0;
   281     TUint ret = 0;
       
   282     
       
   283     QVariant state = NULL;
       
   284     TBool ok = GetSettingValue(IpsServices::ReceptionWeekDays, state);
       
   285                     
       
   286     if(ok){
       
   287         ret = static_cast<TUint>(state.toUInt());
       
   288         }
       
   289     
       
   290     return ret;
   155     }
   291     }
   156 
   292 
   157 // ----------------------------------------------------------------------------
   293 // ----------------------------------------------------------------------------
   158 // ----------------------------------------------------------------------------
   294 // ----------------------------------------------------------------------------
   159 TTime CIpsSosAOSettingsHandler::SelectedTimeStart() const
   295 TTime CIpsSosAOSettingsHandler::SelectedTimeStart() const
   160     {
   296     {
   161     TTime t = TTime(); 
   297     QVariant value = NULL;
   162     t.HomeTime();
   298     TBool ok = GetSettingValue(IpsServices::ReceptionDayStartTime, value);
   163     return t;
   299     TDateTime time;
       
   300     
       
   301     if(ok){
       
   302         TInt total = value.toInt();
       
   303         TInt minutes = total%KAOMinutesInHour;
       
   304         TInt hour = total/KAOMinutesInHour;
       
   305         time.SetHour(hour);
       
   306         time.SetMinute(minutes);
       
   307         }
       
   308     
       
   309     TTime ret(time);
       
   310     return ret;       
   164     }
   311     }
   165 
   312 
   166 // ----------------------------------------------------------------------------
   313 // ----------------------------------------------------------------------------
   167 // ----------------------------------------------------------------------------
   314 // ----------------------------------------------------------------------------
   168 TTime CIpsSosAOSettingsHandler::SelectedTimeStop() const
   315 TTime CIpsSosAOSettingsHandler::SelectedTimeStop() const
   169     {
   316     {
   170     TTime t = TTime();
   317     QVariant value = NULL;
   171     t.HomeTime();
   318     TBool ok = GetSettingValue(IpsServices::ReceptionDayEndTime, value);
   172     return t;
   319     TDateTime time;
       
   320     
       
   321     if(ok){
       
   322         TInt total = value.toInt();
       
   323         TInt minutes = total%KAOMinutesInHour;
       
   324         TInt hour = total/KAOMinutesInHour;
       
   325         time.SetHour(hour);
       
   326         time.SetMinute(minutes);
       
   327         }
       
   328     
       
   329     TTime ret(time);
       
   330     return ret;
   173     }
   331     }
   174 
   332 
   175 // ----------------------------------------------------------------------------
   333 // ----------------------------------------------------------------------------
   176 // ----------------------------------------------------------------------------
   334 // ----------------------------------------------------------------------------
   177 void CIpsSosAOSettingsHandler::SetLastUpdateInfo( 
   335 void CIpsSosAOSettingsHandler::SetLastUpdateInfo( 
   178         const IpsServices::TAOInfo& /*aLastUpdateInfo*/ )
   336         const IpsServices::TAOInfo& aLastUpdateInfo )
   179     {
   337     {
   180     
   338     TInt high = I64HIGH(aLastUpdateInfo.iLastSuccessfulUpdate.Int64());
       
   339     TInt low = I64LOW(aLastUpdateInfo.iLastSuccessfulUpdate.Int64());
       
   340    
       
   341     if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low)){
       
   342         CreateKeyValuePair(IpsServices::AoLastSuccessfulUpdateL, low);
       
   343         }
       
   344         
       
   345     if(!SetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high)){
       
   346         CreateKeyValuePair(IpsServices::AoLastSuccessfulUpdateH, high);
       
   347         }
       
   348         
       
   349     if(!SetSettingValue(
       
   350             IpsServices::AoLastUpdateFailed, 
       
   351             aLastUpdateInfo.iLastUpdateFailed)){
       
   352         CreateKeyValuePair(IpsServices::AoLastUpdateFailed, 
       
   353                 aLastUpdateInfo.iLastUpdateFailed);
       
   354         }
       
   355         
       
   356     if(!SetSettingValue(
       
   357             IpsServices::AoUpdateSuccessfulWithCurSettings, 
       
   358             aLastUpdateInfo.iUpdateSuccessfulWithCurSettings)){
       
   359         CreateKeyValuePair(IpsServices::AoUpdateSuccessfulWithCurSettings, 
       
   360                 aLastUpdateInfo.iUpdateSuccessfulWithCurSettings);
       
   361         }
   181     }
   362     }
   182 
   363 
   183 // ----------------------------------------------------------------------------
   364 // ----------------------------------------------------------------------------
   184 // ----------------------------------------------------------------------------
   365 // ----------------------------------------------------------------------------
   185 IpsServices::TAOInfo CIpsSosAOSettingsHandler::LastUpdateInfo() const
   366 IpsServices::TAOInfo CIpsSosAOSettingsHandler::LastUpdateInfo() const
   186     {
   367     {
   187     IpsServices::TAOInfo dummy;
   368     IpsServices::TAOInfo info;
   188     return dummy;
   369 
       
   370     TDateTime time;        
       
   371     info.iLastSuccessfulUpdate = time; 
       
   372     
       
   373     QVariant high=NULL;
       
   374     QVariant low=NULL;
       
   375     QVariant fail=NULL;
       
   376     QVariant success=NULL;
       
   377         
       
   378     TBool ok = GetSettingValue(IpsServices::AoLastSuccessfulUpdateH, high);
       
   379     if(ok){
       
   380         ok = GetSettingValue(IpsServices::AoLastSuccessfulUpdateL, low);
       
   381         }
       
   382      if(ok){
       
   383          info.iLastSuccessfulUpdate = MAKE_TINT64( high.toInt(), low.toInt() );
       
   384          }
       
   385     
       
   386     ok = GetSettingValue(IpsServices::AoLastUpdateFailed, fail);
       
   387     
       
   388     if(ok){
       
   389         info.iLastUpdateFailed = static_cast<TBool>(fail.toInt());
       
   390         }
       
   391     
       
   392     ok = GetSettingValue(IpsServices::AoUpdateSuccessfulWithCurSettings, success);
       
   393     
       
   394     if(ok){
       
   395         info.iUpdateSuccessfulWithCurSettings = static_cast<TBool>(success.toInt());
       
   396         }
       
   397     
       
   398     return info;
   189     }
   399     }
   190 
   400 
   191 // ----------------------------------------------------------------------------
   401 // ----------------------------------------------------------------------------
   192 // ----------------------------------------------------------------------------
   402 // ----------------------------------------------------------------------------
   193 TInt CIpsSosAOSettingsHandler::InboxRefreshTime() const
   403 TInt CIpsSosAOSettingsHandler::InboxRefreshTime() const
   194     {
   404     {
   195     return 0;
   405     QVariant value = NULL;
   196     }
   406     TBool ok = EFalse;
   197 
   407     if(IsDaytime()){
   198 // ----------------------------------------------------------------------------
   408         ok = GetSettingValue( IpsServices::ReceptionRefreshPeriodDayTime, value);
   199 // ----------------------------------------------------------------------------
   409         }
   200 TBool CIpsSosAOSettingsHandler::RoamHomeOnlyFlag()
   410     else{
   201     {
   411         ok = GetSettingValue(IpsServices::ReceptionRefreshPeriodOther, value);
   202     return EFalse;
   412         }    
   203     }
   413     
       
   414     TInt ret = 0;
       
   415     if(ok){
       
   416         ret = value.toInt();
       
   417         }
       
   418     
       
   419     return ret;
       
   420     }
       
   421 
       
   422 
       
   423 
       
   424 // ----------------------------------------------------------------------------
       
   425 // ----------------------------------------------------------------------------
       
   426 HBufC* CIpsSosAOSettingsHandler::EmailAddressL()
       
   427     {
       
   428     CEmailAccounts* acc = CEmailAccounts::NewLC();
       
   429     TSmtpAccount smtp;
       
   430     acc->GetSmtpAccountL( iEntry.iRelatedId , smtp );
       
   431     CImSmtpSettings* smtpSet = new (ELeave) CImSmtpSettings();
       
   432     CleanupStack::PushL( smtpSet );
       
   433     acc->LoadSmtpSettingsL( smtp, *smtpSet );
       
   434     HBufC* address = smtpSet->EmailAddress().AllocL();
       
   435     CleanupStack::PopAndDestroy( 2, acc );
       
   436     
       
   437     return address;
       
   438     }
       
   439 
       
   440 // ----------------------------------------------------------------------------
       
   441 // ----------------------------------------------------------------------------
       
   442 TBool CIpsSosAOSettingsHandler::GetSettingValue(
       
   443         IpsServices::SettingItem aItem,
       
   444         QVariant& aValue) const
       
   445     {
       
   446     bool ret = false;
       
   447     if(iExtMgr){
       
   448         ret = iExtMgr->readSetting(aItem, aValue);
       
   449         }
       
   450     return ret;
       
   451     }
       
   452 
       
   453 // ----------------------------------------------------------------------------
       
   454 // ----------------------------------------------------------------------------
       
   455 TBool CIpsSosAOSettingsHandler::SetSettingValue(
       
   456         const IpsServices::SettingItem aItem, 
       
   457         const QVariant& aData)
       
   458     {
       
   459     bool ret = false;
       
   460     
       
   461     if(iExtMgr){
       
   462         ret = iExtMgr->writeSetting(aItem, aData);
       
   463         }
       
   464     return ret;
       
   465     }
       
   466 
       
   467 // ----------------------------------------------------------------------------
       
   468 // ----------------------------------------------------------------------------
       
   469 TBool CIpsSosAOSettingsHandler::CreateKeyValuePair(
       
   470             const IpsServices::SettingItem aKey, 
       
   471             const QVariant& aValue)
       
   472     {
       
   473     return iExtMgr->createKeyValuePair(aKey, aValue);
       
   474     }
       
   475 // ----------------------------------------------------------------------------
       
   476 // ----------------------------------------------------------------------------
       
   477 TBool CIpsSosAOSettingsHandler::IsDaytime() const
       
   478     {
       
   479     TTime current;
       
   480     current.HomeTime();
       
   481     
       
   482     TDateTime tmp = current.DateTime();
       
   483     
       
   484     //create blanc time object for comparison.
       
   485     //real current time cannot be used because we only want to
       
   486     //compare hours & minutes
       
   487     TDateTime dtNow;
       
   488     dtNow.SetMinute(tmp.Minute());
       
   489     dtNow.SetHour(tmp.Hour());
       
   490     
       
   491     TTime now(dtNow);
       
   492     TTime start = SelectedTimeStart();
       
   493     TTime stop = SelectedTimeStop();
       
   494     
       
   495     TDateTime a = start.DateTime();
       
   496     TDateTime b = stop.DateTime();
       
   497     
       
   498     if(now >= start &&
       
   499         now < stop){
       
   500         return ETrue;
       
   501         }
       
   502         
       
   503     return EFalse;    
       
   504     }
       
   505 
       
   506 // ----------------------------------------------------------------------------
       
   507 // ----------------------------------------------------------------------------
       
   508 IpsServices::TIpsSetDataAoStates CIpsSosAOSettingsHandler::ProfileIntoAOState(
       
   509             const TInt aProfile) const
       
   510     {
       
   511     IpsServices::TIpsSetDataAoStates ret = IpsServices::EMailAoOff;
       
   512     
       
   513     if ( aProfile != IpsServices::EmailSyncProfileManualFetch ){
       
   514         ret = IpsServices::EMailAoAlways;
       
   515         }
       
   516     
       
   517     return ret;
       
   518     }
       
   519     
   204 // End of file
   520 // End of file
   205 
   521