S60 3rd Edition SDK for Symbian OS
Example Applications Guide

CAddressBookEngine Class Reference

#include <AddressBookEngine.h>

List of all members.

Public Member Functions

 ~CAddressBookEngine ()
void SendSearchL (const TDesC &aSearchPattern)
void ConnectL ()
TBool Connected ()
TInt GetContact (TInt aPosition, CAddressBookContact *&aContact)
void Cancel ()
HBufC8 * GenerateQueryRequestL (const TDesC &aSearchPattern)

Static Public Member Functions

static CAddressBookEngine * NewL (MAddressBookEngineObserver &aObserver)

Protected Member Functions

virtual void StartElementL (const TDesC8 &aNsUri, const TDesC8 &aLocalName, const TDesC8 &aQName, const RAttributeArray &aAttrs)
virtual void EndElementL (const TDesC8 &aNsUri, const TDesC8 &aLocalName, const TDesC8 &aQName)

Private Member Functions

 CAddressBookEngine (MAddressBookEngineObserver &aObserver)
void ConstructL ()
TInt RegisterIdentityProviderL ()
virtual void HandleMessageL (const TDesC8 &aMessage)
virtual void HandleErrorL (const TInt aErrorCode, const TDesC8 &aError)
virtual void SetStatus (const TInt aStatus)
virtual CSenElement * ResolveResourceIdL ()

Private Attributes

RPointerArray< CAddressBookContact > iContacts
TInt iConnectionState
CSenServiceConnection * iConnection
CSenXmlServiceDescription * iSession
CSenXmlReader * iXmlReader
MAddressBookEngineObserver & iObserver
CSenServiceManager * iManager
CSenDomFragment * iFaultDelegate
TInt iErrorState
TBool iInitialized


Detailed Description

Application Engine class performs engine related operations

Definition at line 96 of file AddressBookEngine.h.


Constructor & Destructor Documentation

CAddressBookEngine::~CAddressBookEngine (   ) 
 

Destructor.

Definition at line 51 of file AddressBookEngine.cpp.

References iConnection, iContacts, iFaultDelegate, iManager, iSession, and iXmlReader.

00052         {
00053         _LIT( KLogFileClosed, "CAddressBookEngine::~CAddressBookEngine() - Log file closed.");
00054         LOG(KLogFileClosed);
00055         iContacts.ResetAndDestroy();
00056         delete iXmlReader;
00057         delete iFaultDelegate;
00058         delete iManager;
00059         delete iConnection;
00060         delete iSession;
00061         delete iFaultDelegate;
00062         }

CAddressBookEngine::CAddressBookEngine (  MAddressBookEngineObserver &  aObserver  )  [private]
 

C++ default constructor.

Definition at line 34 of file AddressBookEngine.cpp.

00035 : iConnection(NULL),
00036   iSession(NULL),
00037   iXmlReader(NULL),
00038   iObserver(aObserver),
00039   iManager(NULL),
00040   iFaultDelegate(NULL),
00041   iErrorState(ENoError),
00042   iInitialized(EFalse)
00043         {
00044         }


Member Function Documentation

CAddressBookEngine * CAddressBookEngine::NewL (  MAddressBookEngineObserver &  aObserver  )  [static]
 

Two-phased constructor

Definition at line 69 of file AddressBookEngine.cpp.

References CAddressBookEngine(), and ConstructL().

00071         {
00072         CAddressBookEngine* newEngine = new (ELeave) CAddressBookEngine(aObserver);
00073         CleanupStack::PushL(newEngine);
00074         newEngine->ConstructL();
00075         CleanupStack::Pop(newEngine);
00076         return newEngine;
00077         }

void CAddressBookEngine::SendSearchL (  const TDesC &  aSearchPattern  ) 
 

This function is called after an user has selected Search from the GUI and typed a request. Function creates a search pattern from the descriptor and send it to the WSP. The message from server is received through HandleMessageL() or an error is received through HandleErrorL().

Parameters:
aSearchPattern - descriptor on Searching note that an user has typed

Definition at line 369 of file AddressBookEngine.cpp.

References MAddressBookEngineObserver::ErrorL(), GenerateQueryRequestL(), iConnection, iErrorState, and iObserver.

00370         {       
00371         _LIT( KSendSearchL, "CAddressBookEngine::SendSearchL()");
00372         LOG(KSendSearchL);
00373         iErrorState = ENoError;
00374         if (!iConnection)
00375                 {
00376                 _LIT( KConnNotReady, "Connection not ready.");
00377                 LOG(KConnNotReady);
00378                 iObserver.ErrorL(EConnectionNotReady);
00379                 return;
00380                 }
00381         
00382         //Get the xml query to be sent to service
00383         HBufC8* stSearch= GenerateQueryRequestL(aSearchPattern);
00384         CleanupStack::PushL(stSearch);
00385 
00386         //Send the query to service
00387         iConnection->SendL(*stSearch);
00388         
00389         CleanupStack::PopAndDestroy(stSearch);
00390         }

void CAddressBookEngine::ConnectL (   ) 
 

Makes a connection to an ID-WSF service. When ConnectL() is called the first time, authentication and discovery services are connected and the user is therefore authenticated and the service is connected. When ConnectL() is called again and the credentials received from authentication and discovery services are valid, there are no need to connect to them again. This means that SetStatus() will be called almost immediately with value CONNECTED, but in device GPRS or data connection is not opened yet (but instead it is opened when search occurs).

Definition at line 656 of file AddressBookEngine.cpp.

References iConnection, and RegisterIdentityProviderL().

00657         {
00658         _LIT (KConnectL, "CAddressBookEngine::ConnectL()");
00659         LOG( KConnectL);
00660         RegisterIdentityProviderL();
00661 
00662         CSenXmlServiceDescription* pattern = CSenXmlServiceDescription::NewLC();
00663         pattern->SetContractL(KPpContract());
00664         delete iConnection;
00665         iConnection = NULL;
00666         iConnection = CSenServiceConnection::NewL(*this, *pattern);
00667         CleanupStack::PopAndDestroy(pattern); 
00668         }

TBool CAddressBookEngine::Connected (   ) 
 

sets a state of connection as KSenConnectionStatusReady

Definition at line 675 of file AddressBookEngine.cpp.

References iConnectionState.

00676         {
00677         return (iConnectionState == KSenConnectionStatusReady);
00678         }

TInt CAddressBookEngine::GetContact (  TInt  aPosition,
CAddressBookContact *&  aContact
) 
 

This function need to get a current contact (CAddressBookView::CurrentContact()) or to open an item (CAddressBookView::OpenItemL())

Parameters:
aPosition - Index of Item whose data is needed to get
aContact - gets Value of Item whose Index == aPosition
Returns:
if there is such item, KErrorNotFound is returned otherwise returns KIndexError.

Definition at line 686 of file AddressBookEngine.cpp.

References iContacts.

00687         {
00688         _LIT( KGetContact, "CAddressBookEngine::GetContact()");
00689         LOG( KGetContact);
00690         TInt retVal(KErrNotFound);
00691         if (aPosition < iContacts.Count() && aPosition >= 0)
00692                 {
00693                 aContact = iContacts[aPosition];
00694                 retVal = KErrNone;
00695                 }
00696         return retVal;
00697         }

void CAddressBookEngine::Cancel (   ) 
 

Close WebServices-connection if user canceled

Definition at line 704 of file AddressBookEngine.cpp.

References iConnection, and iConnectionState.

00705         {
00706         _LIT( KCancel, "CAddressBookEngine::Cancel()");
00707         LOG( KCancel);
00708         delete iConnection;
00709         iConnectionState = 0;    // not connected
00710         iConnection = NULL;
00711         }

HBufC8 * CAddressBookEngine::GenerateQueryRequestL (  const TDesC &  aSearchPattern  ) 
 

Gets the XML query based on the search parameter passed Method also calls WSF ServiceDescriptionL() getter and resolves either ResourceID or EncryptedResourceID element. Later on, this resource id may be used when generating the actual query which is sent to the service (WSP)

Parameters:
aSearchPattern - descriptor on Searching note that an user has typed

Definition at line 267 of file AddressBookEngine.cpp.

References ResolveResourceIdL().

00268         {
00269         _LIT( KGenQueryReqL, "CAddressBookEngine::GenerateQueryRequestL(const TDesC& aSearchPattern)");
00270         LOG( KGenQueryReqL);
00271  
00272         // Create Query Tag
00273         _LIT8 (KElement, "Query");
00274     CSenElement* element = CSenBaseElement::NewL(KElement);
00275         CleanupStack::PushL(element);
00276         element->SetNamespaceL(KQueryNS, KPpContract);
00277         
00278         // Create QueryItem element
00279         _LIT8 (KQueryItem, "ab:QueryItem");     
00280         CSenElement* queryItem = CSenBaseElement::NewL(KQueryItem);
00281         CleanupStack::PushL(queryItem);
00282         
00283         // Create Select element
00284         _LIT8 (KSelectElement, "ab:Select");
00285         CSenBaseElement* selectElement=CSenBaseElement::NewL(KSelectElement);   
00286         CleanupStack::PushL(selectElement);
00287         
00288         //Create temporary buffer and perform UTF8 conversion for parameter passed      
00289         HBufC8* tempBuffer = HBufC8::NewLC(512);        
00290         TPtr8 ptrSelectQuery = tempBuffer->Des();       
00291         HBufC8* pattern = SenXmlUtils::ToUtf8LC(aSearchPattern); 
00292         //Replace %S with pattern passed in parameter
00293         ptrSelectQuery.Format(KSelectQuery, pattern, pattern, pattern); 
00294                 
00295         selectElement->SetContentL(ptrSelectQuery);     
00296         // Add select element to QueryItem
00297         queryItem->AddElementL(*selectElement);
00298                 
00299         //Add QueryItemto Query
00300         element->AddElementL(*queryItem);
00301 
00302         // Next phase is to create and add ResourceID element into the query.
00303         CSenElement* resourceID = ResolveResourceIdL();
00304         CSenBaseElement* resourceElement = NULL; 
00305         if(resourceID)
00306                 {
00307                 // (Encrypted)Resource was successfully resolved. Now check
00308                 // whether plain ResourceID or EncryptedResourceID is
00309                 // available and create according element into the query.
00310                 if (resourceID->Content().Find(KEncrypted()) != KErrNotFound) 
00311                         {
00312                         _LIT( KEncResID, "EncryptedResourceID exists.");
00313                         LOG(KEncResID);
00314                         _LIT8 (KResourceElement, "ab:EncryptedResourceID");
00315                         resourceElement = CSenBaseElement::NewL(KResourceElement);
00316                         CleanupStack::PushL(resourceElement);   
00317                         // copy the actual resource id content
00318                         resourceElement->CopyFromL(*resourceID);
00319                         }
00320                 else
00321                         {
00322                         _LIT( KOnlyPlainResID, "Only plain ResourceID should be used (not encrypted).");
00323                         LOG( KOnlyPlainResID);
00324                         _LIT8 (KResourceElement, "ab:ResourceID");
00325                         resourceElement = CSenBaseElement::NewL(KResourceElement);
00326                         CleanupStack::PushL(resourceElement);   
00327                         // Copy the actual resource id content
00328                         resourceElement->CopyFromL(*resourceID);
00329                         }
00330                 }
00331         else
00332                 {
00333                 _LIT( KErrResID, "Error: could not resolve ResourceID!");
00334                 LOG( KErrResID);
00335                 _LIT8 (KResourceElement, "ab:ResourceID");
00336                 resourceElement=CSenBaseElement::NewL(KResourceElement);        
00337                 CleanupStack::PushL(resourceElement);   
00338                 resourceElement->SetContentL(KResourceIDVal); // example content
00339                 }
00340         element->AddElementL(*resourceElement);
00341         CleanupStack::Pop(resourceElement); 
00342         
00343         //Get the XML
00344         HBufC8* soapBuf = element->AsXmlL();
00345 
00346         // Log the XML request
00347     _LIT( KGenQuery, "Generated Query:");
00348     LOG( KGenQuery);
00349         LOG_ALL(( soapBuf->Des() ));
00350         
00351         //Destroy the objects pushed on cleanup stack
00352         CleanupStack::PopAndDestroy(pattern);
00353         CleanupStack::PopAndDestroy(tempBuffer);
00354         CleanupStack::Pop(selectElement);
00355         CleanupStack::Pop(queryItem);
00356         CleanupStack::PopAndDestroy(element);
00357         //return Pointer to Soap Request Buffer;
00358         return soapBuf;
00359         }

void CAddressBookEngine::StartElementL (  const TDesC8 &  aNsUri,
const TDesC8 &  aLocalName,
const TDesC8 &  aQName,
const RAttributeArray &  aAttrs
)  [protected, virtual]
 

From CSenDomFragment, is called from CAddressBookEngine::HandleMessageL (ParseL(aMessage)) every time when XML parser finds a new element tag. In this case we are interested in the <Status> and <Card> elements. When Status is found, we compare if attribute 'Code' is OK or not. SenXmlUtils::LocalName() only extracts out a possible XML prefix (i.e. 'ab:OK'). When local name is 'Card', we have encountered a contact-object. Then we make a new CAddressBookContact and delegate the parsing to it.

Example server response: <ab:QueryResponse xmlns:ab="urn:nokia:test:addrbook:2004-09"> <ab:Status code="ab:OK"/> <ab:Data> <ab:Card> <ab:N> <ab:FAMILY>Smith</ab:FAMILY> <ab:GIVEN>John</ab:GIVEN> </ab:N> <ab:ADR> <ab:EXTADR>Room 123</ab:EXTADDR> <ab:STREET>1st ST 123</ab:STREET> <ab:PCODE>7698532</ab:PCODE> </ab:ADR> <ab:TEL>1234</ab:TEL> <ab:TEL type="CELL">2122345</ab:TEL> </ab:Card> </ab:Data> </ab:QueryResponse>

Parameters:
aNsUri - namespace URI
aLocalName - local name (in this case may be Status or Card)
aQName - qualified name
aAttrs - we are interested if value of attribute is KCode or not

Definition at line 428 of file AddressBookEngine.cpp.

References iContacts, iErrorState, iFaultDelegate, and CAddressBookContact::NewL().

00432         {
00433         _LIT( KStartElementL, "CAddressBookEngine::StartElementL() ***");
00434         _LIT( KNamespaceURI, "- namespace URI  (%S)");
00435         _LIT( KLocalname, "- localname      (%S)");
00436         _LIT( KQualName, "- qualified name (%S)");
00437         
00438         LOG( KStartElementL);
00439         LOG_FORMAT((KNamespaceURI, aNsUri));
00440         LOG_FORMAT((KLocalname, aLocalName));
00441         LOG_FORMAT((KQualName, aQName));
00442 
00443         if (aLocalName == KStatus)
00444                 {
00445                 
00446                 if (SenXmlUtils::LocalName(SenXmlUtils::AttrValue(aAttrs, KCode)) != KOk)
00447                         {
00448                         iErrorState = ENestedError;
00449                         delete iFaultDelegate;
00450                         iFaultDelegate = NULL;
00451                         iFaultDelegate = CSenDomFragment::NewL(aNsUri,
00452                                                         aLocalName, aQName, aAttrs);
00453                         DelegateParsingL(*iFaultDelegate);
00454                         return;
00455                         }
00456                 }
00457         else if (aLocalName == KCard)
00458                 {
00459                 iErrorState = ENoError;
00460 
00461                 CAddressBookContact* delegate = CAddressBookContact::NewL();
00462                 CleanupStack::PushL(delegate);
00463                 iContacts.Append(delegate);
00464                 DelegateParsingL(*delegate);
00465                 CleanupStack::Pop(delegate);
00466                 return;
00467                 }
00468         }

void CAddressBookEngine::EndElementL (  const TDesC8 &  aNsUri,
const TDesC8 &  aLocalName,
const TDesC8 &  aQName
)  [protected, virtual]
 

From CSenDomFragment, is called from CAddressBookEngine::HandleMessageL (ParseL(aMessage)) every time when XML parser finds a closing element tag.

We are only interested about the </Status> element. When the </Status> is found, we check for errors found in response, and if so, notice the observer

Parameters:
aNsUri - namespace URI
aLocalName - local name (in this case we are interested only Status)
aQName - qualified name

Definition at line 482 of file AddressBookEngine.cpp.

References MAddressBookEngineObserver::ErrorL(), iContacts, iErrorState, iFaultDelegate, and iObserver.

00485         {
00486         _LIT( KEndElementL, "CAddressBookEngine::EndElementL()");
00487         _LIT( KNamespaceURI, "- namespace URI  (%S)");
00488         _LIT( KLocalname, "- localname      (%S)");
00489         _LIT( KQualName, "- qualified name (%S)");      
00490 
00491         LOG( KEndElementL);
00492         LOG_FORMAT((KNamespaceURI, aNsUri));
00493         LOG_FORMAT((KLocalname, aLocalName));
00494         LOG_FORMAT((KQualName, aQName));
00495 
00496         if(aLocalName == KStatus)
00497                 {
00498                 if (iErrorState == ENestedError)
00499                         {
00500                         iErrorState = ENoError;
00501                         CSenElement* statusElement = NULL;
00502                         if (iFaultDelegate)
00503                                 {
00504                                         statusElement =
00505                                                 iFaultDelegate->AsElement().Element(KStatus);
00506                                 }
00507 
00508                         if(statusElement)
00509                                 {
00510                                 const TDesC8* errorCode = statusElement->AttrValue(KCode);
00511                                 iContacts.ResetAndDestroy();
00512                                 if (errorCode)
00513                                         {
00514                                         if (SenXmlUtils::LocalName(*errorCode) == KTooManyMatches)
00515                                                 {
00516                                                 iObserver.ErrorL(ETooManyMatches);
00517                                                 }
00518                                         else
00519                                                 {
00520                                                 iObserver.ErrorL(ESearchFailed); // Default error
00521                                                 }
00522                                         }
00523                                 }
00524                         else
00525                                 {
00526                                 // could not find status element:
00527                                 iObserver.ErrorL(ESearchFailed); // Default error
00528                                 }
00529                         }
00530                 else if (iErrorState == ESoapError)
00531                         {
00532                         iErrorState = ENoError;
00533                         delete iFaultDelegate;
00534                         iFaultDelegate = NULL;
00535                         iContacts.ResetAndDestroy();
00536                         iObserver.ErrorL(ESearchFailed); // Default error
00537                         }
00538                 }
00539         else
00540                 {
00541                 CSenBaseFragment::EndElementL(aNsUri, aLocalName, aQName);
00542                 }
00543         }

void CAddressBookEngine::ConstructL (   )  [private]
 

By default Symbian 2nd phase constructor is private.

Definition at line 84 of file AddressBookEngine.cpp.

References iXmlReader.

00085         {
00086         LOG_OPEN();
00087         _LIT( KConstructL, "CAddressBookEngine::ConstructL() ***");
00088         LOG(KConstructL);
00089         CSenBaseFragment::BaseConstructL(KPpContract, KQueryResponseLocalName);
00090         iXmlReader = CSenXmlReader::NewL();
00091         }

TInt CAddressBookEngine::RegisterIdentityProviderL (   )  [private]
 

Register IdentityProvider and associates Forum Nokia's Addressbook service to be known to trust in this IDP. Method creates instance of the CSenServiceManager to achieve this Identity Provider (IDP) registration. IDP is also registered as Authentication Service (AS) Description, because in Liberty ID-WSF, they are the same service.

Returns:
status code or -1 if error appears

Definition at line 554 of file AddressBookEngine.cpp.

References iManager.

00555         {
00556         _LIT( KRegIdProvL, "CAddressBookEngine::RegisterIdentityProviderL()");
00557         LOG( KRegIdProvL);
00558         TBuf<64> buf; // for logging
00559 
00560         TInt retVal(KErrNone);
00561 
00562         if (!iManager)
00563                 {
00564                 _LIT( KInsNewServMng, "Instantiating new service manager");
00565                 LOG( KInsNewServMng);
00566                 iManager = CSenServiceManager::NewL();
00567                 }
00568 
00569         CSenIdentityProvider* idp = CSenIdentityProvider::NewLC(
00570                 KASEndPoint, KASContract);
00571 
00572         // Set the Provider ID
00573         idp->SetProviderID(KASProviderID);
00574 
00575         // Associate Forum Nokia's Addressbook service ID (contract)
00576         // to this Identity Provider
00577         idp->SetServiceID(KPpContract);
00578 
00579         // Set Liberty ID-WSF framework ID
00580         idp->SetFrameworkIdL(KDefaultIdWsfFrameworkID);
00581 
00582         // ------------------------------------------------------------------------
00583         // The following username/password properties will be used for
00584         // authentication. Please note, that use advisory authentication
00585         // id "IMEI" would result device ID to be directly fetched from phone.
00586         // ------------------------------------------------------------------------
00587         //
00588         idp->SetUserInfoL(KTestAuthzID, KNullDesC8, KTestPassword);
00589 
00590         _LIT( KRegIdProv, "Registering identityprovider. User info provided.");
00591         LOG( KRegIdProv);
00592         retVal = iManager->RegisterIdentityProviderL(*idp);
00593         if(retVal != KErrNone)
00594                 {
00595                 // --------------------------------------------------------------------
00596                 // An error occurred. However, the rest of registration calls will
00597                 // be attempted in order to provide any possible data that WSF needs.
00598                 // --------------------------------------------------------------------
00599                 buf.AppendNum(retVal);
00600                 _LIT( KErrRegIdProv, "Error registering Identity Provider: %S");
00601                 LOG_FORMAT((KErrRegIdProv, buf));
00602                 buf.Zero();
00603                 }
00604         _LIT( KRegAutServDesc, "Registering autentication service description.");
00605         LOG( KRegAutServDesc);
00606         retVal = iManager->RegisterServiceDescriptionL(*idp);
00607         if(retVal != KErrNone)
00608                 {
00609                 // --------------------------------------------------------------------
00610                 // An error occurred. However, the rest of registration calls will
00611                 // be attempted in order to provide any possible data that WSF needs.
00612                 // --------------------------------------------------------------------
00613                 buf.AppendNum(retVal);
00614                 _LIT( KErrRegServDesc, "Error registering Service Description: %S");
00615                 LOG_FORMAT((KErrRegServDesc, buf));
00616                 buf.Zero();
00617                 }
00618 
00619 // Note, that following API call could be used to associate more services
00620 // to some Identity Provider, which ProviderID is known.
00621 //
00622 //      LIT( KAssocAddressbookServ, "Associating Addressbook service (WSP) to known Identity Provider.");
00623 //      LOG( KAssocAddressbookServ);
00624 //      retVal = iManager->AssociateServiceL(KPpContract, KASProviderID);
00625 //
00626 //      if(retVal != KErrNone) 
00627 //              {
00628 //              // --------------------------------------------------------------------
00629 //              // An error occurred. However, the rest of registration calls will
00630 //              // be attempted in order to provide any possible data that WSF needs.
00631 //              // --------------------------------------------------------------------
00632 //              buf.AppendNum(retVal);
00633 //              _LIT( KErrAssFNServ, "Error associating the FN service to IDP %S");
00634 //              LOG_FORMAT( KErrAssFNServ, buf);
00635 //              buf.Zero();
00636 //              }
00637 
00638         CleanupStack::PopAndDestroy(idp); 
00639         return retVal;
00640         }

void CAddressBookEngine::HandleMessageL (  const TDesC8 &  aMessage  )  [private, virtual]
 

From MSenServiceConsumer, handles receiving messages from the SendL() (CSenServiceConnection)function call

Parameters:
aMessage - descriptor on content of receiving Message

Definition at line 99 of file AddressBookEngine.cpp.

References iContacts, iObserver, iXmlReader, and MAddressBookEngineObserver::SearchFinishedL().

00100         {
00101         _LIT(KHandleMessageL, "CAddressBookEngine::HandleMessageL()");
00102         LOG( KHandleMessageL);
00103         LOG_ALL(aMessage);
00104         iContacts.ResetAndDestroy();
00105         SetReader(*iXmlReader);
00106         
00107         // ------------------------------------------------------------------------
00108         // Xmlparser calls CAddressBook::StartElementL every time a new element tag is found
00109         // and CAddressBookEngine::EndElementL every time a closing element tag is found.
00110         // ------------------------------------------------------------------------
00111         // 
00112         ParseL(aMessage);
00113         iObserver.SearchFinishedL(iContacts);
00114         }

void CAddressBookEngine::HandleErrorL (  const TInt  aErrorCode,
const TDesC8 &  aError
)  [private, virtual]
 

From MSenServiceConsumer, handles receiving errors about the connection to be initialized or from the SendL()(CSenServiceConnection)function call

Parameters:
aErrorCode - code of error
aError - descriptor on content of receiving Error

Definition at line 123 of file AddressBookEngine.cpp.

References MAddressBookEngineObserver::ErrorL(), iContacts, and iObserver.

00124         {
00125         _LIT( KHandleErrorL, "CAddressBookEngine::HandleErrorL()");
00126         LOG( KHandleErrorL);
00127         TBuf<24> code;
00128         code.AppendNum(aErrorCode);
00129         LOG(code);
00130         LOG_ALL(aError);
00131         iContacts.ResetAndDestroy();
00132         
00133         // ------------------------------------------------------------------------
00134         // Every error reported here is not nested XML error,
00135         // probably SOAP error, so show general error.
00136     // More sophisticated applications could resolve service
00137         // specific info about failure by inspecting soap fault
00138         // received in here.
00139         // ------------------------------------------------------------------------
00140         //
00141         iObserver.ErrorL(ESearchFailed);
00142         }

void CAddressBookEngine::SetStatus (  const TInt  aStatus  )  [private, virtual]
 

From MSenServiceConsumer, handles receiving status info about the connection to be initialized. Is called by CSenServiceConnectionImpl::RunL() that is called by active scheduler from CAddressBookAppUi::HandleCommandL(TInt aCommand) in case "EAddressBookCmdAppConnect"

Parameters:
aStatus - may be KSenConnectionStatusNew, KSenConnectionStatusReady, or STATUS_EXRIRED

Definition at line 153 of file AddressBookEngine.cpp.

References MAddressBookEngineObserver::ConnectionReady(), iConnectionState, iInitialized, and iObserver.

00154         {
00155         _LIT( KSetStatus, "CAddressBookEngine::SetStatus()");
00156         LOG( KSetStatus);
00157         iConnectionState = aStatus;
00158         switch(iConnectionState)
00159                 {
00160                 case KSenConnectionStatusNew:
00161                         _LIT( KSenConnStatNew, "KSenConnectionStatusNew");
00162                         LOG( KSenConnStatNew);
00163                         break;
00164                 case KSenConnectionStatusReady:
00165                         _LIT( KSenConnStatRdy, "KSenConnectionStatusReady");
00166                         LOG( KSenConnStatRdy);
00167                         iInitialized = ETrue;
00168                         iObserver.ConnectionReady();
00169                         break;
00170                 case KSenConnectionStatusExpired:
00171                         _LIT( KSenConnStatEx, "KSenConnectionStatusExpired");
00172                         LOG( KSenConnStatEx);
00173                         break;
00174                 default:
00175                         TBuf<32> num;
00176                         num.AppendNum(iConnectionState);
00177                         _LIT( KUknStat, "UNKNOWN STATUS: (%S)");
00178                         LOG_FORMAT((KUknStat, num));
00179                         break;
00180                 }
00181         if(!iInitialized)
00182                 {
00183                 TInt leaveCode(KErrNone);
00184                 TRAP(leaveCode, iObserver.ErrorL(EConnectionNotReady));
00185                 leaveCode = 0; // not used
00186                 }
00187         }

CSenElement * CAddressBookEngine::ResolveResourceIdL (   )  [private, virtual]
 

This helper function resolves the ResourceID from WSF using ServiceDescriptionL() getter method.

Returns:
pointer to resolved ResourceID element, which content indicates whether it is encrypted or not; content of encrypted ResourceID includes "EncryptedData" element.

Definition at line 198 of file AddressBookEngine.cpp.

00199         {
00200         _LIT( KResolveResourceIdL, "ResolveResourceIdL()");
00201         LOG( KResolveResourceIdL);
00202         TInt parseLeaveCode(KErrNone);
00203         HBufC8* sd = NULL;
00204         CSenElement* resourceID = NULL;
00205 
00206         if(iInitialized && iConnection)  
00207                 {
00208                 TInt err0 = iConnection->ServiceDescriptionL(sd);
00209                 if(err0 == KErrNone && sd)
00210                         {
00211                         _LIT( KServDescRet, "iConnection->ServiceDescriptionL(sd) returned:");
00212                         LOG( KServDescRet);
00213                         CleanupStack::PushL(sd);
00214                         LOG_ALL((*sd));
00215                         delete iSession;
00216                         iSession = NULL;
00217                         iSession = CSenXmlServiceDescription::NewL();
00218                         iSession->SetReader(*iXmlReader);
00219                         iXmlReader->SetContentHandler(*iSession);
00220                         TRAP(parseLeaveCode, iSession->ParseL(*sd));
00221                         CleanupStack::PopAndDestroy(sd); 
00222                         if(parseLeaveCode!=KErrNone)
00223                                 {
00224                                 _LIT( KParServDescFailed, "Parsing of service description (session) failed!");
00225                                 LOG( KParServDescFailed);
00226                                 }
00227                         else
00228                                 {
00229                                 _LIT8 (KResourceID, "ResourceID");
00230                                 resourceID = iSession->AsElement().Element(KResourceID);
00231                                 if(resourceID)
00232                                         {
00233                                         _LIT( KResID, "ResourceID:");
00234                                         LOG(KResID);
00235                                         LOG_ALL((resourceID->Content()));
00236                                         }
00237                                 else
00238                                         {
00239                                         _LIT( KResIdNotFound, "ResourceID not found from service description.");
00240                                         LOG( KResIdNotFound);
00241                                         }
00242                                 }
00243                         }
00244                 }
00245         return resourceID;
00246         }


© Nokia 2006

Back to top