|
1 /* |
|
2 * Copyright (c) 2006-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: An operation for importing the card to the contact(s) |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CVPbkImportToContactsOperation.h" |
|
20 |
|
21 // Internal |
|
22 #include "CVPbkVCardCompactBCardImporter.h" |
|
23 #include "CVPbkVCardImporter.h" |
|
24 #include "VPbkVCardEngError.h" |
|
25 |
|
26 // From Virtual Phonebook |
|
27 #include <MVPbkSingleContactOperationObserver.h> |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // CVPbkImportToContactsOperation::CVPbkImportToContactsOperation |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CVPbkImportToContactsOperation::CVPbkImportToContactsOperation( |
|
36 MVPbkSingleContactOperationObserver& aObserver ) |
|
37 : iObserver( aObserver ) |
|
38 { |
|
39 } |
|
40 |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CVPbkImportToContactsOperation::ConstructL |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 void CVPbkImportToContactsOperation::ConstructL( |
|
47 TVPbkImportCardType aType, |
|
48 CVPbkVCardData& aData, |
|
49 RPointerArray<MVPbkStoreContact>& aImportedContacts, |
|
50 MVPbkContactStore& aTargetStore, |
|
51 RReadStream &aSourceStream ) |
|
52 { |
|
53 if ( aType == ECompactBusinessCard ) |
|
54 { |
|
55 iOperationImpl = CVPbkVCardCompactBCardImporter::NewL( |
|
56 aImportedContacts, aTargetStore, aSourceStream, aData ); |
|
57 } |
|
58 else if ( aType == EVCard ) |
|
59 { |
|
60 iOperationImpl = CVPbkVCardImporter::NewL( |
|
61 aImportedContacts, aSourceStream, aTargetStore, aData ); |
|
62 } |
|
63 else |
|
64 { |
|
65 User::Leave( KErrArgument ); |
|
66 } |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CVPbkImportToContactsOperation::NewL |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CVPbkImportToContactsOperation* CVPbkImportToContactsOperation::NewL( |
|
74 TVPbkImportCardType aType, |
|
75 CVPbkVCardData& aData, |
|
76 RPointerArray<MVPbkStoreContact>& aImportedContacts, |
|
77 MVPbkContactStore& aTargetStore, |
|
78 RReadStream &aSourceStream, |
|
79 MVPbkSingleContactOperationObserver& aObserver ) |
|
80 { |
|
81 CVPbkImportToContactsOperation* self = |
|
82 new( ELeave ) CVPbkImportToContactsOperation( aObserver ); |
|
83 CleanupStack::PushL( self ); |
|
84 self->ConstructL( aType, aData, aImportedContacts, aTargetStore, |
|
85 aSourceStream ); |
|
86 CleanupStack::Pop( self ); |
|
87 return self; |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // Destructor |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CVPbkImportToContactsOperation::~CVPbkImportToContactsOperation() |
|
96 { |
|
97 delete iOperationImpl; |
|
98 } |
|
99 |
|
100 // --------------------------------------------------------------------------- |
|
101 // From class MVPbkContactOperation |
|
102 // CVPbkImportToContactsOperation::StartL |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 void CVPbkImportToContactsOperation::StartL() |
|
106 { |
|
107 __ASSERT_DEBUG( iOperationImpl, VPbkVCardEngError::Panic( |
|
108 VPbkVCardEngError::EPreCond_CVPbkImportToStoreOperation_StartL ) ); |
|
109 |
|
110 iOperationImpl->SetObserver( *this ); |
|
111 iOperationImpl->StartL(); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // From class MVPbkContactOperation |
|
116 // CVPbkImportToContactsOperation::Cancel |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 void CVPbkImportToContactsOperation::Cancel() |
|
120 { |
|
121 delete iOperationImpl; |
|
122 iOperationImpl = NULL; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // From class MVPbkImportOperationObserver |
|
127 // CVPbkImportToContactsOperation::ContactsImported |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CVPbkImportToContactsOperation::ContactsImported() |
|
131 { |
|
132 // Client get contacts from the array it gave in construction |
|
133 iObserver.VPbkSingleContactOperationComplete( *this, NULL ); |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // From class MVPbkImportOperationObserver |
|
138 // CVPbkImportToContactsOperation::ContactImportingFailed |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CVPbkImportToContactsOperation::ContactImportingFailed( TInt aError ) |
|
142 { |
|
143 iObserver.VPbkSingleContactOperationFailed( *this, aError ); |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------------------------- |
|
147 // From class MVPbkImportOperationObserver |
|
148 // CVPbkImportToContactsOperation::ContactsImportingCompleted |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CVPbkImportToContactsOperation::ContactsImportingCompleted() |
|
152 { |
|
153 // Unused |
|
154 } |
|
155 |
|
156 // End of file |