[accounting] Add 'load chart' query (bug 86)
[abstract.git] / base / aaEvent.cpp
blobecfb7bff3f9073008fe9fe29bbd6936a4fde7d60
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent tw=79 ft=cpp: */
3 /*
4 * Copyright (C) 2007 Sergey Yanovich <ynvich@gmail.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "xpcom-config.h"
24 #include "nsCOMPtr.h"
25 #include "nsStringAPI.h"
26 #include "nsEmbedString.h"
27 #include "nsIMutableArray.h"
28 #include "nsCOMArray.h"
29 #include "nsMemory.h"
30 #include "nsIClassInfoImpl.h"
32 /* Project includes */
33 #include "aaIFact.h"
34 #include "aaIHandler.h"
35 #include "aaEvent.h"
37 aaEvent::aaEvent()
38 :mTag((const PRUnichar *) nsnull), mHasTime(PR_FALSE), mRead(PR_FALSE),
39 mEdited(PR_FALSE)
44 aaEvent::~aaEvent()
48 NS_IMPL_ISUPPORTS4_CI(aaEvent,
49 aaIDataNode,
50 aaIEvent,
51 nsIArray,
52 nsIMutableArray)
53 /* aaIDataNode */
54 NS_IMETHODIMP
55 aaEvent::GetId(PRInt64 *aId)
57 NS_ENSURE_ARG_POINTER(aId);
58 *aId = mId;
59 return NS_OK;
61 NS_IMETHODIMP
62 aaEvent::SetId(PRInt64 aId)
64 mId = aId;
65 return NS_OK;
68 NS_IMETHODIMP
69 aaEvent::Accept(aaIHandler* aQuery)
71 NS_ENSURE_ARG_POINTER(aQuery);
72 return aQuery->HandleEvent(this);
75 NS_IMETHODIMP
76 aaEvent::GetEdited(PRBool* aEdited)
78 NS_ENSURE_ARG_POINTER(aEdited);
79 *aEdited = mEdited;
80 return NS_OK;
83 /* aaIEvent */
84 NS_IMETHODIMP
85 aaEvent::GetTag(nsAString & aTag)
87 aTag.Assign(mTag);
88 mRead = PR_TRUE;
89 return NS_OK;
91 NS_IMETHODIMP
92 aaEvent::SetTag(const nsAString & aTag)
94 if (mTag.Equals(aTag))
95 return NS_OK;
96 if (mRead)
97 mEdited = PR_TRUE;
98 mTag.Assign(aTag);
99 return NS_OK;
102 NS_IMETHODIMP
103 aaEvent::GetTime(PRTime *aTime)
105 NS_ENSURE_TRUE( mHasTime, NS_ERROR_NOT_INITIALIZED);
106 NS_ENSURE_ARG_POINTER( aTime );
107 *aTime = mTime;
108 return NS_OK;
110 NS_IMETHODIMP
111 aaEvent::SetTime(PRTime aTime)
113 PRExplodedTime tm;
114 PR_ExplodeTime(aTime, &PR_LocalTimeParameters, &tm);
115 tm.tm_params.tp_gmt_offset = 0;
116 tm.tm_params.tp_dst_offset = 0;
117 tm.tm_hour = 12;
118 tm.tm_min = 0;
119 tm.tm_sec = 0;
120 tm.tm_usec = 0;
121 mTime = PR_ImplodeTime(&tm);
122 mHasTime = PR_TRUE;
123 return NS_OK;
126 /* nsIArray */
127 NS_IMETHODIMP
128 aaEvent::GetLength(PRUint32 *aLength)
130 NS_ENSURE_ARG_POINTER( aLength );
131 *aLength = mFacts.Count();
132 return NS_OK;
135 NS_IMETHODIMP
136 aaEvent::QueryElementAt(PRUint32 index, const nsIID & uuid, void * *result)
138 NS_ENSURE_TRUE( index < (PRUint32) mFacts.Count(), NS_ERROR_INVALID_ARG);
139 NS_ENSURE_ARG_POINTER( result );
140 return mFacts[index]->QueryInterface(uuid, result);
143 NS_IMETHODIMP
144 aaEvent::IndexOf(PRUint32 startIndex, nsISupports *element, PRUint32 *_retval)
146 return NS_ERROR_NOT_IMPLEMENTED;
149 NS_IMETHODIMP
150 aaEvent::Enumerate(nsISimpleEnumerator **_retval)
152 return NS_ERROR_NOT_IMPLEMENTED;
155 /* nsIMutableArray */
156 NS_IMETHODIMP
157 aaEvent::AppendElement(nsISupports *element, PRBool weak)
159 NS_ENSURE_TRUE(! weak, NS_ERROR_NOT_IMPLEMENTED);
160 nsCOMPtr<aaIFact> fact(do_QueryInterface( element ));
161 NS_ENSURE_TRUE(fact, NS_ERROR_INVALID_ARG);
162 if (mFacts.AppendObject(fact))
163 return NS_OK;
164 else
165 return NS_ERROR_FAILURE;
168 NS_IMETHODIMP
169 aaEvent::RemoveElementAt(PRUint32 index)
171 return NS_ERROR_NOT_IMPLEMENTED;
174 NS_IMETHODIMP
175 aaEvent::InsertElementAt(nsISupports *element, PRUint32 index, PRBool weak)
177 return NS_ERROR_NOT_IMPLEMENTED;
180 NS_IMETHODIMP
181 aaEvent::ReplaceElementAt(nsISupports *element, PRUint32 index, PRBool weak)
183 return NS_ERROR_NOT_IMPLEMENTED;
186 NS_IMETHODIMP
187 aaEvent::Clear()
189 return NS_ERROR_NOT_IMPLEMENTED;