|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <smscmds.h> |
|
20 #include <smsclnt.h> |
|
21 #include <smuthdr.h> |
|
22 #include <mtclreg.h> |
|
23 |
|
24 #include "catalogssmsutils.h" |
|
25 |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // Creator |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CCatalogsSmsUtils* CCatalogsSmsUtils::NewL() |
|
32 { |
|
33 CCatalogsSmsUtils* self = new( ELeave ) CCatalogsSmsUtils(); |
|
34 return self; |
|
35 } |
|
36 |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Destructor |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CCatalogsSmsUtils::~CCatalogsSmsUtils() |
|
43 { |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // SMS center number getter |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 HBufC* CCatalogsSmsUtils::SmsCenterNumberLC() |
|
51 { |
|
52 // Open a session to the message server. |
|
53 CMsvSession* session; |
|
54 session = CMsvSession::OpenSyncL( *this ); |
|
55 |
|
56 // We get a MtmClientRegistry from our session |
|
57 // this registry is used to instantiate new mtms. |
|
58 CClientMtmRegistry* mtmRegistry; |
|
59 mtmRegistry = CClientMtmRegistry::NewL( *session ); |
|
60 |
|
61 CleanupStack::PushL( mtmRegistry ); |
|
62 |
|
63 // Create a new message entry. |
|
64 |
|
65 // This represents an entry in the Message Server index |
|
66 TMsvEntry msvEntry; |
|
67 |
|
68 // message type is SMS |
|
69 msvEntry.iMtm = KUidMsgTypeSMS; |
|
70 |
|
71 // this defines the type of the entry: message |
|
72 msvEntry.iType = KUidMsvMessageEntry; |
|
73 |
|
74 // ID of local service ( containing the standard folders ) |
|
75 msvEntry.iServiceId = KMsvLocalServiceIndexEntryId; |
|
76 |
|
77 // set the date of the entry to home time |
|
78 msvEntry.iDate.HomeTime(); |
|
79 |
|
80 // a flag that this message is in preparations |
|
81 msvEntry.SetInPreparation( ETrue ); |
|
82 |
|
83 // Create a new mtm to handle this message ( in case our own mtm is in use) |
|
84 CSmsClientMtm* smsMtm = |
|
85 static_cast<CSmsClientMtm*>( mtmRegistry->NewMtmL( msvEntry.iMtm ) ); |
|
86 CleanupStack::PushL( smsMtm ); |
|
87 |
|
88 smsMtm->RestoreServiceAndSettingsL(); |
|
89 |
|
90 // no, there isn't. We assume there is at least one sc number set and use |
|
91 // the default SC number. |
|
92 CSmsSettings* serviceSettings = &( smsMtm->ServiceSettings()); |
|
93 |
|
94 HBufC* number = NULL; |
|
95 // if number of scaddresses in the list is null |
|
96 if ( serviceSettings->ServiceCenterCount() == 0 ) |
|
97 { |
|
98 // Here should be a dialog in which user can add sc number |
|
99 number = KNullDesC().AllocL(); |
|
100 } |
|
101 else |
|
102 { |
|
103 // set sc address to default. |
|
104 number = serviceSettings->GetServiceCenter( |
|
105 serviceSettings->DefaultServiceCenter() ).Address().AllocL(); |
|
106 } |
|
107 |
|
108 CleanupStack::PopAndDestroy( smsMtm ); |
|
109 CleanupStack::PopAndDestroy( mtmRegistry ); |
|
110 delete session; |
|
111 CleanupStack::PushL( number ); |
|
112 return number; |
|
113 } |
|
114 |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // Handler for CMsvSession events |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void CCatalogsSmsUtils::HandleSessionEventL( TMsvSessionEvent /* aEvent */, |
|
121 TAny* /* aArg1 */, TAny* /* aArg2 */, TAny* /* aArg3 */ ) |
|
122 { |
|
123 } |
|
124 |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // Constructor |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 CCatalogsSmsUtils::CCatalogsSmsUtils() |
|
131 { |
|
132 } |