os/security/contentmgmt/referencedrmagent/contentiterator/contentiteratordata.cpp
First public contribution.
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "contentiteratordata.h"
21 using namespace ContentAccess;
23 CContentIteratorData* CContentIteratorData::NewL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType)
25 CContentIteratorData* self = new (ELeave) CContentIteratorData();
26 CleanupStack::PushL(self);
27 self->ConstructL(aSearchPath, aRecursive, aMimeType);
28 CleanupStack::Pop(self);
32 CContentIteratorData::CContentIteratorData()
36 CContentIteratorData::~CContentIteratorData()
39 iThreadSemaphore.Signal();
41 iDataLockSemaphore.Close();
42 iThreadSemaphore.Close();
45 void CContentIteratorData::ConstructL(const TDesC& aSearchPath, TBool aRecursive, const TDesC8& aMimeType)
47 // Remember search parameters, the CContentIterator::ThreadEntry()
48 // will ask for these later
49 iPath.Copy(aSearchPath);
50 iRecursive = aRecursive;
51 iMimeType.Copy(aMimeType);
55 User::LeaveIfError(iDataLockSemaphore.CreateLocal(1, EOwnerProcess));
56 User::LeaveIfError(iThreadSemaphore.CreateLocal(1, EOwnerProcess));
58 // Grab semaphore so CContentIterator::ThreadEntry function can't enter the loop yet
59 iThreadSemaphore.Wait();
63 void CContentIteratorData::Lock()
65 iDataLockSemaphore.Wait();
68 void CContentIteratorData::Unlock()
70 iDataLockSemaphore.Signal();
73 void CContentIteratorData::CompleteClientRequest(TInt aError)
76 clientThread.Open(iClientThreadId);
77 clientThread.RequestComplete(iClientRequest, aError);
82 void CContentIteratorData::SetClientRequest(TThreadId& aClientThreadId, TRequestStatus& aStatus)
84 // Remember the thread and TRequestStatus that must be completed later
85 iClientThreadId = aClientThreadId;
86 iClientRequest = &aStatus;
89 void CContentIteratorData::RunThreadFunction(TFileIteratorOperation aFunction)
91 // Unblock the CContentIterator::ThreadEntry() function and allow it to run
92 iFunction = aFunction;
93 iThreadSemaphore.Signal();
96 TFileIteratorOperation CContentIteratorData::ThreadWait()
98 // Called by CContentIterator::ThreadEntry() to block execution until RunThreadFunction() is called
99 iThreadSemaphore.Wait();
104 void CContentIteratorData::SetData(const TDesC& aPath, const TDesC& aUniqueId, const TDesC& aName, const TDesC8& aMimeType)
106 // Set the results found in the search
108 iMimeType.Copy(aMimeType);
109 iUniqueId.Copy(aUniqueId);
113 const TDesC& CContentIteratorData::Path() const
118 const TDesC8& CContentIteratorData::MimeType() const
123 const TDesC& CContentIteratorData::UniqueId() const
128 const TDesC& CContentIteratorData::Name() const
133 TBool CContentIteratorData::IsRecursive() const