|
1 /* |
|
2 * Copyright (c) 2002-2005 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: Factory for presence manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CAPresenceManager.h" |
|
22 #include "CCAPEngPresenceManager.h" |
|
23 #include "CAPresenceDll.h" |
|
24 #include "ChatDebugPrint.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CAPresenceManager::InstanceL |
|
30 // Create an instance of the presence manager |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 EXPORT_C MCAPresence* CAPresenceManager::InstanceL( MCASettings* aSettingsAPI ) |
|
34 { |
|
35 MCAPresence* mFactory = static_cast<MCAPresence*>( Dll::Tls() ); |
|
36 |
|
37 if ( !mFactory ) |
|
38 { |
|
39 CHAT_DP_TXT( "Creating IM Presence module singleton" ); |
|
40 CCAPEngPresenceManager *cFactory = CCAPEngPresenceManager::NewL( aSettingsAPI ); |
|
41 mFactory = cFactory; |
|
42 CleanupStack::PushL( cFactory ); |
|
43 User::LeaveIfError( Dll::SetTls( static_cast<TAny*>( mFactory ) ) ); |
|
44 CleanupStack::Pop( cFactory ); |
|
45 } |
|
46 else |
|
47 { |
|
48 CCAPEngPresenceManager *cFactory = static_cast<CCAPEngPresenceManager*> ( mFactory ); |
|
49 cFactory->SetSettingsAPIL( aSettingsAPI ); |
|
50 } |
|
51 |
|
52 return mFactory; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CAPresenceManager::ReleaseL |
|
57 // Release this Singleton |
|
58 // Used mainly for testing purposes |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C void CAPresenceManager::Release() |
|
62 { |
|
63 MCAPresence *mFactory = static_cast<MCAPresence*>( Dll::Tls() ); |
|
64 |
|
65 if ( mFactory ) |
|
66 { |
|
67 CCAPEngPresenceManager *cFactory = static_cast<CCAPEngPresenceManager*>( mFactory ); |
|
68 delete cFactory; |
|
69 Dll::SetTls( NULL ); // Returning error can be safely ignored |
|
70 CHAT_DP_TXT( "Destroying IM Presence module singleton" ); |
|
71 } |
|
72 } |
|
73 |
|
74 // End of File |