satengine/SatServer/SatClient/src/RSatRefresh.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Refresh notification sub-session.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    <rsatrefresh.h>
       
    22 #include    <rsatsession.h>
       
    23 #include    "SatSOpcodes.h"
       
    24 #include    "CSatAllowRefreshMonitor.h"
       
    25 #include    "CSatRefreshMonitor.h"
       
    26 #include    "SatLog.h"
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // RSatRefresh::RSatRefresh
       
    32 // C++ default constructor can NOT contain any code, that
       
    33 // might leave.
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 EXPORT_C RSatRefresh::RSatRefresh( MSatRefreshObserver& aObserver ) :
       
    37     RSubSessionBase(),
       
    38     iObserver( aObserver ),
       
    39     iAllowMonitor( NULL ),
       
    40     iRefreshMonitor( NULL )
       
    41     {
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // RSatRefresh::OpenL
       
    46 // Connects a sub-session to SatServer.
       
    47 // (other items were commented in a header).
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 EXPORT_C void RSatRefresh::OpenL( const RSatSession& aSession )
       
    51     {
       
    52     LOG( SIMPLE, "SATCLIENT: RSatRefresh::OpenL calling" )
       
    53     
       
    54     #ifdef ENABLE_SAT_LOGGING
       
    55     RProcess test;
       
    56     LOG2( SIMPLE, 
       
    57     "SATCLIENT: RSatRefresh::OpenL UID of calling process: 0x%x",
       
    58     test.SecureId().iId )
       
    59     test.Close();
       
    60     #endif
       
    61 
       
    62     TIpcArgs arguments( 0, 0, 0, 0 );
       
    63     User::LeaveIfError(
       
    64         CreateSubSession( aSession, ESatSOpenRefreshSubSession, arguments ) );
       
    65 
       
    66     LOG( SIMPLE, "SATCLIENT: RSatRefresh::OpenL exiting" )
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // RSatRefresh::Close
       
    71 // Closes the sub-session
       
    72 // (other items were commented in a header).
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C void RSatRefresh::Close()
       
    76     {
       
    77     LOG( SIMPLE, "SATCLIENT: RSatRefresh::Close calling" )
       
    78     
       
    79     #ifdef ENABLE_SAT_LOGGING
       
    80     RProcess test;
       
    81     LOG2( SIMPLE, 
       
    82     "SATCLIENT: RSatRefresh::Close UID of calling process: 0x%x",
       
    83     test.SecureId().iId )
       
    84     test.Close();
       
    85     #endif
       
    86 
       
    87     delete iRefreshMonitor;
       
    88     delete iAllowMonitor;
       
    89 
       
    90     iRefreshMonitor = NULL;
       
    91     iAllowMonitor = NULL;
       
    92 
       
    93     CloseSubSession( ESatSCloseRefreshSubSession );
       
    94 
       
    95     LOG( SIMPLE, "SATCLIENT: RSatRefresh::Close exiting" )
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // RSatRefresh::NotifyFileChangeL
       
   100 // Starts monitoring refresh events.
       
   101 // (other items were commented in a header).
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 EXPORT_C void RSatRefresh::NotifyFileChangeL()
       
   105     {
       
   106     LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL calling" )
       
   107     
       
   108     #ifdef ENABLE_SAT_LOGGING
       
   109     RProcess test;
       
   110     LOG2( SIMPLE, 
       
   111     "SATCLIENT: RSatRefresh::NotifyFileChangeL UID of calling process: 0x%x",
       
   112     test.SecureId().iId )
       
   113     test.Close();
       
   114     #endif
       
   115     
       
   116     if ( !iAllowMonitor )
       
   117         {
       
   118         LOG( SIMPLE, 
       
   119         "SATCLIENT: RSatRefresh::NotifyFileChangeL iAllowMonitor false" )
       
   120         iAllowMonitor = CSatAllowRefreshMonitor::NewL( iObserver, *this );
       
   121         iAllowMonitor->Start();
       
   122         }
       
   123     else
       
   124         {
       
   125         LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL, \
       
   126             re-start allowMonitor" )
       
   127         TSatRefreshFiles empty;
       
   128         iAllowMonitor->ObserveFiles( empty );
       
   129         iAllowMonitor->Start();
       
   130         }
       
   131 
       
   132     if ( !iRefreshMonitor )
       
   133         {
       
   134         LOG( SIMPLE, 
       
   135         "SATCLIENT: RSatRefresh::NotifyFileChangeL iRefreshMonitor false" )
       
   136         iRefreshMonitor = CSatRefreshMonitor::NewL( *this, iObserver );
       
   137         iRefreshMonitor->Start();
       
   138         }
       
   139     else
       
   140         {
       
   141         LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL, \
       
   142             re-start RefreshMonitor" )
       
   143         iRefreshMonitor->Start();
       
   144         }
       
   145 
       
   146     LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL exiting" )
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // RSatRefresh::NotifyFileChangeL
       
   151 // Starts monitoring refresh events.
       
   152 // (other items were commented in a header).
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 EXPORT_C void RSatRefresh::NotifyFileChangeL(
       
   156     const TSatRefreshFiles& aObservedFiles )
       
   157     {
       
   158     LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) calling" )
       
   159     
       
   160     #ifdef ENABLE_SAT_LOGGING
       
   161     RProcess test;
       
   162     LOG2( SIMPLE, 
       
   163     "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) UID of calling process: 0x%x",
       
   164     test.SecureId().iId )
       
   165     test.Close();
       
   166     #endif
       
   167     
       
   168     if ( !iAllowMonitor )
       
   169         {
       
   170         LOG( SIMPLE, 
       
   171         "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) iAllowMonitor false" )
       
   172         iAllowMonitor = CSatAllowRefreshMonitor::NewL( iObserver, *this );
       
   173         iAllowMonitor->ObserveFiles( aObservedFiles );
       
   174         iAllowMonitor->Start();
       
   175         }
       
   176     else
       
   177         {
       
   178         LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL(1), \
       
   179             re-start allowMonitor" )
       
   180         iAllowMonitor->ObserveFiles( aObservedFiles );
       
   181         iAllowMonitor->Start();
       
   182         }
       
   183 
       
   184     if ( !iRefreshMonitor )
       
   185         {
       
   186         LOG( SIMPLE, 
       
   187         "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) iRefreshMonitor false" )
       
   188         iRefreshMonitor = CSatRefreshMonitor::NewL( *this, iObserver );
       
   189         iRefreshMonitor->Start();
       
   190         }
       
   191     else
       
   192         {
       
   193         LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL(1), \
       
   194             re-start RefreshMonitor" )
       
   195         iRefreshMonitor->Start();
       
   196         }
       
   197 
       
   198     LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) exiting" )
       
   199     }
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // RSatRefresh::RefreshEFRead
       
   203 // Indicates client's refresh actions complete.
       
   204 // (other items were commented in a header).
       
   205 // -----------------------------------------------------------------------------
       
   206 //
       
   207 EXPORT_C void RSatRefresh::RefreshEFRead( TBool aAdditionEFRead ) const
       
   208     {
       
   209     LOG( SIMPLE, "SATCLIENT: RSatRefresh::RefreshEFRead calling" )
       
   210     
       
   211     #ifdef ENABLE_SAT_LOGGING
       
   212     RProcess test;
       
   213     LOG2( SIMPLE, 
       
   214     "SATCLIENT: RSatRefresh::RefreshEFRead UID of calling process: 0x%x",
       
   215     test.SecureId().iId )
       
   216     test.Close();
       
   217     #endif
       
   218     
       
   219     TPckg<TBool> additionEFReadPckg( aAdditionEFRead );
       
   220     TIpcArgs arguments( &additionEFReadPckg );
       
   221 
       
   222     SendReceive( ESatSRefreshEFRead, arguments );
       
   223 
       
   224     LOG( SIMPLE, "SATCLIENT: RSatRefresh::RefreshEFRead exiting" )
       
   225     }
       
   226 
       
   227 // -----------------------------------------------------------------------------
       
   228 // RSatRefresh::Cancel
       
   229 // Cancels both requests.
       
   230 // (other items were commented in a header).
       
   231 // -----------------------------------------------------------------------------
       
   232 //
       
   233 EXPORT_C void RSatRefresh::Cancel() const
       
   234     {
       
   235     LOG( SIMPLE, "SATCLIENT: RSatRefresh::Cancel calling" )
       
   236     
       
   237     #ifdef ENABLE_SAT_LOGGING
       
   238     RProcess test;
       
   239     LOG2( SIMPLE, 
       
   240     "SATCLIENT: RSatRefresh::Cancel UID of calling process: 0x%x",
       
   241     test.SecureId().iId )
       
   242     test.Close();
       
   243     #endif
       
   244     
       
   245     CancelNotifyAllowRefresh();
       
   246     CancelNotifyRefresh();
       
   247 
       
   248     LOG( SIMPLE, "SATCLIENT: RSatRefresh::Cancel exiting" )
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // RSatRefresh::NotifyAllowRefresh
       
   253 // Issues the request to be notified when refresh query is made.
       
   254 // (other items were commented in a header).
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 void RSatRefresh::NotifyAllowRefresh(
       
   258     TPckg<TSatRefreshType>& aType,
       
   259     TPckg<TSatRefreshFiles>& aChangingFiles,
       
   260     TRequestStatus& aStatus ) const
       
   261     {
       
   262     LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyAllowRefresh calling" )
       
   263 
       
   264     TIpcArgs arguments( &aChangingFiles, &aType );
       
   265     SendReceive( ESatSNotifyAllowRefresh, arguments, aStatus );
       
   266 
       
   267     LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyAllowRefresh exiting" )
       
   268     }
       
   269 
       
   270 // -----------------------------------------------------------------------------
       
   271 // RSatRefresh::AllowRefreshL
       
   272 // Sends client's response.
       
   273 // (other items were commented in a header).
       
   274 // -----------------------------------------------------------------------------
       
   275 //
       
   276 void RSatRefresh::AllowRefreshL( TBool aAllow ) const
       
   277     {
       
   278     LOG( SIMPLE, "SATCLIENT: RSatRefresh::AllowRefreshL calling" )
       
   279 
       
   280     TPckg<TBool> allowPckg( aAllow );
       
   281     TIpcArgs arguments( &allowPckg );
       
   282     User::LeaveIfError( SendReceive( ESatSRefreshAllowed, arguments ) );
       
   283 
       
   284     LOG( SIMPLE, "SATCLIENT: RSatRefresh::AllowRefreshL exiting" )
       
   285     }
       
   286 
       
   287 // -----------------------------------------------------------------------------
       
   288 // RSatRefresh::CancelNotifyAllowRefresh
       
   289 // Cancels the request.
       
   290 // (other items were commented in a header).
       
   291 // -----------------------------------------------------------------------------
       
   292 //
       
   293 void RSatRefresh::CancelNotifyAllowRefresh( TInt aError ) const
       
   294     {
       
   295     LOG( SIMPLE, "SATCLIENT: RSatRefresh::CancelNotifyAllowRefresh calling" )
       
   296 
       
   297     if ( iAllowMonitor )
       
   298         {
       
   299         LOG( SIMPLE, 
       
   300         "SATCLIENT: RSatRefresh::CancelNotifyAllowRefresh iAllowMonitor true" )
       
   301         TIpcArgs arguments( aError );
       
   302         SendReceive( ESatSNotityAllowRefreshCancel, arguments );
       
   303         }
       
   304 
       
   305     LOG( SIMPLE, "SATCLIENT: RSatRefresh::CancelNotifyAllowRefresh exiting" )
       
   306     }
       
   307 
       
   308 // -----------------------------------------------------------------------------
       
   309 // RSatRefresh::NotifyRefresh
       
   310 // Issues the request to be notified when refresh is made.
       
   311 // (other items were commented in a header).
       
   312 // -----------------------------------------------------------------------------
       
   313 //
       
   314 void RSatRefresh::NotifyRefresh(
       
   315     TPckg<TSatRefreshType>& aType,
       
   316     TPckg<TSatRefreshFiles>& aChangedFiles,
       
   317     TRequestStatus& aStatus ) const
       
   318     {
       
   319     LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyRefresh calling" )
       
   320 
       
   321     TIpcArgs arguments( &aChangedFiles, &aType );
       
   322     SendReceive( ESatSNotifyRefresh, arguments, aStatus );
       
   323 
       
   324     LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyRefresh exiting" )
       
   325     }
       
   326 
       
   327 // -----------------------------------------------------------------------------
       
   328 // RSatRefresh::CancelNotifyRefresh
       
   329 // Cancels the request.
       
   330 // (other items were commented in a header).
       
   331 // -----------------------------------------------------------------------------
       
   332 //
       
   333 void RSatRefresh::CancelNotifyRefresh() const
       
   334     {
       
   335     LOG( SIMPLE, "SATCLIENT: RSatRefresh::CancelNotifyRefresh calling" )
       
   336 
       
   337     if ( iRefreshMonitor )
       
   338         {
       
   339         LOG( SIMPLE, 
       
   340         "SATCLIENT: RSatRefresh::CancelNotifyAllowRefresh iRefreshMonitor \
       
   341         true" )
       
   342         TIpcArgs arguments( 0 );
       
   343         SendReceive( ESatSCancelNotifyRefresh, arguments );
       
   344         }
       
   345 
       
   346     LOG( SIMPLE, "SATCLIENT: RSatRefresh::CancelNotifyRefresh exiting" )
       
   347     }
       
   348 
       
   349 //  End of File