1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERYHELPER_HXX
21 #define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERYHELPER_HXX
23 #include <sal/config.h>
27 #include <MNSInclude.hxx>
28 #include "MErrorResource.hxx"
29 #include <sal/types.h>
30 #include <rtl/ustring.hxx>
31 #include <osl/mutex.hxx>
32 #include <osl/conditn.hxx>
33 #include <osl/thread.hxx>
35 #include <boost/unordered_map.hpp>
37 namespace connectivity
41 class MQueryHelperResultEntry
44 typedef ::boost::unordered_map
< OString
, OUString
, OStringHash
> FieldMap
;
46 mutable ::osl::Mutex m_aMutex
;
48 nsCOMPtr
<nsIAbCard
> m_Card
;
49 sal_Int32 m_RowStates
;
52 MQueryHelperResultEntry();
53 ~MQueryHelperResultEntry();
55 void insert( const OString
&key
, OUString
&value
);
56 OUString
getValue( const OString
&key
) const;
57 void setValue( const OString
&key
, const OUString
& rValue
);
59 void setCard(nsIAbCard
*card
);
61 sal_Bool
setRowStates(sal_Int32 state
){m_RowStates
= state
; return sal_True
;};
62 sal_Int32
getRowStates() const { return m_RowStates
;};
65 class MQueryHelper
: public nsIAbDirectoryQueryResultListener
68 typedef std::vector
< MQueryHelperResultEntry
* > resultsArray
;
70 mutable ::osl::Mutex m_aMutex
;
71 ::osl::Condition m_aCondition
;
72 resultsArray m_aResults
;
76 sal_Bool m_bErrorCondition
;
77 sal_Bool m_bQueryComplete
;
78 ErrorDescriptor m_aError
;
80 void append(MQueryHelperResultEntry
* resEnt
);
84 void clearResultOrComplete();
85 void notifyResultOrComplete();
86 sal_Bool
waitForResultOrComplete( );
87 void getCardValues(nsIAbCard
*card
,sal_uInt32 rowIndex
=0);
88 #if OSL_DEBUG_LEVEL > 0
89 oslThreadIdentifier m_oThreadID
;
94 NS_DECL_NSIABDIRECTORYQUERYRESULTLISTENER
97 virtual ~MQueryHelper();
101 MQueryHelperResultEntry
* next( );
103 MQueryHelperResultEntry
* getByIndex( sal_uInt32 nRow
);
105 const ErrorDescriptor
& getError() const { return m_aError
; }
107 sal_Bool
isError() const;
109 sal_Bool
queryComplete() const;
111 sal_Bool
waitForQueryComplete( );
112 sal_Bool
waitForRow( sal_Int32 rowNum
);
114 sal_Int32
getResultCount() const;
115 sal_uInt32
getRealCount() const;
116 sal_Int32
createNewCard(); //return Row count number
117 sal_Bool
resyncRow(sal_uInt32 rowIndex
);
119 void notifyQueryError() ;
120 sal_Bool
setCardValues(const sal_uInt32 rowIndex
);
121 sal_Int32
commitCard(const sal_uInt32 rowIndex
, nsIAbDirectory
* directory
);
122 sal_Int32
deleteCard(const sal_uInt32 rowIndex
, nsIAbDirectory
* directory
);
126 #endif // INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_MOZAB_MOZILLASRC_MQUERYHELPER_HXX
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */