[app] Display 'transaction.value' after completion (bug #25)
[abstract.git] / base / aaEvent.cpp
blob5ee5b03c0b65b813d7a1e1c7cd6391c2e660f598
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 <abstract/aacore.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 <abstract/base/aaIFact.h>
34 #include <abstract/base/aaIEvent.h>
35 #include <abstract/base/aaIHandler.h>
36 #include "aaEvent.h"
38 aaEvent::aaEvent()
39 :mTag((const PRUnichar *) nsnull), mHasTime(PR_FALSE), mRead(PR_FALSE),
40 mEdited(PR_FALSE)
45 aaEvent::~aaEvent()
49 NS_IMPL_ISUPPORTS4_CI(aaEvent,
50 aaIDataNode,
51 aaIEvent,
52 nsIArray,
53 nsIMutableArray)
54 /* aaIDataNode */
55 NS_IMETHODIMP
56 aaEvent::GetId(PRInt64 *aId)
58 NS_ENSURE_ARG_POINTER(aId);
59 *aId = mId;
60 return NS_OK;
62 NS_IMETHODIMP
63 aaEvent::SetId(PRInt64 aId)
65 mId = aId;
66 return NS_OK;
69 NS_IMETHODIMP
70 aaEvent::Accept(aaIHandler* aQuery)
72 NS_ENSURE_ARG_POINTER(aQuery);
73 return aQuery->HandleEvent(this);
76 NS_IMETHODIMP
77 aaEvent::GetEdited(PRBool* aEdited)
79 NS_ENSURE_ARG_POINTER(aEdited);
80 *aEdited = mEdited;
81 return NS_OK;
84 /* aaIEvent */
85 NS_IMETHODIMP
86 aaEvent::GetTag(nsAString & aTag)
88 aTag.Assign(mTag);
89 mRead = PR_TRUE;
90 return NS_OK;
92 NS_IMETHODIMP
93 aaEvent::SetTag(const nsAString & aTag)
95 if (mTag.Equals(aTag))
96 return NS_OK;
97 if (mRead)
98 mEdited = PR_TRUE;
99 mTag.Assign(aTag);
100 return NS_OK;
103 NS_IMETHODIMP
104 aaEvent::GetTime(PRTime *aTime)
106 NS_ENSURE_TRUE( mHasTime, NS_ERROR_NOT_INITIALIZED);
107 NS_ENSURE_ARG_POINTER( aTime );
108 *aTime = mTime;
109 return NS_OK;
111 NS_IMETHODIMP
112 aaEvent::SetTime(PRTime aTime)
114 PRExplodedTime tm;
115 PR_ExplodeTime(aTime, &PR_LocalTimeParameters, &tm);
116 tm.tm_params.tp_gmt_offset = 0;
117 tm.tm_params.tp_dst_offset = 0;
118 tm.tm_hour = 12;
119 tm.tm_min = 0;
120 tm.tm_sec = 0;
121 tm.tm_usec = 0;
122 mTime = PR_ImplodeTime(&tm);
123 mHasTime = PR_TRUE;
124 return NS_OK;
127 /* nsIArray */
128 NS_IMETHODIMP
129 aaEvent::GetLength(PRUint32 *aLength)
131 NS_ENSURE_ARG_POINTER( aLength );
132 *aLength = mFacts.Count();
133 return NS_OK;
136 NS_IMETHODIMP
137 aaEvent::QueryElementAt(PRUint32 index, const nsIID & uuid, void * *result)
139 NS_ENSURE_TRUE( index < (PRUint32) mFacts.Count(), NS_ERROR_INVALID_ARG);
140 NS_ENSURE_ARG_POINTER( result );
141 return mFacts[index]->QueryInterface(uuid, result);
144 NS_IMETHODIMP
145 aaEvent::IndexOf(PRUint32 startIndex, nsISupports *element, PRUint32 *_retval)
147 return NS_ERROR_NOT_IMPLEMENTED;
150 NS_IMETHODIMP
151 aaEvent::Enumerate(nsISimpleEnumerator **_retval)
153 return NS_ERROR_NOT_IMPLEMENTED;
156 /* nsIMutableArray */
157 NS_IMETHODIMP
158 aaEvent::AppendElement(nsISupports *element, PRBool weak)
160 NS_ENSURE_TRUE(! weak, NS_ERROR_NOT_IMPLEMENTED);
161 nsCOMPtr<aaIFact> fact(do_QueryInterface( element ));
162 NS_ENSURE_TRUE(fact, NS_ERROR_INVALID_ARG);
163 if (mFacts.AppendObject(fact))
164 return NS_OK;
165 else
166 return NS_ERROR_FAILURE;
169 NS_IMETHODIMP
170 aaEvent::RemoveElementAt(PRUint32 index)
172 return NS_ERROR_NOT_IMPLEMENTED;
175 NS_IMETHODIMP
176 aaEvent::InsertElementAt(nsISupports *element, PRUint32 index, PRBool weak)
178 return NS_ERROR_NOT_IMPLEMENTED;
181 NS_IMETHODIMP
182 aaEvent::ReplaceElementAt(nsISupports *element, PRUint32 index, PRBool weak)
184 return NS_ERROR_NOT_IMPLEMENTED;
187 NS_IMETHODIMP
188 aaEvent::Clear()
190 return NS_ERROR_NOT_IMPLEMENTED;