transport: pass correct channel
[abstract.git] / storage / base / aaFactSideDelete.cpp
blob13358e14bd6c6d10706b29aa8f6824d38821d307
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) 2008 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 "nsComponentManagerUtils.h"
26 #include "nsXPCOMCID.h"
27 #include "nsIMutableArray.h"
28 #include "nsISupportsPrimitives.h"
30 /* Unfrozen API */
32 /* Project includes */
33 #include "aaAmountUtils.h"
34 #include "aaIEvent.h"
36 #include "aaFactSideDelete.h"
38 static const char *sql =
39 "DELETE FROM fact WHERE event_id = ? AND\
40 day = round(julianday(?,'unixepoch'))";
42 aaFactSideDelete::aaFactSideDelete()
44 mSql = sql;
47 NS_IMPL_ISUPPORTS_INHERITED0(aaFactSideDelete,
48 aaSaveRequest)
50 /* aaSaveRequest */
51 NS_IMETHODIMP
52 aaFactSideDelete::SetFilter(nsISupports * aFilter)
54 nsresult rv;
55 mEvent = do_QueryInterface(aFilter, &rv);
56 NS_ENSURE_SUCCESS(rv, rv);
58 return NS_OK;
61 NS_IMETHODIMP
62 aaFactSideDelete::GetParams(nsIArray * * aParams)
64 NS_ENSURE_TRUE(mEvent, NS_ERROR_NOT_INITIALIZED);
65 nsresult rv;
67 PRTime time;
68 rv = mEvent->GetTime(&time);
69 NS_ENSURE_SUCCESS(rv, rv);
70 time /= 1000000;
72 nsCOMPtr<nsIMutableArray> result
73 = do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
74 NS_ENSURE_SUCCESS(rv, rv);
76 nsCOMPtr<nsISupportsPRInt64> valInt64;
78 valInt64 = do_CreateInstance(NS_SUPPORTS_PRINT64_CONTRACTID, &rv);
79 NS_ENSURE_SUCCESS(rv, rv);
80 rv = valInt64->SetData(mEvent->PickId());
81 NS_ENSURE_SUCCESS(rv, rv);
82 rv = result->InsertElementAt(valInt64, 0, PR_FALSE);
83 NS_ENSURE_SUCCESS(rv, rv);
85 valInt64 = do_CreateInstance(NS_SUPPORTS_PRINT64_CONTRACTID, &rv);
86 NS_ENSURE_SUCCESS(rv, rv);
87 rv = valInt64->SetData(time);
88 NS_ENSURE_SUCCESS(rv, rv);
89 rv = result->InsertElementAt(valInt64, 1, PR_FALSE);
90 NS_ENSURE_SUCCESS(rv, rv);
92 *aParams = result;
93 result.forget();
95 return NS_OK;