Update ooo320-m1
[ooovba.git] / connectivity / source / drivers / mozab / mozillasrc / MQueryHelper.hxx
bloba33fe7f5cad44d2c98e0dd4c0ea81ee45535f092
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: MQueryHelper.hxx,v $
10 * $Revision: 1.8 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CONNECTIVITY_MAB_QUERYHELPER_HXX_
32 #define _CONNECTIVITY_MAB_QUERYHELPER_HXX_
34 #include <MNSInclude.hxx>
35 #include "MErrorResource.hxx"
36 #include <sal/types.h>
37 #include <rtl/ustring.hxx>
38 #include <osl/mutex.hxx>
39 #include <osl/conditn.hxx>
40 #include <comphelper/stl_types.hxx>
41 #include <osl/thread.hxx>
43 #include <hash_map>
45 namespace connectivity
47 namespace mozab
49 class MQueryHelperResultEntry
51 private:
52 typedef ::std::hash_map< ::rtl::OString, ::rtl::OUString, ::rtl::OStringHash > FieldMap;
54 mutable ::osl::Mutex m_aMutex;
55 FieldMap m_Fields;
56 nsCOMPtr<nsIAbCard> m_Card;
57 sal_Int32 m_RowStates;
59 public:
60 MQueryHelperResultEntry();
61 ~MQueryHelperResultEntry();
63 void insert( const rtl::OString &key, rtl::OUString &value );
64 rtl::OUString getValue( const rtl::OString &key ) const;
65 void setValue( const rtl::OString &key, const rtl::OUString & rValue);
67 void setCard(nsIAbCard *card);
68 nsIAbCard *getCard();
69 sal_Bool setRowStates(sal_Int32 state){m_RowStates = state; return sal_True;};
70 sal_Int32 getRowStates() { return m_RowStates;};
73 class MQueryHelper : public nsIAbDirectoryQueryResultListener
75 private:
76 typedef std::vector< MQueryHelperResultEntry* > resultsArray;
78 mutable ::osl::Mutex m_aMutex;
79 ::osl::Condition m_aCondition;
80 resultsArray m_aResults;
81 sal_Int32 m_nIndex;
82 sal_Bool m_bHasMore;
83 sal_Bool m_bAtEnd;
84 sal_Bool m_bErrorCondition;
85 sal_Bool m_bQueryComplete;
86 ErrorDescriptor m_aError;
88 void append(MQueryHelperResultEntry* resEnt );
90 void clear_results();
92 void clearResultOrComplete();
93 void notifyResultOrComplete();
94 sal_Bool waitForResultOrComplete( );
95 void getCardValues(nsIAbCard *card,sal_Int32 rowIndex=0);
96 #if OSL_DEBUG_LEVEL > 0
97 oslThreadIdentifier m_oThreadID;
98 #endif
100 public:
102 NS_DECL_ISUPPORTS
103 NS_DECL_NSIABDIRECTORYQUERYRESULTLISTENER
105 MQueryHelper();
107 virtual ~MQueryHelper();
109 void reset();
111 void rewind();
113 MQueryHelperResultEntry* next( );
115 MQueryHelperResultEntry* getByIndex( sal_uInt32 nRow );
117 const ErrorDescriptor& getError() const { return m_aError; }
119 sal_Bool isError() const;
121 sal_Bool hasMore() const;
123 sal_Bool atEnd() const;
125 sal_Bool queryComplete() const;
127 sal_Bool waitForQueryComplete( );
129 sal_Bool waitForRow( sal_Int32 rowNum );
131 sal_Int32 getResultCount() const;
133 sal_uInt32 getRealCount() const;
134 sal_Int32 createNewCard(); //return Row count number
135 sal_Bool resyncRow(sal_Int32 rowIndex);
137 void notifyQueryError() ;
138 sal_Bool setCardValues(const sal_Int32 rowIndex);
139 sal_Int32 commitCard(const sal_Int32 rowIndex, nsIAbDirectory * directory);
140 sal_Int32 deleteCard(const sal_Int32 rowIndex, nsIAbDirectory * directory);
144 #endif // _CONNECTIVITY_MAB_QUERYHELPER_HXX_