|
1 // nullnif.cpp |
|
2 // |
|
3 // Copyright (c) 2009 - 2010 Accenture. All rights reserved. |
|
4 // This component and the accompanying materials are made available |
|
5 // under the terms of the "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 // Accenture - Initial contribution |
|
11 // |
|
12 |
|
13 #include <in_sock.h> |
|
14 #include <in_iface.h> |
|
15 #include <comms-infras/nifif.h> |
|
16 |
|
17 |
|
18 NONSHARABLE_CLASS(CNullNif) : public CNifIfLink |
|
19 { |
|
20 public: |
|
21 CNullNif(CNifIfFactory& aFactory); |
|
22 ~CNullNif(); |
|
23 virtual void BindL(TAny *aId); |
|
24 virtual TInt State(); |
|
25 virtual TInt Control(TUint aLevel,TUint aName,TDes8& aOption, TAny* aSource=0); |
|
26 virtual TInt Send(RMBufChain& aPdu, TAny* aSource=0); |
|
27 virtual TInt Start(); |
|
28 virtual void Stop(TInt aReason, MNifIfNotify::TAction aAction); |
|
29 virtual CNifIfBase* GetBinderL(const TDesC& aName); |
|
30 virtual void Info(TNifIfInfo& aInfo) const; |
|
31 virtual TInt Notification(TAgentToNifEventType aEvent, void* aInfo); |
|
32 virtual void Restart(CNifIfBase* aIf); |
|
33 static void FillInInfo(TNifIfInfo& aInfo); |
|
34 }; |
|
35 |
|
36 CNullNif::CNullNif(CNifIfFactory& aFactory) |
|
37 : CNifIfLink(aFactory) |
|
38 { |
|
39 } |
|
40 |
|
41 CNullNif::~CNullNif() |
|
42 { |
|
43 } |
|
44 |
|
45 void CNullNif::Info(TNifIfInfo& aInfo) const |
|
46 { |
|
47 FillInInfo(aInfo); |
|
48 } |
|
49 |
|
50 void CNullNif::FillInInfo(TNifIfInfo& aInfo) |
|
51 { |
|
52 aInfo.iVersion = TVersion(0, 0, 0); |
|
53 aInfo.iFlags = KNifIfIsBase | KNifIfUsesNotify | KNifIfIsLink | KNifIfCreatedByFactory; |
|
54 _LIT(KNullNif, "nullnif"); |
|
55 aInfo.iName = KNullNif; |
|
56 aInfo.iProtocolSupported = KProtocolInetIp; |
|
57 } |
|
58 |
|
59 void CNullNif::BindL(TAny*) |
|
60 { |
|
61 } |
|
62 |
|
63 TInt CNullNif::Send(RMBufChain&, TAny*) |
|
64 { |
|
65 return 0; |
|
66 } |
|
67 |
|
68 TInt CNullNif::State() |
|
69 { |
|
70 return EIfUp; |
|
71 } |
|
72 |
|
73 TInt CNullNif::Control(TUint aLevel, TUint aName, TDes8& aOption, TAny* /*aSource*/) |
|
74 { |
|
75 if (aLevel != KSOLInterface) |
|
76 { |
|
77 return KErrNotSupported; |
|
78 } |
|
79 |
|
80 switch (aName) |
|
81 { |
|
82 case KSoIfInfo: |
|
83 { |
|
84 TSoIfInfo& opt = *(TSoIfInfo*)aOption.Ptr(); |
|
85 TNifIfInfo info; |
|
86 FillInInfo(info); |
|
87 opt.iName = info.iName; |
|
88 return KErrNone; |
|
89 } |
|
90 } |
|
91 |
|
92 return KErrNotSupported; |
|
93 } |
|
94 |
|
95 CNifIfBase* CNullNif::GetBinderL(const TDesC&) |
|
96 { |
|
97 return NULL; |
|
98 } |
|
99 |
|
100 TInt CNullNif::Start() |
|
101 { |
|
102 iNotify->IfProgress(KLinkLayerOpen, KErrNone); |
|
103 iNotify->LinkLayerUp(); |
|
104 return KErrNone; |
|
105 } |
|
106 |
|
107 void CNullNif::Stop(TInt aReason, MNifIfNotify::TAction aAction) |
|
108 { |
|
109 iNotify->LinkLayerDown(aReason, aAction); |
|
110 iNotify->IfProgress(EIfProgressLinkDown, aReason); |
|
111 } |
|
112 |
|
113 TInt CNullNif::Notification(TAgentToNifEventType, void*) |
|
114 { |
|
115 return KErrNone; |
|
116 } |
|
117 |
|
118 void CNullNif::Restart(CNifIfBase*) |
|
119 { |
|
120 } |
|
121 |
|
122 |
|
123 NONSHARABLE_CLASS(CNullNifIfFactory) : public CNifIfFactory |
|
124 { |
|
125 protected: |
|
126 virtual void InstallL(); |
|
127 virtual CNifIfBase* NewInterfaceL(const TDesC& aName); |
|
128 TInt Info(TNifIfInfo& aInfo, TInt aIndex) const; |
|
129 }; |
|
130 |
|
131 TInt CNullNifIfFactory::Info(TNifIfInfo& aInfo, TInt) const |
|
132 { |
|
133 CNullNif::FillInInfo(aInfo); |
|
134 return 1; |
|
135 } |
|
136 |
|
137 void CNullNifIfFactory::InstallL() |
|
138 { |
|
139 } |
|
140 |
|
141 CNifIfBase* CNullNifIfFactory::NewInterfaceL(const TDesC& aName) |
|
142 { |
|
143 _LIT(KNullNif, "nullnif"); |
|
144 if (aName.CompareF(KNullNif)) |
|
145 { |
|
146 User::Leave(KErrNotSupported); |
|
147 } |
|
148 |
|
149 return new (ELeave) CNullNif(*this); |
|
150 } |
|
151 |
|
152 // Force export of non-mangled name |
|
153 extern "C" { IMPORT_C CNifFactory *Install(); } |
|
154 |
|
155 EXPORT_C CNifFactory *Install() |
|
156 { |
|
157 return new (ELeave) CNullNifIfFactory; |
|
158 } |
|
159 |