phonebookengines/contactsmodel/cntplsql/src/cpplcommaddrtable.cpp
branchRCL_3
changeset 13 a6539d1e8e43
parent 11 2828b4d142c0
equal deleted inserted replaced
12:4ae315f230bc 13:a6539d1e8e43
    18 #include "plplugins.h"
    18 #include "plplugins.h"
    19 #include <cntdb.h>
    19 #include <cntdb.h>
    20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
    21 #include <cntphonenumparser.h>
    21 #include <cntphonenumparser.h>
    22 #endif
    22 #endif
       
    23 
       
    24 /// Unnamed namespace for local definitions
       
    25 namespace {
       
    26 
       
    27 TBool ComparePtr( const TPtrC* aLeft, const TPtrC& aRight )
       
    28     {
       
    29     return ( aLeft->Compare( aRight )== 0 );
       
    30     }
       
    31 
       
    32 } /// namespace
    23 
    33 
    24 /**
    34 /**
    25 @param aDatabase A handle to the database.
    35 @param aDatabase A handle to the database.
    26 @param aProperties A contact properties object.
    36 @param aProperties A contact properties object.
    27 
    37 
   214 					DoPhoneNumWriteOpL(phoneNumber, EInsert, KItemId);
   224 					DoPhoneNumWriteOpL(phoneNumber, EInsert, KItemId);
   215 					newPhones.AppendL(phoneNumber);
   225 					newPhones.AppendL(phoneNumber);
   216 					}
   226 					}
   217 				}
   227 				}
   218 			// get email addresses
   228 			// get email addresses
   219 			else if (isEmail && newEmails.Find(currField.TextStorage()->Text() ) == KErrNotFound)
   229 			else if (isEmail)
   220 				{
   230 				{
   221 				DoNonPhoneWriteOpL(currField.TextStorage()->Text(), EInsert, KItemId, EEmailAddress);
   231 				if (newEmails.Find( currField.TextStorage()->Text(), ComparePtr ) == KErrNotFound)
   222 				newEmails.AppendL(currField.TextStorage()->Text() );
   232 					{
       
   233 					DoNonPhoneWriteOpL(currField.TextStorage()->Text(), EInsert, KItemId, EEmailAddress);
       
   234 					newEmails.AppendL(currField.TextStorage()->Text() );
       
   235 					}
   223 				}
   236 				}
   224 			// get SIP addresses
   237 			// get SIP addresses
   225 			else if (newSips.Find(currField.TextStorage()->Text() ) == KErrNotFound)
   238 			else if (newSips.Find(currField.TextStorage()->Text() ) == KErrNotFound)
   226 				{
   239 				{
   227 				DoNonPhoneWriteOpL(currField.TextStorage()->Text(), EInsert, KItemId, ESipAddress);
   240 				DoNonPhoneWriteOpL(currField.TextStorage()->Text(), EInsert, KItemId, ESipAddress);
   288 					{
   301 					{
   289 					newPhones.AppendL(phoneNumber);
   302 					newPhones.AppendL(phoneNumber);
   290 					}
   303 					}
   291 				}
   304 				}
   292 			// get email addresses
   305 			// get email addresses
   293 			else if (isEmail && newEmails.Find(currField.TextStorage()->Text() ) == KErrNotFound)
   306 		   else if (isEmail)
   294 				{
   307 			  {
   295 				newEmails.AppendL(currField.TextStorage()->Text() );
   308 			  if (newEmails.Find(currField.TextStorage()->Text(), ComparePtr ) == KErrNotFound)
   296 				}
   309 				  {
       
   310 				  newEmails.AppendL(currField.TextStorage()->Text() );
       
   311 				  }
       
   312 			  }
   297 			// get SIP addresses
   313 			// get SIP addresses
   298 			else if (newSips.Find(currField.TextStorage()->Text() ) == KErrNotFound)
   314 			else if (newSips.Find(currField.TextStorage()->Text() ) == KErrNotFound)
   299 				{
   315 				{
   300 				newSips.AppendL(currField.TextStorage()->Text() );
   316 				newSips.AppendL(currField.TextStorage()->Text() );
   301 				}
   317 				}
   380 
   396 
   381 			// remove any email and sip addresses from the new list if
   397 			// remove any email and sip addresses from the new list if
   382 			// we already have them in the db and they haven't changed...
   398 			// we already have them in the db and they haven't changed...
   383 			if (KType == EEmailAddress)
   399 			if (KType == EEmailAddress)
   384 				{
   400 				{
   385 				matchIndex = aNewEmails.Find(valString);
   401 				matchIndex = aNewEmails.Find( valString, ComparePtr );
   386 				if (matchIndex != KErrNotFound)
   402 				if (matchIndex != KErrNotFound)
   387 					{
   403 					{
   388 					aNewEmails.Remove(matchIndex);
   404 					aNewEmails.Remove(matchIndex);
   389 					}
   405 					}
   390 				}
   406 				}