|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 @released |
|
20 */ |
|
21 |
|
22 #if !defined(__SS_SELECT_H__) |
|
23 #define __SS_SELECT_H__ |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <s32std.h> |
|
27 |
|
28 namespace ESock |
|
29 { |
|
30 class ISelectionNotify; |
|
31 class MProviderSelector |
|
32 /** |
|
33 @internalTechnology |
|
34 */ |
|
35 { |
|
36 public: |
|
37 virtual void Cancel() = 0; |
|
38 virtual void SelectL(ISelectionNotify& aSelectionNotify) = 0; |
|
39 virtual ~MProviderSelector() {}; |
|
40 }; |
|
41 |
|
42 class CMetaConnectionProviderBase; |
|
43 typedef void (*TSelectCompleteFn)(TAny*, MProviderSelector*, CMetaConnectionProviderBase*); |
|
44 typedef void (*TStateChangeNotificationFn)(TAny*, MProviderSelector*, TInt, TInt); |
|
45 typedef void (*TErrorFn)(TAny*, MProviderSelector*, TInt); |
|
46 typedef void (*TAnyFn)(TAny*); |
|
47 |
|
48 class ISelectionNotify |
|
49 /** |
|
50 @internalTechnology |
|
51 */ |
|
52 { |
|
53 public: |
|
54 enum |
|
55 { |
|
56 KCallbacksCount = 3 |
|
57 }; |
|
58 |
|
59 public: |
|
60 ISelectionNotify() : |
|
61 iThis(NULL), |
|
62 iInterfaceVTable(NULL) |
|
63 { |
|
64 } |
|
65 |
|
66 ISelectionNotify(TAny* aThis, const TAnyFn& aInterfaceVTable) : |
|
67 iThis( aThis ), |
|
68 iInterfaceVTable( &aInterfaceVTable ) |
|
69 { |
|
70 } |
|
71 |
|
72 void SelectComplete(MProviderSelector* aSelector, CMetaConnectionProviderBase* aProvider) |
|
73 { |
|
74 if ( Check(1) ) |
|
75 { |
|
76 ((TSelectCompleteFn)(iInterfaceVTable[1]))(iThis, aSelector, aProvider); |
|
77 } |
|
78 } |
|
79 |
|
80 void StateChangeNotification(MProviderSelector* aSelector, TInt aStage, TInt aError) |
|
81 { |
|
82 if ( Check(2) ) |
|
83 { |
|
84 ((TStateChangeNotificationFn)iInterfaceVTable[2])(iThis, aSelector, aStage, aError); |
|
85 } |
|
86 } |
|
87 |
|
88 void Error(MProviderSelector* aSelector, TInt aError) |
|
89 { |
|
90 if ( Check(3) ) |
|
91 { |
|
92 ((TErrorFn)iInterfaceVTable[3])(iThis, aSelector, aError); |
|
93 } |
|
94 } |
|
95 |
|
96 private: |
|
97 TBool Check( TInt nFn ) |
|
98 { |
|
99 return iInterfaceVTable && (TInt)iInterfaceVTable[0] >= nFn && iInterfaceVTable[nFn]; |
|
100 } |
|
101 |
|
102 private: |
|
103 TAny* iThis; |
|
104 TAnyFn const* iInterfaceVTable; |
|
105 }; |
|
106 |
|
107 |
|
108 template <class TCLIENT> |
|
109 class TSelectionNotify |
|
110 /** |
|
111 @internalTechnology |
|
112 */ |
|
113 { |
|
114 public: |
|
115 static void SelectComplete(TAny* aThis, MProviderSelector* aSelector, CMetaConnectionProviderBase* aProvider); |
|
116 static void StateChangeNotification(TAny* aThis, MProviderSelector* aSelector, TInt aStage, TInt aError); |
|
117 static void SelectError(TAny* aThis, MProviderSelector* aSelector, TInt aError); |
|
118 }; |
|
119 |
|
120 template <class TCLIENT> |
|
121 void TSelectionNotify<TCLIENT>::SelectComplete(TAny* aThis, MProviderSelector* aSelector, CMetaConnectionProviderBase* aProvider) |
|
122 { |
|
123 TCLIENT* me = (TCLIENT*)aThis; |
|
124 me->SelectComplete(aSelector,aProvider); |
|
125 } |
|
126 |
|
127 template <class TCLIENT> |
|
128 void TSelectionNotify<TCLIENT>::StateChangeNotification(TAny* aThis, MProviderSelector* aSelector, TInt aStage, TInt aError) |
|
129 { |
|
130 TCLIENT* me = (TCLIENT*)aThis; |
|
131 me->StateChangeNotification(aSelector,aStage,aError); |
|
132 } |
|
133 |
|
134 template <class TCLIENT> |
|
135 void TSelectionNotify<TCLIENT>::SelectError(TAny* aThis, MProviderSelector* aSelector, TInt aError) |
|
136 { |
|
137 TCLIENT* me = (TCLIENT*)aThis; |
|
138 me->SelectError(aSelector,aError); |
|
139 } |
|
140 |
|
141 |
|
142 } //namespace ESock |
|
143 |
|
144 #endif //__SS_SELECT_H__ |
|
145 |