|
1 /* |
|
2 * Copyright (c) 2002-2007 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: A write command for writing own number contacts |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "COwnNumberWriteCmd.h" |
|
22 |
|
23 #include "CVPbkSimContactBuf.h" |
|
24 #include "CVPbkSimCntField.h" |
|
25 #include "CStoreBase.h" |
|
26 #include "MVPbkSimContactObserver.h" |
|
27 |
|
28 namespace VPbkSimStoreImpl { |
|
29 |
|
30 // ============================ MEMBER FUNCTIONS =============================== |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // COwnNumberWriteCmd::COwnNumberWriteCmd |
|
34 // C++ default constructor can NOT contain any code, that |
|
35 // might leave. |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 COwnNumberWriteCmd::COwnNumberWriteCmd( CStoreBase& aStore, TInt& aSimIndex, |
|
39 MVPbkSimContactObserver& aObserver ) |
|
40 : CBasicWriteCmd<RMobileONStore::TMobileONEntryV1>( aStore, aSimIndex, |
|
41 aObserver ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // COwnNumberWriteCmd::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 void COwnNumberWriteCmd::ConstructL( const TDesC8& aData ) |
|
51 { |
|
52 // Convert contact to own number contact |
|
53 CVPbkSimContactBuf* cnt = CVPbkSimContactBuf::NewLC( aData, StoreBase() ); |
|
54 |
|
55 CVPbkSimContactBase::TFieldLookup lookup = cnt->FindField( EVPbkSimName ); |
|
56 if ( !lookup.EndOfLookup() ) |
|
57 { |
|
58 const TDesC& data = cnt->ConstFieldAt( lookup.Index() ).Data(); |
|
59 iETelContact.iText.Copy( data.Left( RMobileONStore::KOwnNumberTextSize ) ); |
|
60 } |
|
61 |
|
62 lookup = cnt->FindField( EVPbkSimGsmNumber ); |
|
63 if ( !lookup.EndOfLookup() ) |
|
64 { |
|
65 const TDesC& data = cnt->ConstFieldAt( lookup.Index() ).Data(); |
|
66 iETelContact.iNumber.iTelNumber.Copy( |
|
67 data.Right( RMobilePhone::KMaxMobileTelNumberSize ) ); |
|
68 } |
|
69 iETelContact.iIndex = cnt->SimIndex(); |
|
70 CleanupStack::PopAndDestroy( cnt ); // cnt |
|
71 |
|
72 BaseConstructL(); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // COwnNumberWriteCmd::NewL |
|
77 // Two-phased constructor. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 COwnNumberWriteCmd* COwnNumberWriteCmd::NewL( CStoreBase& aStore, |
|
81 const TDesC8& aData, TInt& aSimIndex, |
|
82 MVPbkSimContactObserver& aObserver ) |
|
83 { |
|
84 COwnNumberWriteCmd* self = |
|
85 new( ELeave ) COwnNumberWriteCmd( aStore, aSimIndex, aObserver ); |
|
86 CleanupStack::PushL( self ); |
|
87 self->ConstructL( aData ); |
|
88 CleanupStack::Pop( self ); |
|
89 return self; |
|
90 } |
|
91 |
|
92 // Destructor |
|
93 COwnNumberWriteCmd::~COwnNumberWriteCmd() |
|
94 { |
|
95 } |
|
96 } // namespace VPbkSimStoreImpl |
|
97 // End of File |