1 /* |
|
2 * Copyright (c) 2010 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: Implements contact selection strategy. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef TPHCNTCONTACTSELECTIONSTRATEGY_H_ |
|
20 #define TPHCNTCONTACTSELECTIONSTRATEGY_H_ |
|
21 |
|
22 // System includes |
|
23 #include <e32std.h> |
|
24 #include <TVPbkContactStoreUriPtr.h> |
|
25 |
|
26 // Forward declarations |
|
27 class MVPbkContactLinkArray; |
|
28 class CVPbkContactStoreUriArray; |
|
29 |
|
30 // Constants |
|
31 const TInt KNoContact = -1; |
|
32 const TInt KManyContacts = -2; |
|
33 |
|
34 |
|
35 /** |
|
36 * Implements contact selection strategy. |
|
37 * |
|
38 */ |
|
39 NONSHARABLE_CLASS( TPhCntContactSelectionStrategy ) |
|
40 { |
|
41 public: |
|
42 |
|
43 /** Defines the options for contact selection strategy */ |
|
44 enum TAllowSeveralMatches |
|
45 { |
|
46 EAllowSingleMatch, |
|
47 EAllowSeveralMatches |
|
48 }; |
|
49 |
|
50 public: |
|
51 TPhCntContactSelectionStrategy( ); |
|
52 |
|
53 public: |
|
54 /** |
|
55 * Sets the contact selection strategy used in conjunction with |
|
56 * ApplyStrategy -method. |
|
57 * |
|
58 * @param aSeveralMatchesAllowed Option for contact selection strategy. |
|
59 */ |
|
60 void SetContactSelectionStrategy( TAllowSeveralMatches aSeveralMatchesAllowed ); |
|
61 |
|
62 /** |
|
63 * Returns the selected contact according to strategy. |
|
64 * If a call to SetContactSelectionStrategy is not made, |
|
65 * EAllowSingleMatch strategy is applied. |
|
66 * |
|
67 * @param aContactLinkArray Array of matching contacts. |
|
68 * @return index in array of selected contact. |
|
69 * KNoContact if empty array is passed. |
|
70 * KNoContact if several matches and EAllowSingleMatch set. |
|
71 */ |
|
72 TInt ApplyStrategy( const MVPbkContactLinkArray& aContactLinkArray ); |
|
73 |
|
74 /** |
|
75 * Returns the selected contact if single match from |
|
76 * additional contact stores is found. |
|
77 * |
|
78 * @param aContactLinkArray Array of matching contacts. |
|
79 * @param aAdditionalStoreUriArray Array of additional contact stores. |
|
80 * @return index in array of selected contact. |
|
81 * KNoContact if empty array is passed. |
|
82 * KManyContacts if several matches. |
|
83 */ |
|
84 TInt ApplyAdditonalStoreStrategy( const MVPbkContactLinkArray& aContactLinkArray, |
|
85 const CVPbkContactStoreUriArray& aAdditionalStoreUriArray ); |
|
86 |
|
87 protected: |
|
88 /** |
|
89 * Returns the URI of the contact store of the contact. |
|
90 * |
|
91 * @param aContactLinkArrayIndex Specifies the contact. |
|
92 * @return URI of the contact store. |
|
93 */ |
|
94 virtual TVPbkContactStoreUriPtr GetContactStoreUri( TInt aContactLinkArrayIndex ); |
|
95 |
|
96 private: |
|
97 TInt ApplySingleMatchStrategy( ); |
|
98 TInt ApplySeveralMatchesStrategy( ); |
|
99 |
|
100 private: |
|
101 TAllowSeveralMatches iSeveralMatchesAllowed; |
|
102 |
|
103 /* Not owned */ |
|
104 const MVPbkContactLinkArray* iContactLinkArray; |
|
105 }; |
|
106 |
|
107 |
|
108 #endif /* TPHCNTCONTACTSELECTIONSTRATEGY_H_ */ |
|