|
1 // Copyright (c) 2006-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 "pbapfoldertree.h" |
|
17 #include "pbapfolderbase.h" |
|
18 |
|
19 #include "btaccesshostlog.h" |
|
20 #include "pbapserver.h" |
|
21 |
|
22 |
|
23 /*static*/ CVirtualFolders* CVirtualFolders::NewLC() |
|
24 { |
|
25 LOG_STATIC_FUNC |
|
26 CVirtualFolders* self = new (ELeave) CVirtualFolders; |
|
27 CleanupStack::PushL(self); |
|
28 self->ConstructL(); |
|
29 return self; |
|
30 } |
|
31 |
|
32 |
|
33 void CVirtualFolders::ConstructL() |
|
34 { |
|
35 LOG_FUNC |
|
36 } |
|
37 |
|
38 |
|
39 CVirtualFolders::CVirtualFolders() |
|
40 : iSubtrees(_FOFF(CVirtualFolders,iQueLink)) |
|
41 { |
|
42 LOG_FUNC |
|
43 } |
|
44 |
|
45 |
|
46 CVirtualFolders::~CVirtualFolders() |
|
47 { |
|
48 LOG_FUNC |
|
49 delete iItem; |
|
50 TSglQueIter<CVirtualFolders> iter(iSubtrees); |
|
51 CVirtualFolders* subtree=NULL; |
|
52 while ((subtree = iter++)!=NULL) |
|
53 { |
|
54 iSubtrees.Remove(*subtree); |
|
55 delete subtree; |
|
56 } |
|
57 } |
|
58 |
|
59 /** |
|
60 Place a folder object into the tree, takes ownership of aFolder |
|
61 */ |
|
62 void CVirtualFolders::PlaceFolderL(CFolderBase* aFolder) |
|
63 { |
|
64 LOG_FUNC |
|
65 if(iItem) |
|
66 { |
|
67 __ASSERT_DEBUG(EFalse, Panic(EVirtualFolderAlreadyInPlace)); |
|
68 User::Leave(KErrAlreadyExists); |
|
69 } |
|
70 iItem = aFolder; |
|
71 } |
|
72 |
|
73 /** |
|
74 Return a reference to the current folder object |
|
75 */ |
|
76 CFolderBase& CVirtualFolders::Folder() const |
|
77 { |
|
78 LOG_FUNC |
|
79 return *iItem; |
|
80 } |
|
81 |
|
82 /** |
|
83 Attach an entire subtree to the current tree |
|
84 */ |
|
85 void CVirtualFolders::AttachSubtree(CVirtualFolders* aSubtree) |
|
86 { |
|
87 LOG_FUNC |
|
88 |
|
89 #ifdef _DEBUG // long hand __ASSERT_DEBUG for aSubtree already attached |
|
90 TSglQueIter<CVirtualFolders> iter(iSubtrees); |
|
91 CVirtualFolders* subtree = NULL; |
|
92 while ((subtree = iter++) != NULL) |
|
93 { |
|
94 if (subtree == aSubtree) |
|
95 { |
|
96 // aSubtree already exists |
|
97 Panic(EVirtualFolderSubtreeAlreadyExists); |
|
98 } |
|
99 } |
|
100 #endif // _DEBUG |
|
101 |
|
102 iSubtrees.AddLast(*aSubtree); |
|
103 aSubtree->iParentFolder = this; |
|
104 } |
|
105 |
|
106 |
|
107 CVirtualFolders* CVirtualFolders::ParentFolder() const |
|
108 { |
|
109 LOG_FUNC |
|
110 return iParentFolder; |
|
111 } |
|
112 |
|
113 /** |
|
114 Change to the nominated child folder object |
|
115 @param aFolder the name of PBAP Folder to which to change |
|
116 */ |
|
117 CVirtualFolders* CVirtualFolders::NavigateFolder(const TDesC& aFolderName) |
|
118 { |
|
119 LOG_FUNC |
|
120 |
|
121 TSglQueIter<CVirtualFolders> iter(iSubtrees); |
|
122 |
|
123 CVirtualFolders* subtree = NULL; |
|
124 while ((subtree = iter++)!=NULL) |
|
125 { |
|
126 if (subtree->Folder().FolderName()==aFolderName) |
|
127 { |
|
128 return subtree; |
|
129 } |
|
130 } |
|
131 return NULL; |
|
132 } |