omads/omadsappui/AspSyncUtil/inc/AspProfile.h
branchRCL_3
changeset 25 4f0867e42d62
equal deleted inserted replaced
24:8e7494275d3a 25:4f0867e42d62
       
     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: Profile structure mapped to server side data sync profile 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef ASPPROFILE_H
       
    20 #define ASPPROFILE_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <ecom.h>
       
    25 #include <calsession.h>
       
    26 
       
    27 #include <SyncMLClient.h>    // for RSyncMLSession
       
    28 #include <SyncMLClientDS.h>  // for RSyncMLDataSyncProfile
       
    29 
       
    30 #include "AspDefines.h"
       
    31 #include "AspUtil.h"
       
    32 
       
    33 //For Error EAZG-7KGAK8. Language definiton not found in elang.h 
       
    34 const TInt ELangIndon_Apac=327;
       
    35 const TUid KCRUidDSDefaultProfileInternalKeys  = { 0x20021338 };
       
    36 const TInt KNsmlDsDefaultProfile = 0x0;
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 // Visibility settings for operator specific sync profiles on UI
       
    41 // - Normal = Profile shown without any specific formatting
       
    42 // - ReadOnly = Profile fields locked (non-editable), deletion not allowed
       
    43 // - Hidden = Profile not shown in UI
       
    44 enum TOperatorProfileVisibility
       
    45     {
       
    46     EProfileVisibilityNormal = 0,
       
    47     EProfileVisibilityReadOnly = 1,
       
    48     EProfileVisibilityHidden = 2
       
    49     };
       
    50 
       
    51 // FORWARD DECLARATIONS
       
    52 class CAspProfile;
       
    53 
       
    54 
       
    55 // CLASS DECLARATION
       
    56 
       
    57 
       
    58 
       
    59 /**
       
    60 * TAspProfileItem
       
    61 *
       
    62 * TAspProfileItem contains sync profile data.
       
    63 */
       
    64 NONSHARABLE_CLASS (TAspProfileItem)
       
    65 	{
       
    66 	public:
       
    67 		/**
       
    68 		* Get profile name.
       
    69 		* @param None.
       
    70         * @return Profile name.
       
    71         */
       
    72 		const TDesC& Name();
       
    73 
       
    74 		/**
       
    75 		* Get profile name.
       
    76 		* @param None.
       
    77         * @return Profile name.
       
    78         */
       
    79 		HBufC* NameLC();
       
    80 
       
    81 		/**
       
    82 		* Set profile name.
       
    83 		* @param aName.
       
    84         * @return None.
       
    85         */
       
    86 		void SetName(const TDesC& aName);
       
    87 		
       
    88 		/**
       
    89 		* Initalize object data.
       
    90 		* @param None.
       
    91         * @return None.
       
    92         */
       
    93 		void Init();
       
    94 
       
    95 	public:
       
    96 		/**
       
    97 		* Compare two profile items.
       
    98 		* @param aFirst.
       
    99 		* @param aSecond.		
       
   100         * @return Compare result.
       
   101         */
       
   102 		static TInt CompareItems(const TAspProfileItem& aFirst, const TAspProfileItem& aSecond);
       
   103 
       
   104 	public:
       
   105 		// profile name
       
   106 		TBuf<KBufSize> iProfileName;	
       
   107 		
       
   108 		// profile id 
       
   109 		TInt iProfileId;
       
   110 		
       
   111 		// is profile synced
       
   112 		TInt iSynced;
       
   113 		
       
   114 		// last sync time
       
   115 		TTime iLastSync;
       
   116 		
       
   117 		// bearer type
       
   118 		TInt iBearer;
       
   119 		
       
   120 		// is server alert sync activated
       
   121 		TInt iActive;
       
   122 		
       
   123 		// can profile be deleted
       
   124 		TBool iDeleteAllowed;
       
   125 		
       
   126 		// application id
       
   127 		TInt iApplicationId;
       
   128 
       
   129 		// is all mandatory data found 
       
   130 		TInt iMandatoryCheck;
       
   131 		
       
   132 		// number of sync tasks
       
   133 		TInt iTaskCount;
       
   134 		
       
   135 		// application specific sync task id
       
   136 		TInt iTaskId;
       
   137 		
       
   138 		// server id check sum
       
   139 		TUint16 iServerIdCheckSum;
       
   140 
       
   141 	};
       
   142 
       
   143 
       
   144 
       
   145 /**
       
   146 * TAspTaskItem
       
   147 * 
       
   148 * TAspTaskItem contains sync task data.
       
   149 */
       
   150 NONSHARABLE_CLASS (TAspTaskItem)
       
   151 	{
       
   152 	public:
       
   153 	    // task id
       
   154     	TInt  iTaskId;
       
   155     	
       
   156     	// sync direction
       
   157 		TInt  iSyncDirection;
       
   158 		
       
   159 		// is remote database defined
       
   160 		TBool iRemoteDatabaseDefined;
       
   161 		
       
   162 		// is local database defined
       
   163 		TBool iLocalDatabaseDefined;
       
   164 		
       
   165 		// is task included in sync
       
   166 		TBool iEnabled;
       
   167 		
       
   168 		// id of data provider that this task uses
       
   169 		TInt  iDataProviderId;
       
   170 		
       
   171 		// last sync time
       
   172 		TTime	 iLastSync;
       
   173 
       
   174 		// task display name
       
   175 	    TBuf<KBufSize> iDisplayName;
       
   176 	    TBuf<KBufSize> iClientDataSource;
       
   177     };
       
   178 
       
   179 
       
   180 /**
       
   181 * TAspDataProviderItem
       
   182 * 
       
   183 * TAspDataProviderItem contains data provider data.
       
   184 */
       
   185 NONSHARABLE_CLASS (TAspProviderItem)
       
   186 	{
       
   187     enum TProviderListSortOrder
       
   188 	    {
       
   189 	    EOrderContact = 4,
       
   190 	    EOrderCalendar = 3,
       
   191 	    EOrderNotes = 2,
       
   192 	    EOrderEmail = 1,
       
   193 	    EOrderOther = 0
       
   194     	};
       
   195 	
       
   196 	public:
       
   197 		/**
       
   198 		* Compare two profile items.
       
   199 		* @param aFirst.
       
   200 		* @param aSecond.		
       
   201         * @return Compare result.
       
   202         */
       
   203 		static TInt CompareItems(const TAspProviderItem& aFirst, const TAspProviderItem& aSecond);
       
   204 		static TInt SortOrder(TInt aDataProviderId);
       
   205 	
       
   206 	public:
       
   207 	    // data provider id
       
   208 		TInt  iDataProviderId;
       
   209 		
       
   210 		// can more than one database be synced 
       
   211 		TBool iAllowMultipleDataStores;
       
   212 		
       
   213 		// is default data store defined
       
   214 		TBool iHasDefaultDataStore;
       
   215 		
       
   216 		// sync protocol
       
   217 		TInt  iSyncProtocol;
       
   218 
       
   219         // id of sync task that is using this data provider
       
   220 		TBool iTaskId;
       
   221 		
       
   222 		// display name
       
   223 	    TBuf<KBufSize> iDisplayName;
       
   224 	    
       
   225 	   	// default data store name
       
   226 		TBuf<KBufSize> iDefaultDataStore;
       
   227 		
       
   228 		// is this provider included in sync (profile specific)
       
   229 		TBool iIsIncludedInSync;
       
   230 	};
       
   231 
       
   232 
       
   233 /**
       
   234 * TAspFilterInfo
       
   235 * 
       
   236 * TAspFilterInfo contains profile list filtering data.
       
   237 */
       
   238 NONSHARABLE_CLASS (TAspFilterInfo)
       
   239 	{
       
   240 	public:
       
   241 	enum TFilterType
       
   242 		{
       
   243 	    EIncludeDeletableProfile,
       
   244 	    EIncludeRemoteProfile
       
   245 		};
       
   246 
       
   247 	public:
       
   248 	    // filter type
       
   249 		TInt iFilterType;
       
   250 		
       
   251 		// filter id (eg. application id 
       
   252 		TBool iFilterId;
       
   253 		
       
   254 		// filter text
       
   255 		TBuf<KBufSize>  iFilterText;
       
   256 	};
       
   257 
       
   258 
       
   259 /**
       
   260 * CAspContentList 
       
   261 *
       
   262 * CAspContentList contains sync task list and data provider list.
       
   263 */
       
   264 NONSHARABLE_CLASS (CAspContentList): public CBase
       
   265     {
       
   266     public:
       
   267 
       
   268 	enum TListMode
       
   269 		{
       
   270 	    EInitDataProviders,
       
   271 	    EInitTasks,
       
   272 	    EInitAll
       
   273 		};
       
   274 
       
   275     public:
       
   276         /**
       
   277         * Two-phased constructor.
       
   278         */
       
   279         static CAspContentList* NewLC(const TAspParam& aParam);
       
   280 
       
   281         /**
       
   282         * Two-phased constructor.
       
   283         */
       
   284         static CAspContentList* NewL(const TAspParam& aParam);
       
   285 
       
   286 	    /**
       
   287         * Destructor.
       
   288         */
       
   289         virtual ~CAspContentList();
       
   290 
       
   291     private:
       
   292         /**
       
   293         * C++ default constructor.
       
   294         */
       
   295 	    CAspContentList(const TAspParam& aParam);
       
   296 
       
   297         /**
       
   298         * By default Symbian 2nd phase constructor is private.
       
   299         */
       
   300 	    void ConstructL();
       
   301 
       
   302 	public:
       
   303 		/**
       
   304 		* Sets sync profile.
       
   305 		* @param aProfile.
       
   306         * @return None.
       
   307         */
       
   308 		void SetProfile(CAspProfile* aProfile);
       
   309 		
       
   310 		/**
       
   311 		* Find out whether iProfile has been set.
       
   312 		* @param None.
       
   313         * @return TBool.
       
   314         */
       
   315 		TBool IsLocked();
       
   316 	
       
   317 		/**
       
   318 		* Returns data provider count.
       
   319 		* @param None.
       
   320         * @return Data provider count.
       
   321         */
       
   322 		TInt ProviderCount();
       
   323 
       
   324 		/**
       
   325 		* Returns Data provider.
       
   326         * @param aIndex List index.
       
   327 		* @return Data provider.
       
   328         */
       
   329 		TAspProviderItem& ProviderItem(TInt aIndex);
       
   330 		
       
   331 		/**
       
   332 		* Returns list index.
       
   333         * @param aId.
       
   334 		* @return List index.
       
   335         */
       
   336         TInt FindProviderIndex(TInt aId);		
       
   337 
       
   338 		/**
       
   339 		* Returns list index.
       
   340         * @param aId.
       
   341 		* @return List index.
       
   342         */
       
   343         TInt FindProviderIndexForTask(TInt aId);		
       
   344 
       
   345 		/**
       
   346 		* Returns task count.
       
   347         * @return Task count.
       
   348         */
       
   349 		TInt TaskCount();
       
   350 		
       
   351 		/**
       
   352 		* Returns task item.
       
   353         * @param aIndex.
       
   354 		* @return Task item.
       
   355         */
       
   356 		TAspTaskItem& TaskItem(TInt aIndex);
       
   357 		
       
   358 		/**
       
   359 		* Returns list index.
       
   360         * @param aId.
       
   361 		* @return List index.
       
   362         */
       
   363         TInt FindTaskIndex(TInt aId);		
       
   364 
       
   365 		/**
       
   366 		* Returns list index.
       
   367         * @param aId.
       
   368 		* @return List index.
       
   369         */
       
   370         TInt FindTaskIndexForProvider(TInt aId);		
       
   371 
       
   372 		/**
       
   373 		* Returns task id.
       
   374         * @param aId.
       
   375 		* @return Task id.
       
   376         */
       
   377         TInt FindTaskIdForProvider(TInt aId);		
       
   378 		
       
   379 		/**
       
   380 		* Checks that data provider has default local database.
       
   381 		* @param aDataProviderId.
       
   382 		* @return ETrue if database exists, EFalse otherwise.
       
   383         */
       
   384 		//TBool DefaultLocalDatabaseExist(TInt aDataProviderId);
       
   385 		
       
   386 		/**
       
   387 		* Checks that all content items are valid.
       
   388 		* @param aContentCount.
       
   389 		* @return Return code.
       
   390         */
       
   391 		TInt CheckMandatoryDataL(TInt& aContentCount);
       
   392         
       
   393 	public:
       
   394 
       
   395 		/**
       
   396 		* Read sync data providers from RSyncMLSession.
       
   397 		* @return None.
       
   398         */
       
   399 		void InitDataProvidersL();
       
   400 		
       
   401 		/**
       
   402 		* Read sync data providers from RSyncMLSession.
       
   403 		* @return None.
       
   404         */
       
   405 		void DoInitDataProvidersL();
       
   406 
       
   407 		/**
       
   408 		* Read all tasks from profile into task list.
       
   409 		* @return None.
       
   410         */
       
   411 		void InitAllTasksL();
       
   412 
       
   413 		/**
       
   414 		* Read one task from profile into task list.
       
   415 		* @return None.
       
   416         */
       
   417 		void InitTaskL(TInt aTaskId);
       
   418 		
       
   419 		/**
       
   420 		* Remove task that uses dataprovider aDataProviderId.
       
   421 		* @param aDataProviderId.
       
   422 		* @return None.
       
   423         */
       
   424 		void RemoveTask(TInt aDataProviderId);
       
   425 		
       
   426 		/**
       
   427 		* Remove all tasks from task list.
       
   428 		* @param None.
       
   429 		* @return None.
       
   430         */
       
   431 		void RemoveAllTasks();
       
   432 
       
   433 		/**
       
   434 		* Remove data provider with id aDataProviderId.
       
   435 		* @param aDataProviderId.
       
   436 		* @return None.
       
   437         */
       
   438 		void RemoveDataProvider(TInt aDataProviderId);
       
   439 
       
   440 		/**
       
   441 		* Read one task item from profile.
       
   442         * @param aProfile.
       
   443         * @param aTaskId.
       
   444 		* @return Task item.
       
   445         */
       
   446 		static TAspTaskItem ReadTaskItemL(RSyncMLDataSyncProfile& aProfile, TInt aTaskId);
       
   447 		
       
   448 		
       
   449 		TInt CreateTaskL(TAspProviderItem& aDataProvider);
       
   450         void CreateTaskL(TInt aDataProviderId, const TDesC& aLocalDatabase,
       
   451                          const TDesC& aRemoteDatabase, TBool aEnabled, TInt aSyncDirection);
       
   452         void CreateTask(TInt aDataProviderId, const TDesC& aLocalDatabase,
       
   453                          const TDesC& aRemoteDatabase, TBool aEnabled, TInt aSyncDirection);
       
   454 
       
   455 
       
   456         void ReadTaskL(TInt aDataProviderId, TDes& aLocalDatabase, TDes& aRemoteDatabase, TBool& aEnable, TInt& aSyncDirection);
       
   457 
       
   458  
       
   459 		void IncludeTaskL(TAspProviderItem& aDataProvider);
       
   460 		void IncludeTasks(const CArrayFix<TInt>* aIncludedProviderList);
       
   461 		
       
   462 		void ModifyTaskIncludedL(TInt aDataProviderId, TBool aIsIncluded, const TDesC& aLocalDatabase);
       
   463 		void ModifyTaskIncludedL(TAspProviderItem& aProvider, TBool aIsIncluded, const TDesC& aLocalDatabase);
       
   464 		void ModifyTaskDirectionL(TAspProviderItem& aProvider, TInt aDirection);
       
   465 		void ModifyTaskDirectionsL(TInt aSyncDirection);
       
   466 		TBool CheckTaskDirectionsL();
       
   467 		
       
   468 		void SetIncludedProviders(const CArrayFix<TInt>* aIncludedProviderList);
       
   469 		void GetIncludedProviders(CArrayFix<TInt>* aIncludedProviderList);
       
   470 		
       
   471 
       
   472 		
       
   473 		void GetLocalDatabaseList(TInt aDataProviderId, CDesCArray* aList);
       
   474 		void GetLocalDatabaseListL(TInt aDataProviderId, CDesCArray* aList);
       
   475 		void UpdateLocalDatabaseL();
       
   476 		TInt SyncDirection();
       
   477 		TSmlSyncType SmlSyncDirection();
       
   478 		TBool TaskEnabled(TInt aDataProviderId);
       
   479     	void Sort();
       
   480     	void UpdateDataProviderL(TInt aDataProviderId);
       
   481     	void ReadDataProviderItemL(RSyncMLDataProvider& aProvider, TAspProviderItem& aItem);
       
   482 
       
   483 
       
   484     	void CreateCalLocalDatabaseL(TDes& aCalName);
       
   485     	void RetrieveCalLocalDatabaseL(TDes& aCalName);
       
   486     	TBool IsCalNameAvailableL(CCalSession& aSession ,TDes& aCalName);
       
   487     	TBool IsValidClientDataSourceL( TDes& aCalName );
       
   488     	
       
   489 		
       
   490     private:
       
   491     
       
   492 		/**
       
   493 		* Utility function.
       
   494 		* @return Sync session.
       
   495         */
       
   496 		RSyncMLSession& Session();
       
   497 
       
   498 		/**
       
   499 		* Returns sync profile.
       
   500 		* @param None.
       
   501 		* @return Sync profile.
       
   502         */
       
   503 		RSyncMLDataSyncProfile* Profile();
       
   504 		
       
   505 		
       
   506 #ifdef _DEBUG
       
   507     public:
       
   508         void LogL(const TDesC& aText);
       
   509     private:
       
   510     
       
   511         void LogTasksL();
       
   512         void LogDataProvidersL();
       
   513         void GetTaskLogText(TDes& aText, TAspTaskItem& aTask);
       
   514         void GetDataProviderIdText(TDes& aText, TInt aId);
       
   515 #endif
       
   516 		
       
   517 
       
   518 
       
   519     private:
       
   520 		// id of the calling application
       
   521 		TInt iApplicationId;
       
   522     
       
   523 		// sync session
       
   524 		RSyncMLSession* iSyncSession;
       
   525 		
       
   526 		// sync profile
       
   527 		CAspProfile* iProfile;
       
   528 
       
   529 		// sync list type
       
   530 		TInt iListMode;
       
   531         
       
   532 		// data provider list
       
   533 		RArray<TAspTaskItem> iTaskList;
       
   534 
       
   535 		// data provider id list
       
   536 		RArray<TAspProviderItem> iProviderList;
       
   537     };
       
   538 
       
   539 
       
   540 
       
   541 /**
       
   542 * CAspProfileList 
       
   543 *
       
   544 * CAspProfileList is a list of sync profiles,
       
   545 */
       
   546 NONSHARABLE_CLASS (CAspProfileList) : public CBase
       
   547     {
       
   548     public:
       
   549 
       
   550 	enum TListMode
       
   551 		{
       
   552 	    EBasePropertiesOnly,
       
   553 	    ENoMandatoryCheck,
       
   554 	    EMandatoryCheck,
       
   555 	    EMandatoryCheckEx,
       
   556 	    EEMailRetrieve,
       
   557 	    EEMailSync,
       
   558 		};
       
   559 
       
   560     public:
       
   561         /**
       
   562         * Two-phased constructor.
       
   563         */
       
   564         static CAspProfileList* NewLC(const TAspParam& aParam);
       
   565 
       
   566         /**
       
   567         * Two-phased constructor.
       
   568         */
       
   569         static CAspProfileList* NewL(const TAspParam& aParam);
       
   570 
       
   571 	    /**
       
   572         * Destructor.
       
   573         */
       
   574         virtual ~CAspProfileList();
       
   575 
       
   576     private:
       
   577         /**
       
   578         * C++ default constructor.
       
   579         */
       
   580 	    CAspProfileList(const TAspParam& aParam);
       
   581 
       
   582         /**
       
   583         * By default Symbian 2nd phase constructor is private.
       
   584         */
       
   585 	    void ConstructL();
       
   586 
       
   587 	public:
       
   588 		/**
       
   589 		* Returns profile count.
       
   590         * @param None.
       
   591         * @return Profile count.
       
   592         */
       
   593 		TInt Count();
       
   594 
       
   595 		/**
       
   596 		* Returns profile count.
       
   597         * @param aApplicationId.
       
   598         * @return Profile count.
       
   599         */
       
   600 		TInt Count(TInt aApplicationId);
       
   601 
       
   602 		/**
       
   603 		* Returns profile from list.
       
   604         * @param aIndex List index.
       
   605 		* @return Profile.
       
   606         */
       
   607 		TAspProfileItem& Item(TInt aIndex);
       
   608 
       
   609 		/**
       
   610 		* Finds profile with name aProfileName.
       
   611 		* @param aProfileName Profile name.
       
   612 		* @return Profile index or KErrNotFound.
       
   613         */
       
   614 		TInt FindProfileIndex(const TDesC& aProfileName);
       
   615 		
       
   616 		/**
       
   617 		* Gets the Default Profile ID from the Cenrep
       
   618 		* @param aValue ProfileID read from the Cenrep
       
   619      */
       
   620 		void GetDefaultProfileIdL(TInt& aValue);
       
   621 		
       
   622 		/**
       
   623 		* Finds last synced profile index.
       
   624 		* @param aProfileName Profile name.
       
   625 		* @return Profile index or KErrNotFound.
       
   626         */
       
   627 		TInt FindLastSyncedProfileIndexL();
       
   628 		
       
   629 		/**
       
   630 		* Read one profile from database.
       
   631 		* @param aProfile.
       
   632 		* @param aItem.
       
   633 		* @return None.
       
   634         */
       
   635         void ReadProfileItemL(CAspProfile* aProfile, TAspProfileItem& aItem);
       
   636 
       
   637 		/**
       
   638 		* Reads all profiles from database.
       
   639 		* @param aListMode.
       
   640 		* @return None.
       
   641         */
       
   642 		void ReadAllProfilesL(TInt aListMode);
       
   643 		
       
   644 		/**
       
   645 		* Reads all profiles that contain EMail task that uses aLocalDatabase.
       
   646 		* @param aLocalDatabase.
       
   647 		* @param aListMode.
       
   648 		* @return None.
       
   649         */
       
   650 		void ReadEMailProfilesL(const TDesC& aLocalDatabase,  TInt aListMode);
       
   651 
       
   652 		/**
       
   653 		* Reads one profile from database.
       
   654 		* @param aProfileId.
       
   655 		* @return None.
       
   656         */
       
   657 		void ReadProfileL(TInt aProfileId);
       
   658 
       
   659 		/**
       
   660 		* Sorts profile list.
       
   661 		* @param None.
       
   662 		* @return None.
       
   663         */
       
   664     	void Sort();
       
   665 
       
   666 		/**
       
   667 		* Removes profile from profile list.
       
   668 		* @param aProfileId.
       
   669 		* @return None.
       
   670         */
       
   671 		void Remove(TInt aProfileId);
       
   672 		
       
   673 		/**
       
   674 		* Adds profile into profile list.
       
   675 		* @param aProfileItem.
       
   676 		* @return None.
       
   677         */
       
   678 		void AddL(TAspProfileItem& aProfileItem);
       
   679 		
       
   680 		/**
       
   681 		* Constructs filtered profile list.
       
   682 		* @param aFilterInfo.
       
   683 		* @return Profile list.
       
   684         */
       
   685 		CAspProfileList* FilteredListL(TAspFilterInfo& aFilterInfo);
       
   686 
       
   687 		/**
       
   688 		* Replaces profile item.
       
   689 		* @param aProfileItem.
       
   690 		* @return None.
       
   691         */
       
   692 		void ReplaceProfileItemL(TAspProfileItem& aProfileItem);
       
   693 
       
   694 		/**
       
   695 		* Returns profile's list position.
       
   696 		* @param aProfileId.
       
   697 		* @return List index.
       
   698         */
       
   699 		TInt ListIndex(TInt aProfileId);
       
   700 		
       
   701 		/**
       
   702 		* Returns sync session.
       
   703 		* @param None.
       
   704 		* @return Sync session.
       
   705         */
       
   706 		RSyncMLSession& Session();
       
   707 		
       
   708 		/**
       
   709 		* Returns number of profiles that can be deleted.
       
   710 		* @param None.
       
   711 		* @return Profile count.
       
   712         */
       
   713 		TInt DeletableProfileCount();
       
   714 		
       
   715 		TBool IsAutoSyncProfile(CAspProfile* aProfile);
       
   716 		
       
   717 	public:
       
   718                              
       
   719 		/**
       
   720 		* Checks if aServerId is unique in setting databse.
       
   721 		* @param aServerId.
       
   722 		* @param aProfileId.
       
   723 		* @return Return code.
       
   724         */
       
   725         TBool IsUniqueServerId(const TDesC& aServerId, TInt aProfileId);                             
       
   726 
       
   727 		
       
   728 
       
   729 	private:
       
   730    		// sync session
       
   731 		RSyncMLSession* iSyncSession;
       
   732         
       
   733 		// list of profiles
       
   734 		RArray<TAspProfileItem> iList;
       
   735 
       
   736 		// needed for filtering unwanted profiles
       
   737 		TInt iApplicationId;
       
   738 		
       
   739 		// long buffer for string handling 
       
   740 		TBuf<KBufSize255> iBuf;
       
   741     };
       
   742 
       
   743 
       
   744 
       
   745 /**
       
   746 * CAspProfile 
       
   747 *
       
   748 * CAspProfile is used for getting/setting sync profile settings.
       
   749 */
       
   750 NONSHARABLE_CLASS (CAspProfile) : public CBase
       
   751     {
       
   752     
       
   753     public:
       
   754 	enum TOpenMode
       
   755 		{
       
   756 	    EOpenReadWrite,
       
   757 	    EOpenRead,
       
   758 	    EBaseProperties,
       
   759 	    EAllProperties
       
   760 		};
       
   761 
       
   762     public:
       
   763         /**
       
   764         * Two-phased constructor.
       
   765         */
       
   766         static CAspProfile* NewLC(const TAspParam& aParam);
       
   767 
       
   768         /**
       
   769         * Two-phased constructor.
       
   770         */
       
   771         static CAspProfile* NewL(const TAspParam& aParam);
       
   772 
       
   773 	    /**
       
   774         * Destructor.
       
   775         */
       
   776         virtual ~CAspProfile();
       
   777 
       
   778     private:
       
   779         /**
       
   780         * C++ default constructor.
       
   781         */
       
   782 	    CAspProfile(const TAspParam& aParam);
       
   783 
       
   784         /**
       
   785         * By default Symbian 2nd phase constructor is private.
       
   786         */
       
   787 	    void ConstructL();
       
   788 	    
       
   789     public:
       
   790 		/**
       
   791 		* Open profile.
       
   792 		* @param aProfileId.
       
   793 		* @param aReadWrite.
       
   794 		* @param aOpenMode.
       
   795 		* @return None.
       
   796         */
       
   797         void OpenL(TInt aProfileId, TInt aReadWrite, TInt aOpenMode);
       
   798         
       
   799 		/**
       
   800 		* Create profile.
       
   801 		* @param aOpenMode.
       
   802 		* @return None.
       
   803         */
       
   804         void CreateL(TInt aOpenMode);
       
   805 
       
   806 		/**
       
   807 		* Create copy profile.
       
   808 		* @param aProfileId.
       
   809 		* @return None.
       
   810         */
       
   811         void CreateCopyL(TInt aProfileId);
       
   812         
       
   813 		/**
       
   814 		* Save profile.
       
   815 		* @param None.
       
   816 		* @return None.
       
   817         */
       
   818         void SaveL();
       
   819         
       
   820 		/**
       
   821 		* Save profile.
       
   822 		* @param None.
       
   823 		* @return None.
       
   824         */
       
   825         void Save();
       
   826 
       
   827 	public:
       
   828 		/**
       
   829 		* Set profile name.
       
   830 		* @param aText.
       
   831 		* @return None.
       
   832         */
       
   833         void SetNameL(const TDesC& aText);
       
   834 
       
   835 		/**
       
   836 		* Get profile name.
       
   837 		* @param aText.
       
   838 		* @return None.
       
   839         */
       
   840         void GetName(TDes& aText);
       
   841 
       
   842 		/**
       
   843 		* Get profile name.
       
   844 		* @param None.
       
   845 		* @return Profile name.
       
   846         */
       
   847         HBufC* NameL();
       
   848         
       
   849 		/**
       
   850 		* Set creator id.
       
   851 		* @param aCreatorId.
       
   852 		* @return None.
       
   853         */
       
   854         void SetCreatorId(TInt aCreatorId);
       
   855         
       
   856 		/**
       
   857 		* Get creator id.
       
   858 		* @param None.
       
   859 		* @return Creator id.
       
   860         */
       
   861         TInt CreatorId();
       
   862         
       
   863 		/**
       
   864 		* Get profile id.
       
   865 		* @param None.
       
   866 		* @return Profile id.
       
   867         */
       
   868         TInt ProfileId();
       
   869         
       
   870 		/**
       
   871 		* Can profile be deleted.
       
   872 		* @param None.
       
   873 		* @return Boolean.
       
   874         */
       
   875         TBool DeleteAllowed();
       
   876 
       
   877 		/**
       
   878 		* Has profile been synced.
       
   879 		* @param None.
       
   880 		* @return Boolean.
       
   881         */
       
   882 		TBool IsSynced();
       
   883 
       
   884 		/**
       
   885 		* Last sync time.
       
   886 		* @param None.
       
   887 		* @return Sync time.
       
   888         */
       
   889 		TTime LastSync();
       
   890     
       
   891 		/**
       
   892 		* Last sync time.
       
   893 		* @param aTaskId.
       
   894 		* @return Sync time.
       
   895         */
       
   896 		TTime LastSync(TInt aTaskId);
       
   897 
       
   898     
       
   899     // settings that connection dialog displays
       
   900     public:
       
   901 		/**
       
   902 		* Set server id.
       
   903 		* @param aText.
       
   904 		* @return None.
       
   905         */
       
   906         void SetServerIdL(const TDesC& aText);
       
   907 
       
   908 		/**
       
   909 		* Get server id.
       
   910 		* @param aText.
       
   911 		* @return None.
       
   912         */
       
   913         void GetServerId(TDes& aText);
       
   914 
       
   915 		/**
       
   916 		* Get protocol version.
       
   917 		* @param None.
       
   918 		* @return aProtocolVersion.
       
   919         */
       
   920         TInt ProtocolVersion();
       
   921 
       
   922 		/**
       
   923 		* Set protocol version.
       
   924 		* @param aProtocolVersion.
       
   925 		* @return None.
       
   926         */
       
   927         void SetProtocolVersionL(TInt aProtocolVersion);
       
   928 
       
   929 		/**
       
   930 		* Get bearer type.
       
   931 		* @param None.
       
   932 		* @return Bearer type.
       
   933         */
       
   934         TInt BearerType();
       
   935         
       
   936 		/**
       
   937 		* Set bearer type.
       
   938 		* @param aId.
       
   939 		* @return None.
       
   940         */
       
   941         void SetBearerTypeL(TInt aId);
       
   942 
       
   943 		/**
       
   944 		* Get access point.
       
   945 		* @param None.
       
   946 		* @return Access point.
       
   947         */
       
   948         TInt AccessPointL();
       
   949         
       
   950 		/**
       
   951 		* Set access point.
       
   952 		* @param aId.
       
   953 		* @return None.
       
   954         */
       
   955         void SetAccessPointL(const TInt aId);
       
   956 
       
   957 		/**
       
   958 		* Get host address.
       
   959 		* @param aText.
       
   960 		* @param aPort.		
       
   961 		* @return None.
       
   962         */
       
   963         void GetHostAddress(TDes& aText, TInt& aPort);
       
   964 
       
   965 		/**
       
   966 		* Set host address.
       
   967 		* @param aText.
       
   968 		* @param aPort.		
       
   969 		* @return None.
       
   970         */
       
   971         void SetHostAddressL(const TDesC& aText, const TInt aPort);
       
   972          
       
   973 		/**
       
   974 		* Get user name.
       
   975 		* @param aText.
       
   976 		* @return None.
       
   977         */
       
   978         void GetUserName(TDes& aText);
       
   979 
       
   980 		/**
       
   981 		* Set user name.
       
   982 		* @param aText.
       
   983 		* @return None.
       
   984         */
       
   985         void SetUserNameL(const TDesC& aText);
       
   986         
       
   987 		/**
       
   988 		* Get password.
       
   989 		* @param aText.
       
   990 		* @return None.
       
   991         */
       
   992         void GetPassword(TDes& aText);
       
   993 
       
   994 		/**
       
   995 		* Set password.
       
   996 		* @param aText.
       
   997 		* @return None.
       
   998         */
       
   999         void SetPasswordL(const TDesC& aText);
       
  1000         
       
  1001 		/**
       
  1002 		* Set server alert sync state.
       
  1003 		* @param aState.
       
  1004 		* @return None.
       
  1005         */
       
  1006         void SetSASyncStateL(TInt aState);
       
  1007 
       
  1008 		/**
       
  1009 		* Get server alert sync state.
       
  1010 		* @param None.
       
  1011 		* @return Server alert sync state.
       
  1012         */
       
  1013         TInt SASyncState();
       
  1014 
       
  1015 		/**
       
  1016 		* Set http authentication state.
       
  1017 		* @param aEnable.
       
  1018 		* @return None.
       
  1019         */
       
  1020         void SetHttpUsedL(TBool aEnable);
       
  1021 
       
  1022 		/**
       
  1023 		* Get http authentication state.
       
  1024 		* @param aEnable.
       
  1025 		* @return Boolean.
       
  1026         */
       
  1027         TBool HttpUsedL();
       
  1028          
       
  1029 		/**
       
  1030 		* Get http user name.
       
  1031 		* @param aText.
       
  1032 		* @return None.
       
  1033         */
       
  1034         void GetHttpUserNameL(TDes& aText);
       
  1035 
       
  1036 		/**
       
  1037 		* Set http user name.
       
  1038 		* @param aText.
       
  1039 		* @return None.
       
  1040         */
       
  1041         void SetHttpUserNameL(const TDesC& aText);
       
  1042  
       
  1043 		/**
       
  1044 		* Get http password.
       
  1045 		* @param aText.
       
  1046 		* @return None.
       
  1047         */
       
  1048         void GetHttpPasswordL(TDes& aText);
       
  1049         
       
  1050 		/**
       
  1051 		* Set http password.
       
  1052 		* @param aText.
       
  1053 		* @return None.
       
  1054         */
       
  1055         void SetHttpPasswordL(const TDesC& aText);
       
  1056  
       
  1057                
       
  1058     public:
       
  1059   		/**
       
  1060 		* Open history log.
       
  1061 		* @param None.
       
  1062 		* @return None.
       
  1063         */
       
  1064         void OpenHistoryLog();
       
  1065         
       
  1066   		/**
       
  1067 		* Open connection.
       
  1068 		* @param None.
       
  1069 		* @return None.
       
  1070         */
       
  1071         void OpenConnection();
       
  1072 
       
  1073   		/**
       
  1074 		* Get RSyncMLDataSyncProfile.
       
  1075 		* @param None.
       
  1076 		* @return RSyncMLDataSyncProfile.
       
  1077         */
       
  1078         RSyncMLDataSyncProfile& Profile();
       
  1079         
       
  1080   		/**
       
  1081 		* Get RSyncMLSession.
       
  1082 		* @param None.
       
  1083 		* @return RSyncMLSession.
       
  1084         */
       
  1085         RSyncMLSession& Session();
       
  1086         
       
  1087   		/**
       
  1088 		* Get application id.
       
  1089 		* @param None.
       
  1090 		* @return Application id.
       
  1091         */
       
  1092         TInt ApplicationId();
       
  1093         
       
  1094     public:
       
  1095   		/**
       
  1096 		* Get connection property name.
       
  1097 		* @param aText.
       
  1098 		* @param aPropertyPos.
       
  1099 		* @return None.
       
  1100         */
       
  1101         void GetConnectionPropertyNameL(TDes8& aText, TInt aPropertyPos);
       
  1102 
       
  1103   		/**
       
  1104 		* Get sync type.
       
  1105 		* @param aSyncTask.
       
  1106 		* @return Sync type.
       
  1107         */
       
  1108         static TInt SyncType(RSyncMLTask& aSyncTask);
       
  1109 
       
  1110   		/**
       
  1111 		* Set default bearer.
       
  1112 		* @param None.
       
  1113 		* @return None.
       
  1114         */
       
  1115         void SetDefaultBearerL();
       
  1116         
       
  1117   		/**
       
  1118 		* Get latest history job.
       
  1119 		* @param None.
       
  1120 		* @return History job.
       
  1121         */
       
  1122         const CSyncMLHistoryJob* LatestHistoryJob();
       
  1123         
       
  1124   		/**
       
  1125 		* Get latest history job.
       
  1126 		* @param aTaskId.
       
  1127 		* @return History job.
       
  1128         */
       
  1129         const CSyncMLHistoryJob* LatestHistoryJob(TInt aTaskId);
       
  1130 
       
  1131  		/**
       
  1132 		* Find out whether history job contains a task.
       
  1133 		* @param aHistoryJob.
       
  1134 		* @return Boolean.
       
  1135         */
       
  1136         TBool TaskExist(const CSyncMLHistoryJob* aHistoryJob, TInt aTaskId);
       
  1137         
       
  1138   		/**
       
  1139 		* Copy values from another profile.
       
  1140 		* @param aSource.
       
  1141 		* @return None.
       
  1142         */
       
  1143         void CopyValuesL(CAspProfile* aSource);
       
  1144         
       
  1145   		/**
       
  1146 		* Get default transport id.
       
  1147 		* @param None.
       
  1148 		* @return Transport id.
       
  1149         */
       
  1150         TInt DefaultTransportIdL();
       
  1151         
       
  1152   		/**
       
  1153 		* Delete all connections.
       
  1154 		* @param aId.
       
  1155 		* @return None.
       
  1156         */
       
  1157         //void DeleteConnectionsL();
       
  1158         
       
  1159     public:
       
  1160   		/**
       
  1161 		* Get new profile name.
       
  1162 		* @param aList.
       
  1163 		* @param aApplicationId.
       
  1164 		* @return Profile name.
       
  1165         */
       
  1166         static HBufC* GetNewProfileNameLC(CAspProfileList* aList, TInt aApplicationId);
       
  1167         
       
  1168   		/**
       
  1169 		* Set default values.
       
  1170 		* @param aProfile.
       
  1171 		* @return None.
       
  1172         */
       
  1173         static void SetDefaultValuesL(CAspProfile* aProfile);
       
  1174         
       
  1175   		/**
       
  1176 		* Is other sync running.
       
  1177 		* @param aSyncSession.
       
  1178 		* @return Boolean.
       
  1179         */
       
  1180         static TBool OtherSyncRunning(RSyncMLSession* aSyncSession);
       
  1181 
       
  1182   		/**
       
  1183 		* Get current sync job.
       
  1184 		* @param aSyncSession.
       
  1185 		* @return Sync job.
       
  1186         */
       
  1187         static TInt CurrentJob(RSyncMLSession* aSyncSession);
       
  1188         
       
  1189   		/**
       
  1190 		* Is this profile PCSuite profile.
       
  1191 		* @param aProfile.
       
  1192 		* @return Boolean.
       
  1193         */
       
  1194         static TBool IsPCSuiteProfile(CAspProfile* aProfile);
       
  1195         
       
  1196         /**
       
  1197         * Is this profile Operator specific profile.
       
  1198         * @param aProfile.
       
  1199         * @return Boolean.
       
  1200         */
       
  1201         static TBool IsOperatorProfileL(CAspProfile* aProfile);
       
  1202         
       
  1203         /**
       
  1204         * Get Operator adapter Uid.
       
  1205         * @return Operator adapter Uid .
       
  1206         */
       
  1207         static TInt OperatorAdapterUidL();  
       
  1208         
       
  1209         /**
       
  1210         * Get Profile adapter Uid.
       
  1211         * @return Profile adapter Uid .
       
  1212         */
       
  1213         static TInt ProfileAdapterUidL();
       
  1214 
       
  1215         /**
       
  1216         * Get Operator profile visibility setting. 
       
  1217         * @return Visibility setting value.
       
  1218         */
       
  1219         static TInt ProfileVisibilityL();
       
  1220 
       
  1221         
       
  1222         /**
       
  1223         * Is this profile read-only operator specific profile.
       
  1224         * @return Boolean.
       
  1225         */
       
  1226         TBool IsReadOnlyOperatorProfileL();
       
  1227         
       
  1228         /**
       
  1229         * Is this profile hidden operator specific profile.
       
  1230         * @return Boolean.
       
  1231         */
       
  1232         TBool IsHiddenOperatorProfileL();
       
  1233 
       
  1234         /**
       
  1235          * Does the given serverID equal with the operator specific
       
  1236          * serverID value (defined in central repository).
       
  1237          * @param aServerId to be compared
       
  1238          * @return Boolean
       
  1239          */
       
  1240         static TBool EqualsToOperatorServerId( const TDesC& aServerId );
       
  1241 
       
  1242     public:
       
  1243   		/**
       
  1244 		* Check mandatory task data.
       
  1245 		* @param aProfile.
       
  1246 		* @param aContentCount.
       
  1247 		* @return Mandatory data status code.
       
  1248         */
       
  1249         static TInt CheckMandatoryTaskDataL(CAspProfile* aProfile, TInt& aContentCount);
       
  1250  
       
  1251   		/**
       
  1252 		* Check mandatory task data.
       
  1253 		* @param aProfile.
       
  1254 		* @param aContentCount.
       
  1255 		* @return Mandatory data status code.
       
  1256         */
       
  1257         static TInt CheckMandatoryTaskData(CAspProfile* aProfile, TInt& aContentCount);
       
  1258         
       
  1259  		/**
       
  1260 		* Check mandatory data.
       
  1261 		* @param aProfile.
       
  1262 		* @param aContentCount.
       
  1263 		* @return Mandatory data status code.
       
  1264         */
       
  1265         static TInt CheckMandatoryData(CAspProfile* aProfile, TInt& aContentCount);
       
  1266  
       
  1267   		/**
       
  1268 		* Check mandatory connection data.
       
  1269 		* @param aProfile.
       
  1270 		* @return Mandatory data status code.
       
  1271         */
       
  1272         static TInt CheckMandatoryConnData(CAspProfile* aProfile);
       
  1273     
       
  1274     	/**
       
  1275 		* Delete sync history for a profile
       
  1276 		* @param None
       
  1277 		* @return None
       
  1278         */
       
  1279  		void DeleteHistory();
       
  1280  	public:
       
  1281 	    // -----------------------------------------------------------------------------
       
  1282 		// CAspProfile::GetLocalisedPCSuite
       
  1283 		//
       
  1284 		// Returns "PC Suite" string localised to specific language
       
  1285 		// 
       
  1286 		// Current requirement is to localise to 2 languages TaiwanChinese and ELangHongKongChinese
       
  1287 		// For all the rest it will be mapped to "PC suite" only
       
  1288 		// -----------------------------------------------------------------------------
       
  1289 		//
       
  1290 	    void GetLocalisedPCSuite(TDes& aText);
       
  1291        
       
  1292     //public:
       
  1293         //HBufC* HistoryJobsLC();
       
  1294 
       
  1295 	private:
       
  1296         // historylog open state
       
  1297         TBool iHistoryLogOpen;
       
  1298         
       
  1299         // connection open state
       
  1300         TBool iConnectionOpen;
       
  1301           
       
  1302    		// needed for setting creator id
       
  1303 		TInt iApplicationId;
       
  1304 		
       
  1305 		// long buffer for string handling 
       
  1306 		TBuf<KBufSize255> iBuf;
       
  1307 		
       
  1308 		// long buffer for string handling 
       
  1309 		TBuf8<KBufSize255> iBuf8;
       
  1310 
       
  1311    		// sync session
       
  1312 		RSyncMLSession* iSyncSession;
       
  1313 		
       
  1314 		// sync profile
       
  1315 		RSyncMLDataSyncProfile iProfile;
       
  1316 		
       
  1317 		// history log
       
  1318 		RSyncMLHistoryLog iHistoryLog;
       
  1319 				
       
  1320 		// sync connection
       
  1321 		RSyncMLConnection iConnection;
       
  1322     };
       
  1323 
       
  1324 
       
  1325 /**
       
  1326 * CAspTask
       
  1327 *
       
  1328 * TAspTask is used for sync task operations.
       
  1329 */
       
  1330 NONSHARABLE_CLASS (TAspTask) : public CBase
       
  1331     {
       
  1332     public:
       
  1333 		static TInt SyncDirection(TSmlSyncType aSmlSyncDirection);
       
  1334 		static TSmlSyncType SmlSyncDirection(TInt aSyncDirection);
       
  1335         static TInt FindTaskIdL(CAspProfile* aProfile, TInt aDataProviderId, const TDesC& aLocalDatabase);
       
  1336         static TBool CheckLocalDatabaseL(CAspProfile* aProfile, TInt& aDataProviderId);
       
  1337         static TBool CheckLocalDatabase(CAspProfile* aProfile, TInt& aDataProviderId);
       
  1338     };
       
  1339 
       
  1340 
       
  1341 
       
  1342 
       
  1343 
       
  1344 
       
  1345 
       
  1346 #endif  // ASPPROFILE_H
       
  1347 
       
  1348 
       
  1349 // End of file