|
1 // Copyright (c) 2007-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 #include <ecom/ecom.h> |
|
17 #include <tmsvpackednotifierrequest.h> |
|
18 #include <ecom/implementationproxy.h> |
|
19 #include <gsmubuf.h> |
|
20 #include <s32mem.h> |
|
21 #include <e32base.h> |
|
22 #include "class0smsUInotifier.h" |
|
23 |
|
24 /* UID of Class 0 SMS test notifier */ |
|
25 const TUid KClass0SmsNotifierPluginUid = {0x2000C382}; |
|
26 const TUid KClass0SmsNotifierOutput = {0x2000C382}; |
|
27 |
|
28 //class 0 SMS data will be writing to file |
|
29 _LIT(KTestClas0Sms, "\\logs\\testexecute\\class0sms.txt"); |
|
30 |
|
31 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray() |
|
32 { |
|
33 CArrayPtrFlat<MEikSrvNotifierBase2>* subjects=NULL; |
|
34 TRAPD( err, subjects=new (ELeave)CArrayPtrFlat<MEikSrvNotifierBase2>(1) ); |
|
35 if( err == KErrNone ) |
|
36 { |
|
37 TRAP( err, subjects->AppendL( CClass0SmsUINotifier::NewL() ) ); |
|
38 return(subjects); |
|
39 } |
|
40 else |
|
41 { |
|
42 return NULL; |
|
43 } |
|
44 } |
|
45 |
|
46 CClass0SmsUINotifier* CClass0SmsUINotifier::NewL() |
|
47 { |
|
48 CClass0SmsUINotifier* self=new (ELeave) CClass0SmsUINotifier(); |
|
49 CleanupStack::PushL(self); |
|
50 self->ConstructL(); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 } |
|
54 |
|
55 void CClass0SmsUINotifier::ConstructL() |
|
56 { |
|
57 } |
|
58 |
|
59 CClass0SmsUINotifier::~CClass0SmsUINotifier() |
|
60 { |
|
61 REComSession::FinalClose(); |
|
62 } |
|
63 |
|
64 CClass0SmsUINotifier::CClass0SmsUINotifier() |
|
65 { |
|
66 iInfo.iUid = KClass0SmsNotifierPluginUid; |
|
67 iInfo.iChannel = KClass0SmsNotifierOutput; |
|
68 iInfo.iPriority = ENotifierPriorityHigh; |
|
69 } |
|
70 |
|
71 void CClass0SmsUINotifier::Release() |
|
72 { |
|
73 delete this; |
|
74 } |
|
75 |
|
76 /** |
|
77 Called when a notifier is first loaded to allow any initial construction that is required. |
|
78 */ |
|
79 CClass0SmsUINotifier::TNotifierInfo CClass0SmsUINotifier::RegisterL() |
|
80 { |
|
81 return iInfo; |
|
82 } |
|
83 |
|
84 CClass0SmsUINotifier::TNotifierInfo CClass0SmsUINotifier::Info() const |
|
85 { |
|
86 return iInfo; |
|
87 } |
|
88 |
|
89 /** |
|
90 The notifier has been deactivated so resources can be freed and outstanding messages completed. |
|
91 */ |
|
92 void CClass0SmsUINotifier::Cancel() |
|
93 { |
|
94 } |
|
95 |
|
96 /** |
|
97 Start the Notifier with data aBuffer. |
|
98 |
|
99 Not used for confirm notifiers |
|
100 */ |
|
101 TPtrC8 CClass0SmsUINotifier::StartL(const TDesC8& aBuffer) |
|
102 { |
|
103 CreateFile(aBuffer); |
|
104 return KNullDesC8(); |
|
105 } |
|
106 |
|
107 /** |
|
108 Start the notifier with data aBuffer. aMessage should be completed when the notifier is deactivated. |
|
109 |
|
110 May be called multiple times if more than one client starts the notifier. The notifier is immediately |
|
111 responsible for completing aMessage. |
|
112 */ |
|
113 void CClass0SmsUINotifier::StartL(const TDesC8& aBuffer, TInt /*aReplySlot*/, const RMessagePtr2& aMessage) |
|
114 { |
|
115 CreateFile(aBuffer); |
|
116 aMessage.Complete(KErrNone); |
|
117 } |
|
118 |
|
119 /** |
|
120 Update a currently active notifier with data aBuffer. |
|
121 |
|
122 Not used for confirm notifiers |
|
123 */ |
|
124 TPtrC8 CClass0SmsUINotifier::UpdateL(const TDesC8& /*aBuffer*/) |
|
125 { |
|
126 User::Leave(KErrNotSupported); |
|
127 return KNullDesC8(); |
|
128 } |
|
129 |
|
130 |
|
131 //Adding ECOM SUPPORT |
|
132 const TImplementationProxy ImplementationTable[] = |
|
133 { |
|
134 IMPLEMENTATION_PROXY_ENTRY(0x2000C612, NotifierArray) |
|
135 }; |
|
136 |
|
137 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
138 { |
|
139 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
140 return ImplementationTable; |
|
141 } |
|
142 |
|
143 //write received class0sms data to file |
|
144 void CClass0SmsUINotifier::CreateFile(const TDesC8& aBuff) |
|
145 { |
|
146 RFs fs; |
|
147 User::LeaveIfError(fs.Connect()); |
|
148 CleanupClosePushL(fs); |
|
149 |
|
150 TInt startPos, endPos; |
|
151 TBool isLastMessage = EFalse; |
|
152 |
|
153 RDesReadStream readStream(aBuff); |
|
154 CleanupClosePushL (readStream); |
|
155 |
|
156 startPos = readStream.ReadInt32L(); |
|
157 endPos = readStream.ReadInt32L(); |
|
158 isLastMessage = readStream.ReadInt32L(); |
|
159 |
|
160 TBuf<1000> smsMsg1; |
|
161 readStream >> smsMsg1; |
|
162 |
|
163 RFile file; |
|
164 |
|
165 TPtrC8 smsMsg(REINTERPRET_CAST(const TUint8*, smsMsg1.Ptr()), smsMsg1.Size()); |
|
166 User::LeaveIfError(file.Replace(fs, KTestClas0Sms, EFileShareAny | EFileWrite)); |
|
167 file.Write(smsMsg); |
|
168 |
|
169 file.Close(); |
|
170 CleanupStack::PopAndDestroy(&readStream); |
|
171 CleanupStack::PopAndDestroy(&fs); |
|
172 } |