pimprotocols/phonebooksync/plugin/phbksyncplugin.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Contains the Phonebook Synchroniser Plug-in implementation. 
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32base.h>
       
    19 #include <cntdb.h>
       
    20 #include <cntitem.h>
       
    21 #include <cntdef.h>
       
    22 #include <ecom/implementationproxy.h>
       
    23 
       
    24 #include "phbksyncplugin.h"
       
    25 #include "phbksynclog.h"
       
    26 #include "SyncContactICCEntry.h"
       
    27 #include "PhonebookManager.h"
       
    28 #include "SyncEngineServer.h"
       
    29 
       
    30 
       
    31 
       
    32 /** 
       
    33  *  Validate the contact data specified by aId can be read, edited or searched. 
       
    34  * 
       
    35  *  @param aOp  Validate operation requested (read/edit/search)
       
    36  *  @param aId  Contact item ID
       
    37  */
       
    38 TInt CPhoneBookSyncPlugin::ValidateContact(TValidateOperation aOp, TContactItemId aId)
       
    39 	{
       
    40 	LOGPLUGIN3(_L8("ValidateContact(%d, 0x%08x)"), aOp, aId);
       
    41 
       
    42 #ifdef SYMBIAN_CNTMODEL_V2
       
    43 	return iSession.ValidateContact(aOp, aId);
       
    44 #else
       
    45 	if (!iInServerThread)
       
    46 		{
       
    47 		return iSession.ValidateContact(aOp, aId);
       
    48 		}
       
    49 	else
       
    50 		{
       
    51 		return KErrNone;
       
    52 		}
       
    53 #endif // SYMBIAN_CNTMODEL_V2
       
    54 	} // CPhoneBookSyncPlugin::ValidateContact
       
    55 
       
    56 
       
    57 /** 
       
    58  *  Write the contact data specified by aContactItem to the ICC. The slot 
       
    59  *  number used to write the data is specified by the KUidContactFieldICCSlot
       
    60  *  field. Similarly the phonebook Uid is specified by the KUidContactFieldICCPhonebook 
       
    61  *  field. 
       
    62  * 
       
    63  *  @param aContactItem  Contact item to write.
       
    64  *
       
    65  *  @return KErrNone if write to ICC was successful, otherwise return error
       
    66  */
       
    67 TInt CPhoneBookSyncPlugin::ValidateWriteContact(CContactICCEntry& aContactItem)
       
    68 	{
       
    69 	LOGPLUGIN1(_L8("ValidateWriteContact()"));
       
    70 
       
    71 #ifndef SYMBIAN_CNTMODEL_V2
       
    72 	if (!iInServerThread)
       
    73 		{
       
    74 #endif // SYMBIAN_CNTMODEL_V2
       
    75 
       
    76 	TRequestStatus status(0);
       
    77 	TInt slotNum = ICCSlotNumber(aContactItem);
       
    78 
       
    79 	TUid phonebookUid(TUid::Null()); // First check whether phonebook field is supplied
       
    80 	TRAPD(error, phonebookUid = ICCPhonebookL(aContactItem)); 
       
    81 	if (error != KErrNone)
       
    82 		{
       
    83 		return error; 
       
    84 		}
       
    85 
       
    86 	TBuf<KTemplateFieldLength> buf;
       
    87 
       
    88 	if (phonebookUid == KUidIccPhonebookNotSpecified) // phonebook field not set within aContactItem 
       
    89 		{
       
    90 		iSession.WriteContact(status, aContactItem, slotNum);
       
    91 		}
       
    92 	else
       
    93 		{
       
    94 		iSession.WriteContact(status, aContactItem, slotNum, phonebookUid);
       
    95 		}
       
    96 	User::WaitForRequest(status);
       
    97 	TInt ret(status.Int());
       
    98 
       
    99 	if (ret == KErrNone)
       
   100 		{
       
   101 		// Server has added slot number, so add it to aContactItem
       
   102 		buf.Zero();
       
   103 		buf.AppendNum(slotNum);
       
   104 		TRAP(ret, AddFieldValueL(aContactItem, KUidContactFieldICCSlot, buf));
       
   105 		if(phonebookUid != KUidIccPhonebookNotSpecified) 
       
   106 		// Server has added phonebook Uid, so add it to aContactItem
       
   107 			{
       
   108 			buf.Zero();
       
   109 			buf.AppendNum(TUint(phonebookUid.iUid)); // Append integer part of UID as actual field value
       
   110 			TRAP(ret, AddFieldValueL(aContactItem, KUidContactFieldICCPhonebook, buf));
       
   111 			}
       
   112 		}
       
   113 
       
   114 	return ret;
       
   115 
       
   116 #ifndef SYMBIAN_CNTMODEL_V2
       
   117 		}
       
   118 	else
       
   119 		{
       
   120 		return KErrNone;
       
   121 		}
       
   122 #endif // SYMBIAN_CNTMODEL_V2
       
   123 	} // CPhoneBookSyncPlugin::ValidateWriteContact
       
   124 
       
   125 
       
   126 /** 
       
   127  *  Delete the contact data from the ICC at the slot number specified 
       
   128  *  in the CContactICCEntry item ID specified.
       
   129  * 
       
   130  *  @param aId  Contact Item ID
       
   131  *
       
   132  *  @return KErrNone if ICC deletion was successful, otherwise return error
       
   133  */
       
   134 TInt CPhoneBookSyncPlugin::DeleteContact(TContactItemId aId)
       
   135 	{
       
   136 	LOGPLUGIN2(_L8("DeleteContact(0x%08x)"), aId);
       
   137 	
       
   138 #ifndef SYMBIAN_CNTMODEL_V2
       
   139 	if (!iInServerThread)
       
   140 		{
       
   141 #endif // SYMBIAN_CNTMODEL_V2
       
   142 
       
   143 	TRequestStatus status;
       
   144 	iSession.DeleteContact(status, aId);
       
   145 	User::WaitForRequest(status);
       
   146 	return status.Int();
       
   147 
       
   148 #ifndef SYMBIAN_CNTMODEL_V2
       
   149 		}
       
   150 	else
       
   151 		{
       
   152 		return KErrNone;
       
   153 		}
       
   154 #endif // SYMBIAN_CNTMODEL_V2
       
   155 	} // CPhoneBookSyncPlugin::DeleteContact
       
   156 
       
   157 
       
   158 /** 
       
   159  *  Release any resources allocated by the plug-in and delete itself.
       
   160  * 
       
   161  *  This method is called by the destructor of Contact model's 
       
   162  *  CContactDatabase class - ensuring it will be called when the plug-in
       
   163  *  is unloaded.
       
   164  */
       
   165 void CPhoneBookSyncPlugin::Release()
       
   166 	{
       
   167 	LOGPLUGIN1(_L8("Release()"));
       
   168 	
       
   169 	iSession.Close();
       
   170 	delete this;
       
   171 	} // CPhoneBookSyncPlugin::Release
       
   172 
       
   173 
       
   174 /** 
       
   175  *  Update the lookup tables in the server.
       
   176  *  This method is called by the Contacts model when a new CContactICCEntry
       
   177  *  has been added to the database.
       
   178  *
       
   179  *  This is only important when it is done by a client other than the 
       
   180  *  phonebook synchronisation server because the sync server can do the 
       
   181  *  update when it knows what the UID of the newly added contact was.
       
   182  * 
       
   183  *  The plug-in should extract the appropriate details from the item 
       
   184  *  (eg. item UID, slot number and ICC phonebook type) and call the sync server to 
       
   185  *  update the lookup tables.
       
   186  *
       
   187  *  @param aContactItem  Contact Entry to update in the look up table.
       
   188  */
       
   189 void CPhoneBookSyncPlugin::UpdatePostWriteL(const CContactICCEntry& aContactItem)
       
   190 	{
       
   191 	LOGPLUGIN1(_L8("UpdatePostWriteL()"));
       
   192 
       
   193 #ifndef SYMBIAN_CNTMODEL_V2
       
   194 	if (iInServerThread)
       
   195 		{
       
   196 		return;
       
   197 		}
       
   198 #endif // SYMBIAN_CNTMODEL_V2
       
   199 
       
   200 	TContactItemId id(aContactItem.Id());
       
   201 	TInt slotNum(ICCSlotNumber(aContactItem));
       
   202 	// Extract phonebook type from CContactICCEntry
       
   203 	TUid phonebook(ICCPhonebookL(const_cast<CContactICCEntry&>(aContactItem)));
       
   204 
       
   205 	if(phonebook == KUidIccPhonebookNotSpecified) // Phonebook not specified so assume
       
   206 		{
       
   207 		iSession.UpdateLookuptable(id, slotNum);  // Global/GSM ADN phonebook is used
       
   208 		}
       
   209 	else
       
   210 		{
       
   211 		iSession.UpdateLookuptable(id, slotNum, phonebook); // phonebook supplied 
       
   212 		}
       
   213 	} // CPhoneBookSyncPlugin::UpdatePostWriteL
       
   214 
       
   215 
       
   216 /** 
       
   217  *  Return the template that should be used with CContactICCEntry items residing on the 
       
   218  *  phonebook specified by the aPhonebookUid parameter.
       
   219  *
       
   220  *  @param aPhonebookUid  UID of ICC phonebook for which the template is needed
       
   221  *
       
   222  *  @return Template item ID 
       
   223  */
       
   224 TContactItemId CPhoneBookSyncPlugin::ICCTemplateIdL(TUid aPhonebookUid)
       
   225 	{
       
   226 	LOGPLUGIN2(_L8("ICCTemplateIdL(0x%08x)"), aPhonebookUid);
       
   227 
       
   228 	TContactItemId templateId(KNullContactId);
       
   229 
       
   230 #ifdef SYMBIAN_CNTMODEL_V2
       
   231 	User::LeaveIfError(iSession.GetPhoneBookId(templateId, RPhoneBookSession::ESyncTemplateId, aPhonebookUid));
       
   232 #else
       
   233 	if (!iInServerThread)
       
   234 		{
       
   235 		User::LeaveIfError(iSession.GetPhoneBookId(templateId, RPhoneBookSession::ESyncTemplateId, aPhonebookUid));
       
   236 		}
       
   237 #endif // SYMBIAN_CNTMODEL_V2
       
   238 
       
   239 	return templateId;
       
   240 	} // CPhoneBookSyncPlugin::ICCTemplateIdL
       
   241 
       
   242 
       
   243 /** 
       
   244  *  Return the group to be used for the phonebook specified by the aPhonebookUid parameter.
       
   245  * 
       
   246  *  @param aPhonebookUid  UID of ICC phonebook for which the group UID is required 
       
   247  *
       
   248  *  @return Group item ID 
       
   249  */
       
   250 TContactItemId CPhoneBookSyncPlugin::GroupIdL(TUid aPhonebookUid)
       
   251 	{
       
   252 	LOGPLUGIN2(_L8("GroupIdL(0x%08x)"), aPhonebookUid);
       
   253 
       
   254 	TContactItemId groupId(KNullContactId);
       
   255 
       
   256 #ifdef SYMBIAN_CNTMODEL_V2
       
   257 	User::LeaveIfError(iSession.GetPhoneBookId(groupId, RPhoneBookSession::ESyncGroupId, aPhonebookUid));
       
   258 #else
       
   259 	if (!iInServerThread)
       
   260 		{
       
   261 		User::LeaveIfError(iSession.GetPhoneBookId(groupId, RPhoneBookSession::ESyncGroupId, aPhonebookUid));
       
   262 		}
       
   263 #endif // SYMBIAN_CNTMODEL_V2
       
   264 
       
   265 	return groupId;
       
   266 	} // CPhoneBookSyncPlugin::GroupIdL
       
   267 
       
   268 
       
   269 /** 
       
   270  *  Request notification of a phbksync cache state change.
       
   271  *
       
   272  *  @param aStatus Request to be completed.
       
   273  */
       
   274 void CPhoneBookSyncPlugin::NotifySyncStateChange(TRequestStatus& aStatus, TUid aPhonebookUid)
       
   275 	{
       
   276 	LOGPLUGIN2(_L8("NotifySyncStateChange(0x%08x)"), aPhonebookUid);
       
   277 
       
   278 #ifndef SYMBIAN_CNTMODEL_V2
       
   279 	__ASSERT_ALWAYS(!iInServerThread, User::Invariant()); 
       
   280 #endif // SYMBIAN_CNTMODEL_V2
       
   281 
       
   282 	iSession.NotifyPhBkCacheStateChange(aStatus, aPhonebookUid);
       
   283 	} // CPhoneBookSyncPlugin::NotifySyncStateChange
       
   284 
       
   285 
       
   286 /** 
       
   287  *  Cancel previous request for notification of phbksync cache state change.
       
   288  */
       
   289 void CPhoneBookSyncPlugin::CancelNotifyRequest(TUid aPhonebookUid)
       
   290 	{
       
   291 	LOGPLUGIN2(_L8("CancelNotifyRequest(0x%08x)"), aPhonebookUid);
       
   292 
       
   293 #ifndef SYMBIAN_CNTMODEL_V2
       
   294 	__ASSERT_ALWAYS(!iInServerThread, User::Invariant()); 
       
   295 #endif // SYMBIAN_CNTMODEL_V2
       
   296 
       
   297 	iSession.CancelRequest(ESyncNotifyCacheStateChangeCancelClient, aPhonebookUid);
       
   298 	} // CPhoneBookSyncPlugin::CancelNotifyRequest
       
   299 
       
   300 
       
   301 /** 
       
   302  *  Return the current synchronisation state of the synchroniser.
       
   303  *  If the state is EErrorDuringSync, this method leaves with the last sync
       
   304  *  error recorded.
       
   305  *
       
   306  *  @return ETrue if cache valid. EFalse, otherwise
       
   307  */
       
   308 TBool CPhoneBookSyncPlugin::IsSynchronisedL(TUid aPhonebookUid)
       
   309 	{
       
   310 	LOGPLUGIN2(_L8("IsSynchronisedL(0x%08x)"), aPhonebookUid);
       
   311 
       
   312 #ifndef SYMBIAN_CNTMODEL_V2
       
   313 	__ASSERT_ALWAYS(!iInServerThread, User::Invariant()); 
       
   314 #endif // SYMBIAN_CNTMODEL_V2
       
   315 
       
   316 	RPhoneBookSession::TSyncState state;
       
   317 
       
   318 	User::LeaveIfError(iSession.GetPhoneBookCacheState(state, aPhonebookUid));
       
   319 	
       
   320 	if (state==RPhoneBookSession::EErrorDuringSync)
       
   321 		{
       
   322 		TInt syncError(KErrNone);
       
   323 		User::LeaveIfError(iSession.GetLastSyncError(syncError, aPhonebookUid));
       
   324 		User::Leave(syncError);
       
   325 		}
       
   326 	
       
   327 	return (state==RPhoneBookSession::ECacheValid);
       
   328 	} // CPhoneBookSyncPlugin::IsSynchronisedL
       
   329 
       
   330 /** 
       
   331  * Returns the list of Phonebooks that may be present on the ICC.
       
   332  *
       
   333  * @param aPhonebookList List of the phonebooks. If successful this updated with current list of phonebooks, otherwise it is reset.
       
   334  * @return KErrNone or a system wide error such as KErrNoMemory.
       
   335  */
       
   336 TInt CPhoneBookSyncPlugin::PhonebookList(RArray<TUid>& aPhonebookList)
       
   337 	{
       
   338 	LOGPLUGIN1(_L8("PhonebookList()"));
       
   339 
       
   340 	//
       
   341 	// Empty the list to start with...
       
   342 	//
       
   343 	aPhonebookList.Reset();
       
   344 
       
   345 #ifndef SYMBIAN_CNTMODEL_V2
       
   346 	if (iInServerThread)
       
   347 		{
       
   348 		return KErrNone;
       
   349 		}
       
   350 #endif // SYMBIAN_CNTMODEL_V2
       
   351 
       
   352 	//
       
   353 	// Return the list of phonebooks...
       
   354 	//	
       
   355 	RPhoneBookSession::TSyncState state;
       
   356 	TInt  result;
       
   357 		
       
   358 	result = iSession.GetPhoneBookCacheState(state, KUidIccGlobalAdnPhonebook);
       
   359 	if (result != KErrNotSupported  &&  result != KErrNotFound)
       
   360 		{
       
   361 		result = aPhonebookList.Append(KUidIccGlobalAdnPhonebook);
       
   362 		if (result != KErrNone)
       
   363 			{
       
   364 			aPhonebookList.Reset();
       
   365 			return result;
       
   366 			}
       
   367 		}
       
   368 
       
   369 	result = iSession.GetPhoneBookCacheState(state, KUidIccGlobalSdnPhonebook);
       
   370 	if (result != KErrNotSupported  &&  result != KErrNotFound)
       
   371 		{
       
   372 		result = aPhonebookList.Append(KUidIccGlobalSdnPhonebook);
       
   373 		if (result != KErrNone)
       
   374 			{
       
   375 			aPhonebookList.Reset();
       
   376 			return result;
       
   377 			}
       
   378 		}
       
   379 
       
   380 	result = iSession.GetPhoneBookCacheState(state, KUidIccGlobalLndPhonebook);
       
   381 	if (result != KErrNotSupported  &&  result != KErrNotFound)
       
   382 		{
       
   383 		result = aPhonebookList.Append(KUidIccGlobalLndPhonebook);
       
   384 		if (result != KErrNone)
       
   385 			{
       
   386 			aPhonebookList.Reset();
       
   387 			return result;
       
   388 			}
       
   389 		}
       
   390 
       
   391 	result = iSession.GetPhoneBookCacheState(state, KUidUsimAppAdnPhonebook);
       
   392 	if (result != KErrNotSupported  &&  result != KErrNotFound)
       
   393 		{
       
   394 		result = aPhonebookList.Append(KUidUsimAppAdnPhonebook);
       
   395 		if (result != KErrNone)
       
   396 			{
       
   397 			aPhonebookList.Reset();
       
   398 			return result;
       
   399 			}
       
   400 		}
       
   401 
       
   402 	result = iSession.GetPhoneBookCacheState(state, KUidIccGlobalFdnPhonebook);
       
   403 	if (result != KErrNotSupported  &&  result != KErrNotFound)
       
   404 		{
       
   405 		result = aPhonebookList.Append(KUidIccGlobalFdnPhonebook);
       
   406 		if (result != KErrNone)
       
   407 			{
       
   408 			aPhonebookList.Reset();
       
   409 			return result;
       
   410 			}
       
   411 		}
       
   412 
       
   413 	return KErrNone;
       
   414 	}
       
   415 
       
   416 
       
   417 /**
       
   418  *  Extract the ICC slot number from the ICC slot field. 
       
   419  * 
       
   420  *  @param aContactItem CContactICCEntry item
       
   421  *
       
   422  *  @return ICC Slot number 
       
   423  */
       
   424 TInt CPhoneBookSyncPlugin::ICCSlotNumber(const CContactICCEntry& aContactItem) const
       
   425 	{
       
   426 	LOGPLUGIN1(_L8("ICCSlotNumber()"));
       
   427 
       
   428 	CContactItemFieldSet&  fieldset = aContactItem.CardFields();
       
   429 	TInt  position = fieldset.Find(KUidContactFieldICCSlot);
       
   430 	TInt  slotNum(KErrNotFound);
       
   431 	if (position != KErrNotFound)
       
   432 		{
       
   433 		const CContactItemField&  field = fieldset[position];
       
   434 		TPtrC  iccSlotField = field.TextStorage()->Text();
       
   435 		TLex  input(iccSlotField);
       
   436 		/*TInt ignore  = */ input.Val(slotNum);
       
   437 		}
       
   438 
       
   439 	return slotNum;
       
   440 	} // CPhoneBookSyncPlugin::ICCSlotNumber
       
   441 
       
   442 
       
   443 /**
       
   444  *  Extract the ICC phonebook Uid from the ICC phonebook field. It also creates the phonebook
       
   445  *  field if it is not supplied within aContactItem. 
       
   446  * 
       
   447  *  @param aContactItem CContactICCEntry item
       
   448  *
       
   449  *  @return TUid that represents the ICC Phonebook type
       
   450  */
       
   451 TUid CPhoneBookSyncPlugin::ICCPhonebookL(CContactICCEntry& aContactItem) const
       
   452 	{
       
   453 	LOGPLUGIN1(_L8("ICCPhonebookL()"));
       
   454 
       
   455 	TUid  phonebookUid;
       
   456 	CContactItemFieldSet&  fieldset = aContactItem.CardFields();
       
   457 	TInt  position = fieldset.Find(KUidContactFieldICCPhonebook);
       
   458 
       
   459 	if (position != KErrNotFound)
       
   460 		{
       
   461 		const CContactItemField& field = fieldset[position];
       
   462 		TPtrC phonebookField = field.TextStorage()->Text();
       
   463 		TLex input(phonebookField);
       
   464 		input.Val(phonebookUid.iUid);
       
   465 		}
       
   466 	else // phonebook field not supplied within aContactItem, so create one 
       
   467 		{
       
   468 		// Create phonebook type field within aContactItem 
       
   469 		TBuf<KTemplateFieldLength> buf;
       
   470 		phonebookUid = KUidIccPhonebookNotSpecified; // default phonebook Uid value 
       
   471 		buf.AppendNum(TUint(phonebookUid.iUid));
       
   472 		TPtrC phonebookPtrC(buf.Ptr());
       
   473 		CContactItemField* field=CContactItemField::NewLC(KStorageTypeText, KUidContactFieldICCPhonebook);
       
   474 		field->SetMapping(KUidContactFieldVCardMapNotRequired);
       
   475 		field->AddFieldTypeL(KUidContactFieldICCPhonebook); // Appends a field type to the field's content type
       
   476 		field->TextStorage()->SetTextL(phonebookPtrC);
       
   477 		aContactItem.AddFieldL(*field); // Add this phonebook field to ICC contact item 
       
   478 		CleanupStack::Pop(field); // No need to destroy it since contact item takes ownership of field
       
   479 		}
       
   480 
       
   481 	return phonebookUid;
       
   482 	} // CPhoneBookSyncPlugin::ICCPhonebookL
       
   483 
       
   484 
       
   485 /**
       
   486  *  Add the field value aField supplied by the phonebook synchroniser to the 
       
   487  *  item's field specified by the aFieldType parameter. 
       
   488  * 
       
   489  *  @param aContactItem  CContactICCEntry item
       
   490  *  @param aFieldType    Field type
       
   491  *  @param aField        Field data
       
   492  */
       
   493 void CPhoneBookSyncPlugin::AddFieldValueL(CContactICCEntry& aContactItem, TFieldType aFieldType,
       
   494 										  TDesC& aField)
       
   495 	{
       
   496 	LOGPLUGIN1(_L8("AddFieldValueL()"));
       
   497 
       
   498 	CContactItemFieldSet&  fieldset = aContactItem.CardFields();
       
   499 	TInt  position = fieldset.Find(aFieldType);
       
   500 	CContactItemField&  field = fieldset[position];
       
   501 	CContactTextField*  textField = field.TextStorage();
       
   502 
       
   503 	if (!textField->IsFull())
       
   504 		{
       
   505 		textField->SetTextL(aField);
       
   506 		}
       
   507 	} // CPhoneBookSyncPlugin::AddFieldValueL
       
   508 
       
   509 
       
   510 /** 
       
   511  *  Create a connection with the phonebook synchroniser server.
       
   512  */
       
   513 void CPhoneBookSyncPlugin::ConstructL()
       
   514 	{
       
   515 	LOGPLUGIN1(_L8("ConstructL()"));
       
   516 
       
   517 #ifdef SYMBIAN_CNTMODEL_V2
       
   518 	User::LeaveIfError(iSession.Connect());
       
   519 #else
       
   520 	TName threadName = RThread().Name();
       
   521 	iInServerThread = (threadName.CompareF(PHBKSYNC_ENGINE_NAME)==0);
       
   522 	
       
   523 	if (!iInServerThread)
       
   524 		{
       
   525 		User::LeaveIfError(iSession.Connect());
       
   526 		}
       
   527 #endif // SYMBIAN_CNTMODEL_V2
       
   528 	} // CPhoneBookSyncPlugin::ConstructL
       
   529 
       
   530 
       
   531 /** 
       
   532  *  Non-leaving factory construction method.
       
   533  *
       
   534  *  @return Pointer to plug-in or NULL if plug-in construction unsuccessful
       
   535  */
       
   536 CPhoneBookSyncPlugin* CPhoneBookSyncPlugin::New()
       
   537 	{
       
   538 	CPhoneBookSyncPlugin* self = NULL;
       
   539 
       
   540 	TRAPD(err,self = NewL());
       
   541 
       
   542 	if (err != KErrNone)
       
   543 		{
       
   544 		return NULL;
       
   545 		}
       
   546 	else
       
   547 		{
       
   548 		return self;
       
   549 		}
       
   550 	} // CPhoneBookSyncPlugin::New
       
   551 
       
   552 
       
   553 /** 
       
   554  *  Standard factory construction method
       
   555  */
       
   556 CPhoneBookSyncPlugin* CPhoneBookSyncPlugin::NewL()
       
   557 	{
       
   558 	CPhoneBookSyncPlugin* self = new (ELeave) CPhoneBookSyncPlugin();
       
   559 	CleanupStack::PushL(self);
       
   560 	self->ConstructL();
       
   561 	CleanupStack::Pop(self);
       
   562 
       
   563 	return self;
       
   564 	} // CPhoneBookSyncPlugin::NewL
       
   565 
       
   566 
       
   567 /**
       
   568  *  Implementation collection function.
       
   569  */
       
   570 const TImplementationProxy ImplementationTable[] = 
       
   571     {
       
   572     IMPLEMENTATION_PROXY_ENTRY(0x1020428D, CPhoneBookSyncPlugin::NewL)
       
   573     };
       
   574 
       
   575 
       
   576 /**
       
   577  *  Return the implementation table size.
       
   578  */
       
   579 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   580     {
       
   581     aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   582 
       
   583     return ImplementationTable;
       
   584     } // ImplementationGroupProxy