40
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: CSconOviAccountHandler implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "sconoviaccounthandler.h"
|
|
20 |
#include <wsoviaccountmanager.h>
|
|
21 |
#include "debug.h"
|
|
22 |
|
|
23 |
// Constants
|
|
24 |
_LIT8( KUserId, "#UserID: " );
|
|
25 |
_LIT8( KFirstName, "\n#FirstName: " );
|
|
26 |
_LIT8( KLastName, "\n#LastName: " );
|
|
27 |
_LIT8( KEmail, "\n#Email: " );
|
|
28 |
_LIT8( KEmailVerified, "\n#EmailVerified: " );
|
|
29 |
_LIT8( KMobile, "\n#Mobile: " );
|
|
30 |
_LIT8( KMobileVerified, "\n#MobileVerified: " );
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
// -----------------------------------------------------------------------------
|
|
35 |
// CreateCSconOviAccountHandlerL()
|
|
36 |
// Entry to CSconOviAccountHandler
|
|
37 |
// -----------------------------------------------------------------------------
|
|
38 |
//
|
|
39 |
EXPORT_C CSconOviAccountHandler* CreateCSconOviAccountHandlerL()
|
|
40 |
{
|
|
41 |
TRACE_FUNC;
|
|
42 |
return CSconOviAccountHandler::NewL();
|
|
43 |
}
|
|
44 |
|
|
45 |
CSconOviAccountHandler* CSconOviAccountHandler::NewL()
|
|
46 |
{
|
|
47 |
TRACE_FUNC;
|
|
48 |
CSconOviAccountHandler* self = new (ELeave) CSconOviAccountHandler();
|
|
49 |
CleanupStack::PushL( self );
|
|
50 |
self->ConstructL();
|
|
51 |
CleanupStack::Pop( self );
|
|
52 |
return self;
|
|
53 |
}
|
|
54 |
|
|
55 |
CSconOviAccountHandler::~CSconOviAccountHandler()
|
|
56 |
{
|
|
57 |
TRACE_FUNC;
|
|
58 |
delete iOviAccountManager;
|
|
59 |
}
|
|
60 |
|
|
61 |
void CSconOviAccountHandler::ConstructL()
|
|
62 |
{
|
|
63 |
TRACE_FUNC_ENTRY;
|
|
64 |
iOviAccountManager = CWSOviAccountManager::NewL();
|
|
65 |
TRACE_FUNC_EXIT;
|
|
66 |
}
|
|
67 |
|
|
68 |
// -----------------------------------------------------------------------------
|
|
69 |
// GetOviAccountDetailsL()
|
|
70 |
// Reads account info and prints details to aAccountInfoStream
|
|
71 |
// -----------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
void CSconOviAccountHandler::GetOviAccountDetailsL( RWriteStream& aAccountInfoStream )
|
|
74 |
{
|
|
75 |
TRACE_FUNC_ENTRY;
|
|
76 |
|
|
77 |
// not owned
|
|
78 |
CWSAccount* account = iOviAccountManager->Account();
|
|
79 |
if ( !account )
|
|
80 |
{
|
|
81 |
// Account information not found.
|
|
82 |
LOGGER_WRITE("Account information not found, leaving KErrNotFound");
|
|
83 |
User::Leave( KErrNotFound );
|
|
84 |
}
|
|
85 |
|
|
86 |
// Write userId
|
|
87 |
const TDesC8& userId = account->UserId();
|
|
88 |
aAccountInfoStream.WriteL( KUserId );
|
|
89 |
aAccountInfoStream.WriteL( userId );
|
|
90 |
|
|
91 |
// Write first name
|
|
92 |
HBufC8* temp = account->AccountItemL( KWSAccAttrAccountFirstName );
|
|
93 |
if ( temp )
|
|
94 |
{
|
|
95 |
aAccountInfoStream.WriteL( KFirstName );
|
|
96 |
aAccountInfoStream.WriteL( temp->Des() );
|
|
97 |
delete temp;
|
|
98 |
temp = NULL;
|
|
99 |
}
|
|
100 |
|
|
101 |
// Write last name
|
|
102 |
temp = account->AccountItemL( KWSAccAttrAccountLastName );
|
|
103 |
if ( temp )
|
|
104 |
{
|
|
105 |
aAccountInfoStream.WriteL( KLastName );
|
|
106 |
aAccountInfoStream.WriteL( temp->Des() );
|
|
107 |
delete temp;
|
|
108 |
temp = NULL;
|
|
109 |
}
|
|
110 |
|
|
111 |
// Write email
|
|
112 |
temp = account->AccountItemL( KWSAccAttrAccountEmail );
|
|
113 |
if ( temp )
|
|
114 |
{
|
|
115 |
aAccountInfoStream.WriteL( KEmail );
|
|
116 |
aAccountInfoStream.WriteL( temp->Des() );
|
|
117 |
delete temp;
|
|
118 |
temp = NULL;
|
|
119 |
}
|
|
120 |
|
|
121 |
// Write email verified (true/false)
|
|
122 |
temp = account->AccountItemL( KWSAccAttrAccountEmailVerified );
|
|
123 |
if ( temp )
|
|
124 |
{
|
|
125 |
aAccountInfoStream.WriteL( KEmailVerified );
|
|
126 |
aAccountInfoStream.WriteL( temp->Des() );
|
|
127 |
delete temp;
|
|
128 |
temp = NULL;
|
|
129 |
}
|
|
130 |
|
|
131 |
// Write mobile number
|
|
132 |
temp = account->AccountItemL( KWSAccAttrAccountMobile );
|
|
133 |
if ( temp )
|
|
134 |
{
|
|
135 |
aAccountInfoStream.WriteL( KMobile );
|
|
136 |
aAccountInfoStream.WriteL( temp->Des() );
|
|
137 |
delete temp;
|
|
138 |
temp = NULL;
|
|
139 |
}
|
|
140 |
|
|
141 |
// Write mobile verified
|
|
142 |
temp = account->AccountItemL( KWSAccAttrAccountMobileVerified );
|
|
143 |
if ( temp )
|
|
144 |
{
|
|
145 |
aAccountInfoStream.WriteL( KMobileVerified );
|
|
146 |
aAccountInfoStream.WriteL( temp->Des() );
|
|
147 |
delete temp;
|
|
148 |
temp = NULL;
|
|
149 |
}
|
|
150 |
|
|
151 |
TRACE_FUNC_EXIT;
|
|
152 |
}
|