omadm/omadmappui/src/NSmlDMSyncState.cpp
changeset 0 3ce708148e4d
equal deleted inserted replaced
-1:000000000000 0:3ce708148e4d
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Sync state handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 
       
    21 #include "NSmlDMSyncState.h"
       
    22 #include "NSmlDMSyncUtil.h"
       
    23 
       
    24 // ============================ MEMBER FUNCTIONS ===============================
       
    25 
       
    26 // -----------------------------------------------------------------------------
       
    27 // NewL
       
    28 //
       
    29 // Two-phased constructor.
       
    30 // -----------------------------------------------------------------------------
       
    31 //
       
    32 CNSmlDMSyncState* CNSmlDMSyncState::NewL()
       
    33     {
       
    34     CNSmlDMSyncState* self = new(ELeave) CNSmlDMSyncState();
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL();
       
    37 	CleanupStack::Pop(self);
       
    38 	return self;
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // ~CNSmlDMSyncState
       
    43 //
       
    44 // Destructor.
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 CNSmlDMSyncState::~CNSmlDMSyncState()
       
    48     {
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CNSmlDMSyncState
       
    53 //
       
    54 // C++ default constructor can NOT contain any code, that
       
    55 // might leave.
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CNSmlDMSyncState::CNSmlDMSyncState()
       
    59     {
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // ConstructL
       
    64 //
       
    65 // Symbian 2nd phase constructor can leave.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 void CNSmlDMSyncState::ConstructL()
       
    69     {
       
    70 	Reset();
       
    71     }
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // Reset
       
    75 //
       
    76 // Resets all state variables.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void CNSmlDMSyncState::Reset()
       
    80     {
       
    81 	iSyncPhase = EPhaseNone;
       
    82     }
       
    83 
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // SetSyncPhase
       
    87 //
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CNSmlDMSyncState::SetSyncPhase(TInt aPhase)
       
    91 	{
       
    92 	iSyncPhase = aPhase;
       
    93 	}
       
    94 
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // SyncPhase
       
    98 //
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 TInt CNSmlDMSyncState::SyncPhase()
       
   102 	{
       
   103 	return iSyncPhase;
       
   104 	}
       
   105 
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // SetProgress
       
   109 //
       
   110 // -----------------------------------------------------------------------------
       
   111 //
       
   112 void CNSmlDMSyncState::SetProgress(TInt aCount)
       
   113 	{
       
   114 	iProgressCount = aCount;
       
   115 	}
       
   116 
       
   117 // -----------------------------------------------------------------------------
       
   118 // IncreaseProgress
       
   119 //
       
   120 // -----------------------------------------------------------------------------
       
   121 //
       
   122 void CNSmlDMSyncState::IncreaseProgress()
       
   123 	{
       
   124 	if (iProgressCount < iTotalProgressCount)
       
   125 		{
       
   126 		iProgressCount++;
       
   127 		}
       
   128 	}
       
   129 
       
   130 // -----------------------------------------------------------------------------
       
   131 // Progress
       
   132 //
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 TInt CNSmlDMSyncState::Progress()
       
   136 	{
       
   137 	return iProgressCount;
       
   138 	}
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // SetTotalProgress
       
   142 //
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 void CNSmlDMSyncState::SetTotalProgress(TInt aCount)
       
   146 	{
       
   147 	iTotalProgressCount = aCount;
       
   148 	}
       
   149 
       
   150 // -----------------------------------------------------------------------------
       
   151 // TotalProgress
       
   152 //
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 TInt CNSmlDMSyncState::TotalProgress()
       
   156 	{
       
   157 	return iTotalProgressCount;
       
   158 	}
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // SetContent
       
   162 //
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CNSmlDMSyncState::SetContent(const TDesC& aContent)
       
   166 	{
       
   167 	TUtil::StrCopy(iSyncContent, aContent);
       
   168 	}
       
   169 
       
   170 // -----------------------------------------------------------------------------
       
   171 // Content
       
   172 //
       
   173 // -----------------------------------------------------------------------------
       
   174 //
       
   175 const TDesC& CNSmlDMSyncState::Content()
       
   176 	{
       
   177 	return iSyncContent;
       
   178 	}
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // ResetProgress
       
   182 //
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 void CNSmlDMSyncState::ResetProgress()
       
   186 	{
       
   187 	iProgressCount = 0;
       
   188 	iTotalProgressCount = 0;
       
   189 	iSyncContent = KNullDesC;
       
   190 	}
       
   191 
       
   192 // -----------------------------------------------------------------------------
       
   193 // ProgressKnown
       
   194 //
       
   195 // -----------------------------------------------------------------------------
       
   196 //
       
   197 TBool CNSmlDMSyncState::ProgressKnown()
       
   198 	{
       
   199 	if (iTotalProgressCount == -1 )
       
   200 		{
       
   201 		return EFalse;
       
   202 		}
       
   203 
       
   204 	return ETrue;
       
   205 	}
       
   206 
       
   207